void MaterialGeneratorNode::addOutput( const MaterialGeneratorNodeConnectorDesc& desc )
{
    MaterialGeneratorNodeConnectorAttachment* att(HENew(MaterialGeneratorNodeConnectorAttachment)(this, desc));
    att->init(eNodeGraphNodeConnectorType_Output, desc.m_Id, desc.m_Name.c_str());
    addAttachment(att);
    m_Outputs.add(att);
}
Example #2
0
PermissionAttachment *PermissibleBase::addAttachment(Plugin *plugin, int ticks)
{
	if (!plugin || !plugin->isEnabled())
		return NULL;

	PermissionAttachment *result = addAttachment(plugin);

	return result;
}
Example #3
0
PermissionAttachment *PermissibleBase::addAttachment(Plugin *plugin, const std::string &name, bool value, int ticks)
{
	if (!plugin || !plugin->isEnabled())
		return NULL;

	PermissionAttachment *result = addAttachment(plugin, ticks);

	if (result)
		result->setPermission(name, value);

	return result;
}
Example #4
0
void XFE_ComposeAttachFolderView::addExistingAttachments()
{
    // we're only going to do this once per window
    if (_addedExistingAttachments)
        return;
    
    // add pre-existing attachments to the icon panel (e.g. during msg forward)
    const struct MSG_AttachmentData *al=MSG_GetAttachmentList(getPane());
    if (al) {
        while(al->url) {
            addAttachment(al->url,TRUE); // set 'pre_exisiting' flag - don't add to internal list
            al++;
        }
    }
}
void KOEditorAttachments::readIncidence( KCal::Incidence *i )
{
  mAttachments->clear();

  KCal::Attachment::List attachments = i->attachments();
  KCal::Attachment::List::ConstIterator it;
  for ( it = attachments.constBegin(); it != attachments.constEnd(); ++it ) {
    addAttachment( (*it) );
  }

  mUid = i->uid();

  if ( mAttachments->count() > 0 ) {
    QTimer::singleShot( 0, mAttachments, SLOT(arrangeItemsInGrid()) );
  }
}
Example #6
0
GBuffer::GBuffer(Qt3DCore::QNode *parent)
    : Qt3DRender::QRenderTarget(parent)
{
    const Qt3DRender::QAbstractTextureProvider::TextureFormat formats[AttachmentsCount] = {
        Qt3DRender::QAbstractTextureProvider::RGBA32F,
        Qt3DRender::QAbstractTextureProvider::RGB32F,
        Qt3DRender::QAbstractTextureProvider::RGB16F,
        Qt3DRender::QAbstractTextureProvider::D32F
    };

    const Qt3DRender::QRenderAttachment::RenderAttachmentType attachmentTypes[AttachmentsCount] = {
        Qt3DRender::QRenderAttachment::ColorAttachment0,
        Qt3DRender::QRenderAttachment::ColorAttachment1,
        Qt3DRender::QRenderAttachment::ColorAttachment2,
        Qt3DRender::QRenderAttachment::DepthAttachment
    };

    const QString attachmentNames[AttachmentsCount] = {
        QString::fromLatin1("color"),
        QString::fromLatin1("position"),
        QString::fromLatin1("normal"),
        QString::fromLatin1("depth")
    };

    for (int i = 0; i < AttachmentsCount; i++) {
        Qt3DRender::QRenderAttachment *attachment = new Qt3DRender::QRenderAttachment(this);

        m_textures[i] = new Qt3DRender::QTexture2D();
        m_textures[i]->setFormat(formats[i]);
        m_textures[i]->setWidth(1024);
        m_textures[i]->setHeight(1024);
        m_textures[i]->setGenerateMipMaps(false);
        m_textures[i]->setWrapMode(Qt3DRender::QTextureWrapMode(Qt3DRender::QTextureWrapMode::ClampToEdge));
        m_textures[i]->setMinificationFilter(Qt3DRender::QAbstractTextureProvider::Linear);
        m_textures[i]->setMagnificationFilter(Qt3DRender::QAbstractTextureProvider::Linear);

        attachment->setTexture(m_textures[i]);
        attachment->setType(attachmentTypes[i]);
        attachment->setName(attachmentNames[i]);

        addAttachment(attachment);
    }
}
Example #7
0
AttachmentsDialog::AttachmentsDialog() :
    QDialog(Application::getInstance()->getWindow()) {
    
    setWindowTitle("Edit Attachments");
    setAttribute(Qt::WA_DeleteOnClose);
    
    QVBoxLayout* layout = new QVBoxLayout();
    setLayout(layout);
    
    QScrollArea* area = new QScrollArea();
    layout->addWidget(area);
    area->setWidgetResizable(true);
    QWidget* container = new QWidget();
    container->setLayout(_attachments = new QVBoxLayout());
    container->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Preferred);
    area->setWidget(container);
    _attachments->addStretch(1);
    
    foreach (const AttachmentData& data, Application::getInstance()->getAvatar()->getAttachmentData()) {
        addAttachment(data);
    }
Example #8
0
void ElogThreadSubmit::doTransmit(int sock) {
  KstELOGCaptureStruct captureStruct;
  QByteArray	byteArrayCapture;
  QBuffer bufferCapture( byteArrayCapture );
  QByteArray	byteArrayConfigure;
  QTextStream textStreamConfigure( byteArrayConfigure, IO_ReadWrite );
  QByteArray	byteArrayDebugInfo;
  QTextStream textStreamDebugInfo( byteArrayDebugInfo, IO_ReadWrite );
  QCustomEvent eventCapture(KstELOGCaptureEvent);
  QCustomEvent eventConfigure(KstELOGConfigureEvent);
  QCustomEvent eventDebugInfo(KstELOGDebugInfoEvent);
  QStringList::iterator it;
  QStringList	strListAttributes;
  QStringList	strListAttribute;
  QString strSplit( "\n" );
  QString strSplitAttribute( "=" );
  QString strUserName;
  QString strUserPassword;
  QString strWritePassword;
  QString strLogbook;
  QString strAttributes;
  QString strText;
  bool bIncludeCapture;
  bool bIncludeConfiguration;
  bool bIncludeDebugInfo;
  bool bSubmitAsHTML;
  bool bSuppressEmail;
  char* content;
  char request[100000];
  char response[100000];
  char boundary[80], str[80], *p;
  int i, n, header_length, content_length;
  int iAttachment = 0;

  bIncludeCapture   		= _elog->entry()->includeCapture();
  bIncludeConfiguration = _elog->entry()->includeConfiguration();
  bIncludeDebugInfo     = _elog->entry()->includeDebugInfo();
  content_length 			  = 100000;
  
  if( bIncludeCapture ) {  
    captureStruct.pBuffer     = &bufferCapture;
    captureStruct.iWidth      = _elog->configuration()->captureWidth();
    captureStruct.iHeight     = _elog->configuration()->captureHeight();
    eventCapture.setData( &captureStruct );
    QApplication::sendEvent( (QObject*)_elog->app()->viewObject(), (QEvent*)&eventCapture );
    content_length += byteArrayCapture.size();
  }
  
  if( bIncludeConfiguration ) {
    eventConfigure.setData( &textStreamConfigure );
    QApplication::sendEvent( (QObject*)_elog->app(), (QEvent*)&eventConfigure );
    content_length += byteArrayConfigure.size();
  }
  
  if( bIncludeDebugInfo ) {
    eventDebugInfo.setData( &textStreamDebugInfo );
    QApplication::sendEvent( (QObject*)_elog->app(), (QEvent*)&eventDebugInfo );
    content_length += byteArrayDebugInfo.size();
  }
  
  content = (char*)malloc(content_length);
  if (content != NULL) {
    strUserName 					= _elog->configuration()->userName();
    strUserPassword 			= _elog->configuration()->userPassword();
    strWritePassword			= _elog->configuration()->writePassword();
    strLogbook  					= _elog->configuration()->name();
    bSubmitAsHTML    		  = _elog->configuration()->submitAsHTML();
    bSuppressEmail    		= _elog->configuration()->suppressEmail();
    strAttributes     		= _elog->entry()->attributes();
    strText     					= _elog->entry()->text();
    
    srand((unsigned) time(NULL));
    sprintf(boundary, "---------------------------%04X%04X%04X", rand(), rand(), rand());
    strcpy(content, boundary);
    strcat(content, "\r\nContent-Disposition: form-data; name=\"cmd\"\r\n\r\nSubmit\r\n");
    
    //
    // add the attributes...
    //
    addAttribute( content, boundary, "unm", strUserName, false );
    addAttribute( content, boundary, "upwd", strUserPassword, true );
    addAttribute( content, boundary, "exp", strLogbook, false );
    
    strListAttributes = QStringList::split( strSplit, strAttributes, FALSE ); 
    for ( it = strListAttributes.begin(); it != strListAttributes.end(); ++it ) {
      strListAttribute = QStringList::split( strSplitAttribute, *it, FALSE );
      if( strListAttribute.count() == 2 ) {
        addAttribute( content, boundary, 
                      strListAttribute.first().stripWhiteSpace().ascii(),
                      strListAttribute.last().stripWhiteSpace(), false );
      }
    }
    if( bSubmitAsHTML ) {
      addAttribute( content, boundary, "html", "1", false );      
    }
    if( bSuppressEmail ) {
      addAttribute( content, boundary, "suppress", "1", false );      
    }
    addAttribute( content, boundary, "Text", strText, false );
    sprintf( content + strlen(content), "%s\r\n", boundary );

    content_length = strlen(content);
    p = content + content_length;
    
    //
    // add the attachments...
    //
    if( bIncludeCapture ) {
      iAttachment++;
      addAttachment( &content_length, &p, boundary, &byteArrayCapture, iAttachment, "Capture.png" );
    }
    if( bIncludeConfiguration ) {
      iAttachment++;
      addAttachment( &content_length, &p, boundary, &byteArrayConfigure, iAttachment, "Configure.kst" );
    }
    if( bIncludeDebugInfo ) {
      iAttachment++;
      addAttachment( &content_length, &p, boundary, &byteArrayDebugInfo, iAttachment, "DebugInfo.txt" );
    }

    strcpy(request, "POST /");
    if (!strLogbook.isEmpty()) {
      sprintf(request + strlen(request), "%s/", strLogbook.ascii());
    }
    strcat(request, " HTTP/1.0\r\n");
    
    sprintf(request + strlen(request), "Content-Type: multipart/form-data; boundary=%s\r\n", boundary);
    sprintf(request + strlen(request), "Host: %s\r\n", _host_name);
    sprintf(request + strlen(request), "User-Agent: ELOG\r\n");
    sprintf(request + strlen(request), "Content-Length: %d\r\n", content_length);
    
    if (!strWritePassword.isEmpty()) {
      base64_encode(strWritePassword.ascii(), str);
      sprintf(request + strlen(request), "Cookie: wpwd=%s\r\n", str);
    }

    strcat(request, "\r\n");
    
    header_length = strlen(request);
    
    send(sock, request, header_length, 0);
    send(sock, content, content_length, 0);
    
    //
    // handle the response...
    //
    i = recv(sock, response, 10000, 0);
    if (i >= 0) {    
      n = i;
      while (i > 0) {
        i = recv(sock, response + n, 10000, 0);
        if (i > 0) {
          n += i;
        }
      }
      response[n] = 0;
      
      doResponseError(response);
    }
    else
    {
      doError( tr2i18n("ELOG entry: unable to receive response"), KstDebug::Notice );
    }
  }
}
void PlaneMoveManipulator::onCreate(const PlaneMoveManipulator* source)
{
    // Skip direct parent, don't want the default geometry creation
    Transform::onCreate(source);

    SimpleMaterialUnrecPtr pMat = SimpleMaterial::create();
    pMat->setDiffuse(Color3f(.5, .5, .5));
    pMat->setLit    (false              );
    setMaterialX(pMat);

    pMat = SimpleMaterial::create();
    pMat->setDiffuse(Color3f(0, 1, 0));
    pMat->setLit    (false           );
    LineChunkUnrecPtr lc = LineChunk::create();
    lc->setWidth(3);
    pMat->addChunk(lc);
    setMaterialY(pMat);

    pMat = SimpleMaterial::create();
    pMat->setDiffuse(Color3f(0., 0., 1.));
    pMat->setLit    (true               );
    setMaterialZ(pMat);

//    SimpleMaterial *simpleMat;
//    Geometry       *geo;

    setExternalUpdateHandler(NULL);

    // add a name attachment
    NameUnrecPtr nameN = Name::create();
    nameN->editFieldPtr()->setValue("XYManipulator");
    addAttachment(nameN);

    // make the axis line. Not really a handle, but easier to manage this way.
       
    GeoBuilder b;
    
    b.vertex(Pnt3f(0,0,0));
    b.vertex(Pnt3f(0,getLength()[1],0));
    
    b.line(0, 1);
    
    GeometryUnrecPtr g = b.getGeometry();
    
    g->setMaterial(getMaterialY());
    
    NodeUnrecPtr pNode = makeNodeFor(g);
    setTransYNode(pNode);

    // make the plane handle

    pNode = Node::create();
    setTransXNode(pNode);

    g = makePlaneGeo(getLength()[0] / 2.f, getLength()[2] / 2.f, 1, 1);
    g->setMaterial(getMaterialX());   
    pNode = makeNodeFor(g);
    
    OSG::ComponentTransformUnrecPtr transHandleXC = ComponentTransform::create();

    setHandleXNode(pNode);

    getTransXNode()->setCore (transHandleXC   );
    getTransXNode()->addChild(getHandleXNode());

    transHandleXC->setTranslation(Vec3f(0, getLength()[1], 0));
    transHandleXC->setRotation   (Quaternion(Vec3f(1, 0, 0), osgDegree2Rad(90)));

    //
    // make the rotate handle

    pNode = Node::create();
    setTransZNode(pNode);

    g = makeCylinderGeo(0.05f, 0.1f, 16, true, true, true);
    g->setMaterial(getMaterialZ());   
    pNode = makeNodeFor(g);
    
    OSG::ComponentTransformUnrecPtr transHandleZC = ComponentTransform::create();

    setHandleZNode(pNode);

    getTransZNode()->setCore (transHandleZC   );
    getTransZNode()->addChild(getHandleZNode());

    transHandleZC->setTranslation(Vec3f(0, getLength()[1], 0));

    commitChanges();
}
Example #10
0
void Framebuffer::attachTexture(const GLenum attachment, Texture * texture, const GLint level)
{
    implementation().attachTexture(this, attachment, texture, level);

    addAttachment(AttachedTexture::create(this, attachment, texture, level));
}
Example #11
0
bool handleContextMenuAction(s32 cmd_id)
{

    World *world = World::getWorld();
    Physics *physics = world ? world->getPhysics() : NULL;
    switch(cmd_id)
    {
    case DEBUG_GRAPHICS_RELOAD_SHADERS:
            Log::info("Debug", "Reloading shaders...");
            ShaderBase::updateShaders();
            break;
    case DEBUG_GRAPHICS_RESET:
        if (physics)
            physics->setDebugMode(IrrDebugDrawer::DM_NONE);

        irr_driver->resetDebugModes();
        break;
    case DEBUG_GRAPHICS_WIREFRAME:
        if (physics)
            physics->setDebugMode(IrrDebugDrawer::DM_NONE);

        irr_driver->resetDebugModes();
        irr_driver->toggleWireframe();
        break;
    case DEBUG_GRAPHICS_MIPMAP_VIZ:
        if (physics)
            physics->setDebugMode(IrrDebugDrawer::DM_NONE);

        irr_driver->resetDebugModes();
        irr_driver->toggleMipVisualization();
        break;
    case DEBUG_GRAPHICS_NORMALS_VIZ:
        if (physics)
            physics->setDebugMode(IrrDebugDrawer::DM_NONE);

        irr_driver->resetDebugModes();
        irr_driver->toggleNormals();
        break;
    case DEBUG_GRAPHICS_SSAO_VIZ:
        if (physics)
            physics->setDebugMode(IrrDebugDrawer::DM_NONE);

        irr_driver->resetDebugModes();
        irr_driver->toggleSSAOViz();
        break;
    case DEBUG_GRAPHICS_RSM_VIZ:
        if (physics)
            physics->setDebugMode(IrrDebugDrawer::DM_NONE);

        irr_driver->resetDebugModes();
        irr_driver->toggleRSM();
        break;
    case DEBUG_GRAPHICS_RH_VIZ:
        if (physics)
            physics->setDebugMode(IrrDebugDrawer::DM_NONE);

        irr_driver->resetDebugModes();
        irr_driver->toggleRH();
        break;
    case DEBUG_GRAPHICS_GI_VIZ:
        if (physics)
            physics->setDebugMode(IrrDebugDrawer::DM_NONE);

        irr_driver->resetDebugModes();
        irr_driver->toggleGI();
        break;
    case DEBUG_GRAPHICS_SHADOW_VIZ:
        if (physics)
            physics->setDebugMode(IrrDebugDrawer::DM_NONE);

        irr_driver->resetDebugModes();
        irr_driver->toggleShadowViz();
        break;
    case DEBUG_GRAPHICS_LIGHT_VIZ:
        if (physics)
            physics->setDebugMode(IrrDebugDrawer::DM_NONE);

        irr_driver->resetDebugModes();
        irr_driver->toggleLightViz();
        break;
    case DEBUG_GRAPHICS_DISTORT_VIZ:
        if (physics)
            physics->setDebugMode(IrrDebugDrawer::DM_NONE);

        irr_driver->resetDebugModes();
        irr_driver->toggleDistortViz();
        break;
    case DEBUG_GRAPHICS_BULLET_1:
        irr_driver->resetDebugModes();

        if (!world) return false;
        physics->setDebugMode(IrrDebugDrawer::DM_KARTS_PHYSICS);
        break;
    case DEBUG_GRAPHICS_BULLET_2:
    {
        irr_driver->resetDebugModes();

        if (!world) return false;
        Physics *physics = world->getPhysics();
        physics->setDebugMode(IrrDebugDrawer::DM_NO_KARTS_GRAPHICS);
        break;
    }
    case DEBUG_GRAPHICS_BOUNDING_BOXES_VIZ:
        irr_driver->resetDebugModes();
        irr_driver->toggleBoundingBoxesViz();
        break;
    case DEBUG_PROFILER:
        UserConfigParams::m_profiler_enabled =
            !UserConfigParams::m_profiler_enabled;
        break;
    case DEBUG_PROFILER_GENERATE_REPORT:
        profiler.setCaptureReport(!profiler.getCaptureReport());
        break;
    case DEBUG_THROTTLE_FPS:
        main_loop->setThrottleFPS(false);
        break;
    case DEBUG_FONT_DUMP_GLYPH_PAGE:
        font_manager->getFont<BoldFace>()->dumpGlyphPage("bold");
        font_manager->getFont<DigitFace>()->dumpGlyphPage("digit");
        font_manager->getFont<RegularFace>()->dumpGlyphPage("regular");
    case DEBUG_FONT_RELOAD:
        font_manager->getFont<BoldFace>()->reset();
        font_manager->getFont<DigitFace>()->reset();
        font_manager->getFont<RegularFace>()->reset();
        break;
    case DEBUG_FPS:
        UserConfigParams::m_display_fps =
            !UserConfigParams::m_display_fps;
        break;
    case DEBUG_SAVE_REPLAY:
        ReplayRecorder::get()->save();
        break;
    case DEBUG_SAVE_HISTORY:
        history->Save();
        break;
    case DEBUG_POWERUP_BOWLING:
        addPowerup(PowerupManager::POWERUP_BOWLING);
        break;
    case DEBUG_POWERUP_BUBBLEGUM:
        addPowerup(PowerupManager::POWERUP_BUBBLEGUM);
        break;
    case DEBUG_POWERUP_CAKE:
        addPowerup(PowerupManager::POWERUP_CAKE);
        break;
    case DEBUG_POWERUP_PARACHUTE:
        addPowerup(PowerupManager::POWERUP_PARACHUTE);
        break;
    case DEBUG_POWERUP_PLUNGER:
        addPowerup(PowerupManager::POWERUP_PLUNGER);
        break;
    case DEBUG_POWERUP_RUBBERBALL:
        addPowerup(PowerupManager::POWERUP_RUBBERBALL);
        break;
    case DEBUG_POWERUP_SWATTER:
        addPowerup(PowerupManager::POWERUP_SWATTER);
        break;
    case DEBUG_POWERUP_SWITCH:
        addPowerup(PowerupManager::POWERUP_SWITCH);
        break;
    case DEBUG_POWERUP_ZIPPER:
        addPowerup(PowerupManager::POWERUP_ZIPPER);
        break;
    case DEBUG_POWERUP_NITRO:
    {
        if (!world) return false;
        const unsigned int num_local_players =
            race_manager->getNumLocalPlayers();
        for (unsigned int i = 0; i < num_local_players; i++)
        {
            AbstractKart* kart = world->getLocalPlayerKart(i);
            kart->setEnergy(100.0f);
        }
        break;
    }
    case DEBUG_ATTACHMENT_ANVIL:
        addAttachment(Attachment::ATTACH_ANVIL);
        break;
    case DEBUG_ATTACHMENT_BOMB:
        addAttachment(Attachment::ATTACH_BOMB);
        break;
    case DEBUG_ATTACHMENT_PARACHUTE:
        addAttachment(Attachment::ATTACH_PARACHUTE);
        break;
    case DEBUG_GUI_TOGGLE:
    {
        if (!world) return false;
        RaceGUIBase* gui = world->getRaceGUI();
        if (gui != NULL) gui->m_enabled = !gui->m_enabled;
        break;
    }
    case DEBUG_GUI_HIDE_KARTS:
        if (!world) return false;
        for (unsigned int n = 0; n<world->getNumKarts(); n++)
        {
            AbstractKart* kart = world->getKart(n);
            if (kart->getController()->isPlayerController())
                kart->getNode()->setVisible(false);
        }
        break;
    case DEBUG_GUI_CAM_TOP:
        CameraDebug::setDebugType(CameraDebug::CM_DEBUG_TOP_OF_KART);
        Camera::changeCamera(0, Camera::CM_TYPE_DEBUG);
        irr_driver->getDevice()->getCursorControl()->setVisible(true);
        break;
    case DEBUG_GUI_CAM_WHEEL:
        CameraDebug::setDebugType(CameraDebug::CM_DEBUG_GROUND);
        Camera::changeCamera(0, Camera::CM_TYPE_DEBUG);
        irr_driver->getDevice()->getCursorControl()->setVisible(true);
        break;
    case DEBUG_GUI_CAM_BEHIND_KART:
        CameraDebug::setDebugType(CameraDebug::CM_DEBUG_BEHIND_KART);
        Camera::changeCamera(0, Camera::CM_TYPE_DEBUG);
        irr_driver->getDevice()->getCursorControl()->setVisible(true);
        break;
    case DEBUG_GUI_CAM_SIDE_OF_KART:
        CameraDebug::setDebugType(CameraDebug::CM_DEBUG_SIDE_OF_KART);
        Camera::changeCamera(0, Camera::CM_TYPE_DEBUG);
        irr_driver->getDevice()->getCursorControl()->setVisible(true);
        break;
    case DEBUG_GUI_CAM_FREE:
    {
        Camera *camera = Camera::getActiveCamera();
        Camera::changeCamera(camera->getIndex(), Camera::CM_TYPE_FPS);
        irr_driver->getDevice()->getCursorControl()->setVisible(false);
        // Reset camera rotation
        CameraFPS *cam = dynamic_cast<CameraFPS*>(Camera::getActiveCamera());
        if(cam)
        {
            cam->setDirection(vector3df(0, 0, 1));
            cam->setUpVector(vector3df(0, 1, 0));
        }
        break;
    }
    case DEBUG_GUI_CAM_NORMAL:
    {
        Camera *camera = Camera::getActiveCamera();
        Camera::changeCamera(camera->getIndex(), Camera::CM_TYPE_NORMAL);
        irr_driver->getDevice()->getCursorControl()->setVisible(true);
        break;
    }
    case DEBUG_GUI_CAM_SMOOTH:
    {
        CameraFPS *cam = dynamic_cast<CameraFPS*>(Camera::getActiveCamera());
        if(cam)
        {
            cam->setSmoothMovement(!cam->getSmoothMovement());
        }
        break;
    }
    case DEBUG_GUI_CAM_ATTACH:
    {
        CameraFPS *cam = dynamic_cast<CameraFPS*>(Camera::getActiveCamera());
        if(cam)
        {
            cam->setAttachedFpsCam(!cam->getAttachedFpsCam());
        }
        break;
    }
    case DEBUG_VIEW_KART_ONE:
        changeCameraTarget(1);
        break;
    case DEBUG_VIEW_KART_TWO:
        changeCameraTarget(2);
        break;
    case DEBUG_VIEW_KART_THREE:
        changeCameraTarget(3);
        break;
    case DEBUG_VIEW_KART_FOUR:
        changeCameraTarget(4);
        break;
    case DEBUG_VIEW_KART_FIVE:
        changeCameraTarget(5);
        break;
    case DEBUG_VIEW_KART_SIX:
        changeCameraTarget(6);
        break;
    case DEBUG_VIEW_KART_SEVEN:
        changeCameraTarget(7);
        break;
    case DEBUG_VIEW_KART_EIGHT:
        changeCameraTarget(8);
        break;
    case DEBUG_PRINT_START_POS:
        if (!world) return false;
        for (unsigned int i = 0; i<world->getNumKarts(); i++)
        {
            AbstractKart *kart = world->getKart(i);
            Log::warn(kart->getIdent().c_str(),
                "<start position=\"%d\" x=\"%f\" y=\"%f\" z=\"%f\" h=\"%f\"/>",
                i, kart->getXYZ().getX(), kart->getXYZ().getY(),
                kart->getXYZ().getZ(), kart->getHeading()*RAD_TO_DEGREE
                );
        }
        break;
    case DEBUG_VISUAL_VALUES:
    {
#if !defined(__APPLE__)
        DebugSliderDialog *dsd = new DebugSliderDialog();
        dsd->setSliderHook("red_slider", 0, 255,
            [](){ return int(irr_driver->getAmbientLight().r * 255.f); },
            [](int v){
            video::SColorf ambient = irr_driver->getAmbientLight();
            ambient.setColorComponentValue(0, v / 255.f);
            irr_driver->setAmbientLight(ambient); }
        );
        dsd->setSliderHook("green_slider", 0, 255,
            [](){ return int(irr_driver->getAmbientLight().g * 255.f); },
            [](int v){
            video::SColorf ambient = irr_driver->getAmbientLight();
            ambient.setColorComponentValue(1, v / 255.f);
            irr_driver->setAmbientLight(ambient); }
        );
        dsd->setSliderHook("blue_slider", 0, 255,
            [](){ return int(irr_driver->getAmbientLight().b * 255.f); },
            [](int v){
            video::SColorf ambient = irr_driver->getAmbientLight();
            ambient.setColorComponentValue(2, v / 255.f);
            irr_driver->setAmbientLight(ambient); }
        );
        dsd->setSliderHook("ssao_radius", 0, 100,
            [](){ return int(irr_driver->getSSAORadius() * 10.f); },
            [](int v){irr_driver->setSSAORadius(v / 10.f); }
        );
        dsd->setSliderHook("ssao_k", 0, 100,
            [](){ return int(irr_driver->getSSAOK() * 10.f); },
            [](int v){irr_driver->setSSAOK(v / 10.f); }
        );
        dsd->setSliderHook("ssao_sigma", 0, 100,
            [](){ return int(irr_driver->getSSAOSigma() * 10.f); },
            [](int v){irr_driver->setSSAOSigma(v / 10.f); }
        );
#endif
    }
    break;
    case DEBUG_ADJUST_LIGHTS:
    {
#if !defined(__APPLE__)
        // Some sliders use multipliers because the spinner widget
        // only supports integers
        DebugSliderDialog *dsd = new DebugSliderDialog();
        dsd->changeLabel("Red", "Red (x10)");
        dsd->setSliderHook("red_slider", 0, 100,
            []()
            {
                return int(findNearestLight()->getColor().X * 100);
            },
            [](int intensity)
            {
                LightNode* nearest = findNearestLight();
                core::vector3df color = nearest->getColor();
                nearest->setColor(intensity / 100.0f, color.Y, color.Z);
            }
        );
        dsd->changeLabel("Green", "Green (x10)");
        dsd->setSliderHook("green_slider", 0, 100,
            []()
            {
                return int(findNearestLight()->getColor().Y * 100);
            },
            [](int intensity)
            {
                LightNode* nearest = findNearestLight();
                core::vector3df color = nearest->getColor();
                nearest->setColor(color.X, intensity / 100.0f, color.Z);
            }
        );
        dsd->changeLabel("Blue", "Blue (x10)");
        dsd->setSliderHook("blue_slider", 0, 100,
            []()
            {
                return int(findNearestLight()->getColor().Z * 100);
            },
            [](int intensity)
            {
                LightNode* nearest = findNearestLight();
                core::vector3df color = nearest->getColor();
                nearest->setColor(color.X, color.Y, intensity / 100.0f);
            }
        );
        dsd->changeLabel("SSAO radius", "energy (x10)");
        dsd->setSliderHook("ssao_radius", 0, 100,
            []()     { return int(findNearestLight()->getEnergy() * 10);  },
            [](int v){        findNearestLight()->setEnergy(v / 10.0f); }
        );
        dsd->changeLabel("SSAO k", "radius");
        dsd->setSliderHook("ssao_k", 0, 100,
            []()     { return int(findNearestLight()->getRadius());  },
            [](int v){        findNearestLight()->setRadius(float(v)); }
        );
        dsd->changeLabel("SSAO Sigma", "[None]");
#endif
        break;
    }
    case DEBUG_SCRIPT_CONSOLE:
        new ScriptingConsole();
        break;
    }   // switch
    return false;
}
Example #12
0
// Checked: 2010-03-21 (RLVa-1.2.0a) | Modified: RLVa-1.2.0a
void RlvForceWear::forceFolder(const LLViewerInventoryCategory* pFolder, EWearAction eAction, EWearFlags eFlags)
{
	// [See LLWearableBridge::wearOnAvatar(): don't wear anything until initial wearables are loaded, can destroy clothing items]
	if (!gAgentWearables.areWearablesLoaded())
	{
		LLNotificationsUtil::add("CanNotChangeAppearanceUntilLoaded");
		return;
	}
	if (!isAgentAvatarValid())
		return;

	// Grab a list of all the items we'll be wearing/attaching
	LLInventoryModel::cat_array_t folders; LLInventoryModel::item_array_t items;
	RlvWearableItemCollector f(pFolder, eAction, eFlags);
	gInventory.collectDescendentsIf(pFolder->getUUID(), folders, items, FALSE, f, TRUE);

	// TRUE if we've already encountered this LLWearableType::EType (used only on wear actions and only for AT_CLOTHING)
	bool fSeenWType[LLWearableType::WT_COUNT] = { false };

	EWearAction eCurAction = eAction;
	for (S32 idxItem = 0, cntItem = items.count(); idxItem < cntItem; idxItem++)
	{
		LLViewerInventoryItem* pRlvItem = items.get(idxItem);
		LLViewerInventoryItem* pItem = (LLAssetType::AT_LINK == pRlvItem->getActualType()) ? pRlvItem->getLinkedItem() : pRlvItem;

		// If it's wearable it should be worn on detach
//		if ( (ACTION_DETACH == eAction) && (isWearableItem(pItem)) && (!isWearingItem(pItem)) )
//			continue;

		// Each folder can specify its own EWearAction override
		if (isWearAction(eAction))
			eCurAction = f.getWearAction(pRlvItem->getParentUUID());
		else
			eCurAction = eAction;

		//  NOTES: * if there are composite items then RlvWearableItemCollector made sure they can be worn (or taken off depending)
		//         * some scripts issue @remattach=force,attach:worn-items=force so we need to attach items even if they're currently worn
		switch (pItem->getType())
		{
			case LLAssetType::AT_BODYPART:
				RLV_ASSERT(isWearAction(eAction));	// RlvWearableItemCollector shouldn't be supplying us with body parts on detach
			case LLAssetType::AT_CLOTHING:
				if (isWearAction(eAction))
				{
					// The first time we encounter any given clothing type we use 'eCurAction' (replace or add)
					// The second time we encounter a given clothing type we'll always add (rather than replace the previous iteration)
					eCurAction = (!fSeenWType[pItem->getWearableType()]) ? eCurAction : ACTION_WEAR_ADD;

					ERlvWearMask eWearMask = gRlvWearableLocks.canWear(pRlvItem);
					if ( ((ACTION_WEAR_REPLACE == eCurAction) && (eWearMask & RLV_WEAR_REPLACE)) ||
						 ((ACTION_WEAR_ADD == eCurAction) && (eWearMask & RLV_WEAR_ADD)) )
					{
						// The check for whether we're replacing a currently worn composite item happens in onWearableArrived()
						if (!isAddWearable(pItem))
							addWearable(pRlvItem, eCurAction);
						fSeenWType[pItem->getWearableType()] = true;
					}
				}
				else
				{
					const LLViewerWearable* pWearable = gAgentWearables.getWearableFromItemID(pItem->getUUID());
					if ( (pWearable) && (isForceRemovable(pWearable, false)) )
						remWearable(pWearable);
				}
				break;

			case LLAssetType::AT_OBJECT:
				if (isWearAction(eAction))
				{
					ERlvWearMask eWearMask = gRlvAttachmentLocks.canAttach(pRlvItem);
					if ( ((ACTION_WEAR_REPLACE == eCurAction) && (eWearMask & RLV_WEAR_REPLACE)) ||
						 ((ACTION_WEAR_ADD == eCurAction) && (eWearMask & RLV_WEAR_ADD)) )
					{
						if (!isAddAttachment(pRlvItem))
						{
							#ifdef RLV_EXPERIMENTAL_COMPOSITEFOLDERS
							// We still need to check whether we're about to replace a currently worn composite item
							// (which we're not if we're just reattaching an attachment we're already wearing)
							LLViewerInventoryCategory* pCompositeFolder = NULL;
							if ( (pAttachPt->getObject()) && (RlvSettings::getEnableComposites()) && 
								 (pAttachPt->getItemID() != pItem->getUUID()) &&
								 (gRlvHandler.getCompositeInfo(pAttachPt->getItemID(), NULL, &pCompositeFolder)) )
							{
								// If we can't take off the composite folder this item would replace then don't allow it to get attached
								if (gRlvHandler.canTakeOffComposite(pCompositeFolder))
								{
									forceFolder(pCompositeFolder, ACTION_DETACH, FLAG_DEFAULT);
									addAttachment(pRlvItem);
								}
							}
							else
							#endif // RLV_EXPERIMENTAL_COMPOSITEFOLDERS
							{
								addAttachment(pRlvItem, eCurAction);
							}
						}
					}
				}
				else
				{
					const LLViewerObject* pAttachObj = gAgentAvatarp->getWornAttachment(pItem->getUUID());
					if ( (pAttachObj) && (isForceDetachable(pAttachObj, false)) )
						remAttachment(pAttachObj);
				}
				break;

			#ifdef RLV_EXTENSION_FORCEWEAR_GESTURES
			case LLAssetType::AT_GESTURE:
				if (isWearAction(eAction))
				{
					if (std::find_if(m_addGestures.begin(), m_addGestures.end(), RlvPredIsEqualOrLinkedItem(pRlvItem)) == m_addGestures.end())
						m_addGestures.push_back(pRlvItem);
				}
				else
				{
					if (std::find_if(m_remGestures.begin(), m_remGestures.end(), RlvPredIsEqualOrLinkedItem(pRlvItem)) == m_remGestures.end())
						m_remGestures.push_back(pRlvItem);
				}
				break;
			#endif // RLV_EXTENSION_FORCEWEAR_GESTURES

			default:
				break;
		}
	}
}
Example #13
0
// -----------------------------------------------------------------------------
// Debug menu handling
bool onEvent(const SEvent &event)
{
    // Only activated in artist debug mode
    if(!UserConfigParams::m_artist_debug_mode)
        return true;    // keep handling the events

    if(event.EventType == EET_MOUSE_INPUT_EVENT)
    {
        // Create the menu (only one menu at a time)
        if(event.MouseInput.Event == EMIE_RMOUSE_PRESSED_DOWN && !g_debug_menu_visible)
        {
            // root menu
            gui::IGUIEnvironment* guienv = irr_driver->getGUI();
            IGUIContextMenu* mnu = guienv->addContextMenu(
                core::rect<s32>(event.MouseInput.X, event.MouseInput.Y, event.MouseInput.Y+100, event.MouseInput.Y+100),NULL);
            int graphicsMenuIndex = mnu->addItem(L"Graphics >",-1,true,true);
            
            // graphics menu
            IGUIContextMenu* sub = mnu->getSubMenu(graphicsMenuIndex);

            sub->addItem(L"Reload shaders", DEBUG_GRAPHICS_RELOAD_SHADERS );
            sub->addItem(L"Reset debug views", DEBUG_GRAPHICS_RESET );
            sub->addItem(L"Wireframe", DEBUG_GRAPHICS_WIREFRAME );
            sub->addItem(L"Mipmap viz", DEBUG_GRAPHICS_MIPMAP_VIZ );
            sub->addItem(L"Normals viz", DEBUG_GRAPHICS_NORMALS_VIZ );
            sub->addItem(L"SSAO viz", DEBUG_GRAPHICS_SSAO_VIZ );
            sub->addItem(L"RSM viz", DEBUG_GRAPHICS_RSM_VIZ);
            sub->addItem(L"RH viz", DEBUG_GRAPHICS_RH_VIZ);
            sub->addItem(L"GI viz", DEBUG_GRAPHICS_GI_VIZ);
            sub->addItem(L"Shadow viz", DEBUG_GRAPHICS_SHADOW_VIZ );
            sub->addItem(L"Light viz", DEBUG_GRAPHICS_LIGHT_VIZ );
            sub->addItem(L"Distort viz", DEBUG_GRAPHICS_DISTORT_VIZ );
            sub->addItem(L"Physics debug", DEBUG_GRAPHICS_BULLET_1);
            sub->addItem(L"Physics debug (no kart)", DEBUG_GRAPHICS_BULLET_2);

            mnu->addItem(L"Items >",-1,true,true);
            sub = mnu->getSubMenu(1);
            sub->addItem(L"Basketball", DEBUG_POWERUP_RUBBERBALL );
            sub->addItem(L"Bowling", DEBUG_POWERUP_BOWLING );
            sub->addItem(L"Bubblegum", DEBUG_POWERUP_BUBBLEGUM );
            sub->addItem(L"Cake", DEBUG_POWERUP_CAKE );
            sub->addItem(L"Parachute", DEBUG_POWERUP_PARACHUTE );
            sub->addItem(L"Plunger", DEBUG_POWERUP_PLUNGER );
            sub->addItem(L"Swatter", DEBUG_POWERUP_SWATTER );
            sub->addItem(L"Switch", DEBUG_POWERUP_SWITCH );
            sub->addItem(L"Zipper", DEBUG_POWERUP_ZIPPER );
            sub->addItem(L"Nitro", DEBUG_POWERUP_NITRO );
            
            mnu->addItem(L"Attachments >",-1,true, true);
            sub = mnu->getSubMenu(2);
            sub->addItem(L"Bomb", DEBUG_ATTACHMENT_BOMB);
            sub->addItem(L"Anvil", DEBUG_ATTACHMENT_ANVIL);
            sub->addItem(L"Parachute", DEBUG_ATTACHMENT_PARACHUTE);

            mnu->addItem(L"Adjust values", DEBUG_VISUAL_VALUES);

            mnu->addItem(L"Profiler",DEBUG_PROFILER);
            if (UserConfigParams::m_profiler_enabled)
                mnu->addItem(L"Toggle capture profiler report", DEBUG_PROFILER_GENERATE_REPORT);
            mnu->addItem(L"Do not limit FPS", DEBUG_THROTTLE_FPS);
            mnu->addItem(L"FPS",DEBUG_FPS);
            mnu->addItem(L"Save replay", DEBUG_SAVE_REPLAY);
            mnu->addItem(L"Save history", DEBUG_SAVE_HISTORY);
            mnu->addItem(L"Toggle GUI", DEBUG_TOGGLE_GUI);
            mnu->addItem(L"Hide karts", DEBUG_HIDE_KARTS);


            g_debug_menu_visible = true;
            irr_driver->showPointer();
        }

        // Let Irrlicht handle the event while the menu is visible - otherwise in a race the GUI events won't be generated
        if(g_debug_menu_visible)
            return false;
    }

    if (event.EventType == EET_GUI_EVENT)
    {
        if (event.GUIEvent.Caller != NULL && event.GUIEvent.Caller->getType() == EGUIET_CONTEXT_MENU )
        {
            IGUIContextMenu *menu = (IGUIContextMenu*)event.GUIEvent.Caller;
            s32 cmdID = menu->getItemCommandId(menu->getSelectedItem());

            if(event.GUIEvent.EventType == EGET_ELEMENT_CLOSED)
            {
                g_debug_menu_visible = false;
            }

            if (event.GUIEvent.EventType == gui::EGET_MENU_ITEM_SELECTED)
            {
                if(cmdID == DEBUG_GRAPHICS_RELOAD_SHADERS)
                {
                    Log::info("Debug", "Reloading shaders...");
                    irr_driver->updateShaders();
                }
                else if (cmdID == DEBUG_GRAPHICS_RESET)
                {
                    World* world = World::getWorld();
                    if (world != NULL) world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NONE);

                    irr_driver->resetDebugModes();
                }
                else if (cmdID == DEBUG_GRAPHICS_WIREFRAME)
                {
                    World* world = World::getWorld();
                    if (world != NULL) world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NONE);

                    irr_driver->resetDebugModes();
                    irr_driver->toggleWireframe();
                }
                else if (cmdID == DEBUG_GRAPHICS_MIPMAP_VIZ)
                {
                    World* world = World::getWorld();
                    if (world != NULL) world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NONE);

                    irr_driver->resetDebugModes();
                    irr_driver->toggleMipVisualization();
                }
                else if (cmdID == DEBUG_GRAPHICS_NORMALS_VIZ)
                {
                    World* world = World::getWorld();
                    if (world != NULL) world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NONE);

                    irr_driver->resetDebugModes();
                    irr_driver->toggleNormals();
                }
                else if (cmdID == DEBUG_GRAPHICS_SSAO_VIZ)
                {
                    World* world = World::getWorld();
                    if (world != NULL) world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NONE);

                    irr_driver->resetDebugModes();
                    irr_driver->toggleSSAOViz();
                }
                else if (cmdID == DEBUG_GRAPHICS_RSM_VIZ)
                {
                    World* world = World::getWorld();
                    if (world != NULL) world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NONE);

                    irr_driver->resetDebugModes();
                    irr_driver->toggleRSM();
                }
                else if (cmdID == DEBUG_GRAPHICS_RH_VIZ)
                {
                    World* world = World::getWorld();
                    if (world != NULL) world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NONE);

                    irr_driver->resetDebugModes();
                    irr_driver->toggleRH();
                }
                else if (cmdID == DEBUG_GRAPHICS_GI_VIZ)
                {
                    World* world = World::getWorld();
                    if (world != NULL) world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NONE);

                    irr_driver->resetDebugModes();
                    irr_driver->toggleGI();
                }
                else if (cmdID == DEBUG_GRAPHICS_SHADOW_VIZ)
                {
                    World* world = World::getWorld();
                    if (world != NULL) world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NONE);

                    irr_driver->resetDebugModes();
                    irr_driver->toggleShadowViz();
                }
                else if (cmdID == DEBUG_GRAPHICS_LIGHT_VIZ)
                {
                    World* world = World::getWorld();
                    if (world != NULL) world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NONE);

                    irr_driver->resetDebugModes();
                    irr_driver->toggleLightViz();
                }
                else if (cmdID == DEBUG_GRAPHICS_DISTORT_VIZ)
                {
                    World* world = World::getWorld();
                    if (world != NULL) world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NONE);

                    irr_driver->resetDebugModes();
                    irr_driver->toggleDistortViz();
                }
                else if (cmdID == DEBUG_GRAPHICS_BULLET_1)
                {
                    irr_driver->resetDebugModes();

                    World* world = World::getWorld();
                    if (world == NULL) return false;
                    world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_KARTS_PHYSICS);
                }
                else if (cmdID == DEBUG_GRAPHICS_BULLET_2)
                {
                    irr_driver->resetDebugModes();

                    World* world = World::getWorld();
                    if (world == NULL) return false;
                    world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NO_KARTS_GRAPHICS);
                }
                else if (cmdID == DEBUG_PROFILER)
                {
                    UserConfigParams::m_profiler_enabled =
                                            !UserConfigParams::m_profiler_enabled;
                }
                else if (cmdID == DEBUG_PROFILER_GENERATE_REPORT)
                {
                    profiler.setCaptureReport(!profiler.getCaptureReport());
                }
                else if (cmdID == DEBUG_THROTTLE_FPS)
                {
                    main_loop->setThrottleFPS(false);
                }
                else if (cmdID == DEBUG_FPS)
                {
                    UserConfigParams::m_display_fps =
                                        !UserConfigParams::m_display_fps;
                }
                else if (cmdID == DEBUG_SAVE_REPLAY)
                {
                    ReplayRecorder::get()->Save();
                }
                else if (cmdID == DEBUG_SAVE_HISTORY)
                {
                    history->Save();
                }
                else if (cmdID == DEBUG_POWERUP_BOWLING)
                {
                    addPowerup(PowerupManager::POWERUP_BOWLING);
                }
                else if (cmdID == DEBUG_POWERUP_BUBBLEGUM)
                {
                    addPowerup(PowerupManager::POWERUP_BUBBLEGUM);
                }
                else if (cmdID == DEBUG_POWERUP_CAKE)
                {
                    addPowerup(PowerupManager::POWERUP_CAKE);
                }
                else if (cmdID == DEBUG_POWERUP_PARACHUTE)
                {
                    addPowerup(PowerupManager::POWERUP_PARACHUTE);
                }
                else if (cmdID == DEBUG_POWERUP_PLUNGER)
                {
                    addPowerup(PowerupManager::POWERUP_PLUNGER);
                }
                else if (cmdID == DEBUG_POWERUP_RUBBERBALL)
                {
                    addPowerup(PowerupManager::POWERUP_RUBBERBALL);
                }
                else if (cmdID == DEBUG_POWERUP_SWATTER)
                {
                    addPowerup(PowerupManager::POWERUP_SWATTER);
                }
                else if (cmdID == DEBUG_POWERUP_SWITCH)
                {
                    addPowerup(PowerupManager::POWERUP_SWITCH);
                }
                else if (cmdID == DEBUG_POWERUP_ZIPPER)
                {
                    addPowerup(PowerupManager::POWERUP_ZIPPER);
                }
                else if (cmdID == DEBUG_POWERUP_NITRO)
                {
                    World* world = World::getWorld();
                    if (world == NULL) return false;
                    for(unsigned int i = 0; i < race_manager->getNumLocalPlayers(); i++)
                    {
                        AbstractKart* kart = world->getLocalPlayerKart(i);
                        kart->setEnergy(100.0f);
                    }
                }
                else if (cmdID == DEBUG_ATTACHMENT_ANVIL)
                {
                    addAttachment(Attachment::ATTACH_ANVIL);
                }
                else if (cmdID == DEBUG_ATTACHMENT_BOMB)
                {
                    addAttachment(Attachment::ATTACH_BOMB);
                }
                else if (cmdID == DEBUG_ATTACHMENT_PARACHUTE)
                {
                    addAttachment(Attachment::ATTACH_PARACHUTE);
                }
                else if (cmdID == DEBUG_TOGGLE_GUI)
                {
                    World* world = World::getWorld();
                    if (world == NULL) return false;
                    RaceGUIBase* gui = world->getRaceGUI();
                    if (gui != NULL) gui->m_enabled = !gui->m_enabled;
                }
                else if (cmdID == DEBUG_HIDE_KARTS)
                {
                    World* world = World::getWorld();
                    if (world == NULL) return false;
                    const int count = World::getWorld()->getNumKarts();
                    for (int n = 0; n<count; n++)
                    {
                        AbstractKart* kart = world->getKart(n);
                        if (kart->getController()->isPlayerController())
                            kart->getNode()->setVisible(false);
                    }
                }
                else if (cmdID == DEBUG_VISUAL_VALUES)
                {
#if !defined(__APPLE__)
                    DebugSliderDialog *dsd = new DebugSliderDialog();
                    dsd->setSliderHook( "red_slider", 0, 255, [](){ return irr_driver->getAmbientLight().r * 255.f; },
                        [](int v){
                            video::SColorf ambient = irr_driver->getAmbientLight();
                            ambient.setColorComponentValue(0, v / 255.f);
                            irr_driver->setAmbientLight(ambient); }
                    );
                    dsd->setSliderHook("green_slider", 0, 255, [](){ return irr_driver->getAmbientLight().g * 255.f; },
                        [](int v){
                        video::SColorf ambient = irr_driver->getAmbientLight();
                        ambient.setColorComponentValue(1, v / 255.f);
                        irr_driver->setAmbientLight(ambient); }
                    );
                    dsd->setSliderHook("blue_slider", 0, 255, [](){ return irr_driver->getAmbientLight().b * 255.f; },
                        [](int v){
                        video::SColorf ambient = irr_driver->getAmbientLight();
                        ambient.setColorComponentValue(2, v / 255.f);
                        irr_driver->setAmbientLight(ambient); }
                    );
                    dsd->setSliderHook("ssao_radius", 0, 100, [](){ return irr_driver->getSSAORadius() * 10.f; },
                        [](int v){irr_driver->setSSAORadius(v / 10.f); }
                    );
                    dsd->setSliderHook("ssao_k", 0, 100, [](){ return irr_driver->getSSAOK() * 10.f; },
                        [](int v){irr_driver->setSSAOK(v / 10.f); }
                    );
                    dsd->setSliderHook("ssao_sigma", 0, 100, [](){ return irr_driver->getSSAOSigma() * 10.f; },
                        [](int v){irr_driver->setSSAOSigma(v / 10.f); }
                    );
#endif
                }
            }

            return false;   // event has been handled
        }
    }
    return true;    // continue event handling
}
Example #14
0
void Framebuffer::attachRenderBuffer(const GLenum attachment, Renderbuffer * renderBuffer)
{
    implementation().attachRenderBuffer(this, attachment, renderBuffer);

    addAttachment(new AttachedRenderbuffer(this, attachment, renderBuffer));
}
Example #15
0
void Framebuffer::attachTextureLayer(const GLenum attachment, Texture * texture, const GLint level, const GLint layer)
{
    implementation().attachTextureLayer(this, attachment, texture, level, layer);

    addAttachment(new AttachedTexture(this, attachment, texture, level, layer));
}
void ElogThreadSubmit::doTransmit( ) {
  KURL destination;
  QStringList::iterator it;
  QStringList	strListAttributes;
  QStringList	strListAttribute;
  QString boundary;
  int iAttachment = 0;

  destination.setProtocol("http");
  destination.setHost(_elog->configuration()->ipAddress());
  destination.setPort((short)_elog->configuration()->portNumber());
  destination.setQuery("");
  if (!_strLogbook.isEmpty()) {
    destination.setPath(QString("/%1/").arg(_strLogbook));
  }

  srand((unsigned) time(NULL));
  boundary = QString("---------------------------%1%2%3").arg(rand(), 4, 16).arg(rand(), 4, 16).arg(rand(), 4, 16);

  //
  // add the attributes...
  //
  addAttribute( _dataStreamAll, boundary, "cmd", "Submit", false );
  addAttribute( _dataStreamAll, boundary, "unm", _strUserName, false );
  addAttribute( _dataStreamAll, boundary, "upwd", _strUserPassword, true );
  addAttribute( _dataStreamAll, boundary, "exp", _strLogbook, false );

  strListAttributes = QStringList::split( '\n', _strAttributes, FALSE );
  for ( it = strListAttributes.begin(); it != strListAttributes.end(); ++it ) {
    strListAttribute = QStringList::split( '=', *it, FALSE );
    if( strListAttribute.count() == 2 ) {
      addAttribute( _dataStreamAll, boundary,
                    strListAttribute.first().stripWhiteSpace(),
                    strListAttribute.last().stripWhiteSpace(), false );
    }
  }

  if( _bSubmitAsHTML ) {
    addAttribute( _dataStreamAll, boundary, "html", "1", false );
  }
  if( _bSuppressEmail ) {
    addAttribute( _dataStreamAll, boundary, "suppress", "1", false );
  }

  addAttribute( _dataStreamAll, boundary, "Text", _strMessage, false );
  QString str = QString("%1\r\n").arg(boundary);
  _dataStreamAll.writeRawBytes(str.ascii(), str.length());

  //
  // add the attachments...
  //
  if( _bIncludeCapture ) {
    iAttachment++;
    addAttachment( _dataStreamAll, boundary, _byteArrayCapture, iAttachment, "Capture.png" );
  }
  if( _bIncludeConfiguration ) {
    QByteArray byteArrayConfigure;
    QTextStream textStreamConfigure( byteArrayConfigure, IO_ReadWrite );
    QCustomEvent eventConfigure(KstELOGConfigureEvent);

    eventConfigure.setData( &textStreamConfigure );
    QApplication::sendEvent( (QObject*)_elog->app(), (QEvent*)&eventConfigure );
    iAttachment++;
    addAttachment( _dataStreamAll, boundary, byteArrayConfigure, iAttachment, "Configure.kst" );
  }
  if( _bIncludeDebugInfo ) {
    QByteArray byteArrayDebugInfo;
    QTextStream textStreamDebugInfo( byteArrayDebugInfo, IO_ReadWrite );
    QCustomEvent eventDebugInfo(KstELOGDebugInfoEvent);

    eventDebugInfo.setData( &textStreamDebugInfo );
    QApplication::sendEvent( (QObject*)_elog->app(), (QEvent*)&eventDebugInfo );
    iAttachment++;
    addAttachment( _dataStreamAll, boundary, byteArrayDebugInfo, iAttachment, "DebugInfo.txt" );
  }

  _job = KIO::http_post(destination, _byteArrayAll, false);
  if (_job) {
    _job->addMetaData("content-type", QString("multipart/form-data; boundary=%1").arg(boundary));
    if (!_strWritePassword.isEmpty()) {
      QCString enc = KCodecs::base64Encode(_strWritePassword.ascii());

      _job->addMetaData("cookies", "manual");
      _job->addMetaData("setcookies", QString("Cookie: wpwd=%1").arg(enc.data()));
    }

    QObject::connect(_job, SIGNAL(result(KIO::Job*)), this, SLOT(result(KIO::Job*)));
    QObject::connect(_job, SIGNAL(dataReq(KIO::Job*, QByteArray&)), this, SLOT(dataReq(KIO::Job*, QByteArray&)));
    QObject::connect(_job, SIGNAL(data(KIO::Job*, const QByteArray&)), this, SLOT(data(KIO::Job*, const QByteArray&)));

    KIO::Scheduler::scheduleJob(_job);
  } else {
MessageSender::MessageSender(QWidget *parent, Qt::WindowFlags flags)
    : QWidget(parent, flags),
      accountCombo(0),
      toEdit(0),
      subjectEdit(0),
      textEdit(0),
      sendButton(0),
      removeButton(0),
      addButton(0),
      attachmentsList(0)
{
    QVBoxLayout* vbl = new QVBoxLayout(this);
    vbl->setSpacing(0);
    vbl->setContentsMargins(0,0,0,0);

    QWidget* mainWidget = new QWidget(this);

    QScrollArea* sa = new QScrollArea(this);
    vbl->addWidget(sa);
    sa->setWidget(mainWidget);
    sa->setWidgetResizable(true);

    setWindowTitle(tr("Write Message"));

    accountCombo = new QComboBox;
    connect(accountCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(accountSelected(int)));

    toEdit = new QLineEdit;

    subjectEdit = new QLineEdit;

    QLabel *accountLabel = new QLabel(tr("Account"));
    accountLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);

    QLabel *toLabel = new QLabel(tr("To"));
    toLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);

    QLabel *subjectLabel = new QLabel(tr("Subject"));
    subjectLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);

    QGridLayout *metaDataLayout = new QGridLayout;
    metaDataLayout->setContentsMargins(0, 0, 0, 0);
    metaDataLayout->addWidget(accountLabel, 0, 0);
    metaDataLayout->setAlignment(accountLabel, Qt::AlignRight);
    metaDataLayout->addWidget(toLabel, 1, 0);
    metaDataLayout->setAlignment(toLabel, Qt::AlignRight);
    metaDataLayout->addWidget(subjectLabel, 2, 0);
    metaDataLayout->setAlignment(subjectLabel, Qt::AlignRight);
    metaDataLayout->addWidget(accountCombo, 0, 1);
    metaDataLayout->addWidget(toEdit, 1, 1);
    metaDataLayout->addWidget(subjectEdit, 2, 1);

    removeButton = new QPushButton(tr("Remove"));
    removeButton->setEnabled(false);

    connect(removeButton, SIGNAL(clicked()), this, SLOT(removeAttachment()));

    addButton = new QPushButton(tr("Add"));

    connect(addButton, SIGNAL(clicked()), this, SLOT(addAttachment()));

    QHBoxLayout *buttonLayout = new QHBoxLayout;
    buttonLayout->setContentsMargins(0, 0, 0, 0);
    buttonLayout->addWidget(addButton);
    buttonLayout->addWidget(removeButton);

    attachmentsList = new QListWidget;
    attachmentsList->setSelectionMode(QAbstractItemView::SingleSelection);

    connect(attachmentsList, SIGNAL(currentRowChanged(int)), this, SLOT(attachmentSelected(int)));

    QVBoxLayout *attachmentsLayout = new QVBoxLayout;
    attachmentsLayout->setContentsMargins(0, 0, 0, 0);
    attachmentsLayout->addWidget(attachmentsList);
    attachmentsLayout->addLayout(buttonLayout);

    QGroupBox *attachmentsGroup = new QGroupBox(tr("Attachments"));
    attachmentsGroup->setLayout(attachmentsLayout);
#ifdef Q_WS_MAEMO_5
    // Maemo 5 style doesn't take group box titles into account.
    int spacingHack = QFontMetrics(QFont()).height();
    attachmentsLayout->setContentsMargins(0, spacingHack, 0, 0);
#endif

    textEdit = new QTextEdit;

    sendButton = new QPushButton(tr("Send"));

    connect(sendButton, SIGNAL(clicked()), this, SLOT(send()), Qt::QueuedConnection);

#ifdef USE_TABBED_LAYOUT
    QTabWidget *tabWidget = new QTabWidget;
    tabWidget->addTab(textEdit, tr("Text"));
    tabWidget->addTab(attachmentsGroup, tr("Attachments"));
#endif

    QVBoxLayout *mainLayout = new QVBoxLayout(mainWidget);
    mainLayout->setContentsMargins(0, 0, 0, 0);
    mainLayout->addLayout(metaDataLayout, 0);
#ifdef USE_TABBED_LAYOUT
    mainLayout->addWidget(tabWidget, 0);
#else
    mainLayout->addWidget(textEdit, 2);
    mainLayout->addWidget(attachmentsGroup, 1);
#endif
    mainLayout->addWidget(sendButton, 0);
    mainLayout->setAlignment(sendButton, Qt::AlignRight);

    connect(&service, SIGNAL(stateChanged(QMessageService::State)), this, SLOT(stateChanged(QMessageService::State)));

    QTimer::singleShot(0, this, SLOT(populateAccounts()));
    
    QWidgetList focusableWidgets;
    focusableWidgets << accountCombo
                     << toEdit
                     << subjectEdit
#ifdef USE_TABBED_LAYOUT
                     << tabWidget
#else
                     << textEdit
                     << attachmentsList
#endif
                     << addButton
                     << removeButton
                     << sendButton;

    foreach(QWidget* w, focusableWidgets)
        w->setContextMenuPolicy(Qt::NoContextMenu);

    accountCombo->setFocus();
}
void Manipulator::onCreate(const Manipulator* source)
{
    Inherited::onCreate(source);

    SimpleMaterialUnrecPtr pMat;

//    SimpleMaterial *simpleMat;
    Geometry       *geo;

    setExternalUpdateHandler(NULL);

    // add a name attachment
    NameUnrecPtr nameN = Name::create();
    nameN->editFieldPtr()->setValue("XManipulator");
    addAttachment(nameN);

    // make the axis lines
    NodeUnrecPtr pNode = makeCoordAxis(getLength()[0], 2.0, false);
    setAxisLinesN(pNode);

    // make the red x-axis transform and handle

    pNode = Node::create();
    setTransXNode(pNode);
    OSG::ComponentTransformUnrecPtr transHandleXC = ComponentTransform::create();

    pNode = makeHandleGeo();
    setHandleXNode(pNode);
    pMat = SimpleMaterial::create();
    setMaterialX  (pMat );

    getTransXNode()->setCore (transHandleXC   );
    getTransXNode()->addChild(getHandleXNode());

    transHandleXC->setTranslation(Vec3f(getLength()[0], 0, 0)                   );
    transHandleXC->setRotation   (Quaternion(Vec3f(0, 0, 1), osgDegree2Rad(-90)));

    pMat->setDiffuse(Color3f(1, 0, 0));
    pMat->setLit    (true            );

    geo = dynamic_cast<Geometry *>(getHandleXNode()->getCore());
    geo->setMaterial(pMat);

    //
    // make the green y-axis transform and handle

    pNode = Node::create();
    setTransYNode(pNode);
    OSG::ComponentTransformUnrecPtr transHandleYC = ComponentTransform::create();
    pNode = makeHandleGeo();
    setHandleYNode(pNode);
    pMat = SimpleMaterial::create();
    setMaterialY(pMat);

    getTransYNode()->setCore (transHandleYC   );
    getTransYNode()->addChild(getHandleYNode());

    transHandleYC->setTranslation(Vec3f(0, getLength()[1], 0)                    );
//    transHandleYC->setRotation   ( Quaternion(Vec3f(0, 0, 1), osgDegree2Rad(-90)));

    pMat->setDiffuse(Color3f(0, 1, 0));
    pMat->setLit    (true            );

    geo = dynamic_cast<Geometry *>(getHandleYNode()->getCore());
    geo->setMaterial(pMat);

    //
    // make the blue z-axis transform and handle

    pNode = Node::create();
    setTransZNode(pNode);
    OSG::ComponentTransformUnrecPtr transHandleZC = ComponentTransform::create();
    pNode = makeHandleGeo();
    setHandleZNode(pNode);
    pMat = SimpleMaterial::create();
    setMaterialZ  (pMat);

    getTransZNode()->setCore (transHandleZC   );
    getTransZNode()->addChild(getHandleZNode());

    transHandleZC->setTranslation(Vec3f(0, 0, getLength()[2])                  );
    transHandleZC->setRotation   (Quaternion(Vec3f(1, 0, 0), osgDegree2Rad(90)));

    pMat->setDiffuse(Color3f(0, 0, 1));
    pMat->setLit    (true            );

    geo = dynamic_cast<Geometry *>(getHandleZNode()->getCore());
    geo->setMaterial(pMat);

    //
    // make the yellow pivot transform and handle

    pNode = Node::create();
    setPivotNode(pNode);
    OSG::ComponentTransformUnrecPtr transHandlePivotC = ComponentTransform::create();
    pNode = makeSphere(2, 0.05f);
    setHandlePNode(pNode);
    pMat = SimpleMaterial::create();
    setMaterialPivot  (pMat);

    getPivotNode()->setCore (transHandlePivotC   );
    getPivotNode()->addChild(getHandlePNode());

    transHandlePivotC->setTranslation(Vec3f(0, 0, 0));

    pMat->setDiffuse(Color3f(1, 1, 0));
    pMat->setLit    (true            );

    geo = dynamic_cast<Geometry *>(getHandlePNode()->getCore());
    geo->setMaterial(pMat);

    if (!getEnablePivot())
    {
        getPivotNode()->setTravMask(0x0);
    }

    commitChanges();
}
Example #19
0
// static
void attachmentHelper::addAttachment(std::shared_ptr<message> msg, std::shared_ptr<message> amsg)
{
	std::shared_ptr<attachment> att =
		vmime::factory<parsedMessageAttachment>::create(amsg);
	addAttachment(msg, att);
}