QWidget* PathChooserDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const { Q_UNUSED(index) QTreeWidgetItem *item = tree_->currentItem(); if (!item) { return NULL; } path_item_ = item; path_editor_ = new QWidget(parent); QHBoxLayout *hbox = new QHBoxLayout(path_editor_); path_editor_->setLayout(hbox); path_le_ = new QLineEdit(path_editor_); QPushButton *pb = new QPushButton(path_editor_); path_le_->setText(item->text(col_p_pipe_)); pb->setText(QString(tr("Browse..."))); hbox->setContentsMargins(0, 0, 0, 0); hbox->addWidget(path_le_); hbox->addWidget(pb); hbox->setSizeConstraint(QLayout::SetMinimumSize); // Grow the item to match the editor. According to the QAbstractItemDelegate // documenation we're supposed to reimplement sizeHint but this seems to work. QSize size = option.rect.size(); size.setHeight(qMax(option.rect.height(), hbox->sizeHint().height())); item->setData(col_p_pipe_, Qt::SizeHintRole, size); path_le_->selectAll(); path_editor_->setFocusProxy(path_le_); path_editor_->setFocusPolicy(path_le_->focusPolicy()); connect(path_le_, SIGNAL(destroyed()), this, SLOT(stopEditor())); connect(pb, SIGNAL(pressed()), this, SLOT(browse_button_clicked())); return path_editor_; }
vector<vector3df> Editor::startEditor(){ myRecEditor->startEventProcess(); #ifdef EDITOR_VIEW myRecEditorView->startEventProcess(); #endif bool leftPress = false; mouseWheelCurr = 0; double value = 0; CAMPOSX = 0; CAMPOSY = 0; CAMPOSZ = CAM_POS_DEFAULT; while (deviceEditor->run()) { mouseWheelCurr = (int)(myRecEditor->mouseWheel()*1.29); if (currentEksen == EKSEN_X) X = mouseWheelCurr; else X = myRecEditor->mouseX() - EDITOR_HALF_SCREEN_SIZE; if (currentEksen == EKSEN_Y) Y = mouseWheelCurr; else{ Y = (EDITOR_HALF_SCREEN_SIZE - myRecEditor->mouseY()); } if (currentEksen == EKSEN_X) Z = (myRecEditor->mouseX() - EDITOR_HALF_SCREEN_SIZE); else if (currentEksen == EKSEN_Y) Z = EDITOR_HALF_SCREEN_SIZE - myRecEditor->mouseY(); else Z = mouseWheelCurr; driverEditor->beginScene(true, true, SColor(204, 204, 204, 204)); #ifdef EDITOR_VIEW driverEditorView->beginScene(true, true, SColor(204, 204, 204, 204)); #endif cameraCalibration(myRecEditor, editorCam); if (myRecEditor->keyDown(KEY_KEY_W)){ // .... EVENT HANDLERS .... currentEksen = EKSEN_Y; deviceEditor->setWindowCaption(L"Editor Platform X - Z Ekseni "); editorParentNode->setRotation(vector3df(((int)(editorParentNode->getRotation().X + NODE_ROTATION_SPEED)) % ROTATION_LIMIT, 0, 0)); } else if (myRecEditor->keyDown(KEY_KEY_S)){ currentEksen = EKSEN_Z; deviceEditor->setWindowCaption(L"Editor Platform X - Y Ekseni "); editorCam->setPosition(vector3df(0, 0, CAM_POS_DEFAULT + (mouseWheelCurr * CAM_POS_INC))); editorParentNode->setRotation(vector3df(0, 0, 0)); CAMPOSX = 0; CAMPOSY = 0; CAMPOSZ = CAM_POS_DEFAULT; } else if (myRecEditor->keyDown(KEY_KEY_A)){ currentEksen = EKSEN_X; deviceEditor->setWindowCaption(L"Editor Platform Y - Z Ekseni "); editorParentNode->setRotation(vector3df(0, ((int)(editorParentNode->getRotation().Y + NODE_ROTATION_SPEED)) % ROTATION_LIMIT, 0)); } else if (myRecEditor->keyDown(KEY_KEY_D)){ currentEksen = EKSEN_Z; deviceEditor->setWindowCaption(L"Editor Platform X - Y Ekseni "); editorParentNode->setRotation(vector3df(0, 0, ((int)(editorParentNode->getRotation().Z + NODE_ROTATION_SPEED)) % ROTATION_LIMIT)); } else if (myRecEditor->keyDown(KEY_KEY_P)) { stopEditor(); } if (myRecEditor->leftMousePressed()){ if (!leftPress) vFirst = vLast; // Clear Buffer. drawLine(); leftPress = true; } if (myRecEditor->leftMouseReleased()){ if (leftPress){ vFirst = vLast; // Clear buffer. leftPress = false; } } if (myRecEditor->rightMouseDown()){ drawLine(); } if (myRecEditor->keyDown(KEY_KEY_C)) { positionNodes.clear(); smgrEditor->clear(); editorParentNode = smgrEditor->addEmptySceneNode(); editorParentNode->setVisible(true); editorChildNode = smgrEditor->addSphereSceneNode(); nodeEditorCurrMouse = editorChildNode->clone(); if (nodeEditorCurrMouse && editorChildNode){ editorParentNode->setVisible(true); editorChildNode->setMaterialFlag(EMF_LIGHTING, false); editorChildNode->setScale(editorChildNode->getScale()*0.60f); #if defined(_WIN32) || defined(_WIN64) editorChildNode->setMaterialTexture(0, driverEditor->getTexture("media/blueTexture.png")); #else editorChildNode->setMaterialTexture(0, driverEditor->getTexture("../media/blueTexture.png")); #endif editorChildNode->setVisible(false); nodeEditorCurrMouse->setMaterialFlag(EMF_LIGHTING, false); #if defined(_WIN32) || defined(_WIN64) nodeEditorCurrMouse->setMaterialTexture(0, driverEditor->getTexture("media/redTexture.png")); #else nodeEditorCurrMouse->setMaterialTexture(0, driverEditor->getTexture("../media/redTexture.png")); #endif nodeEditorCurrMouse->setVisible(true); nodeEditorCurrMouse->setScale(nodeEditorCurrMouse->getScale()*1.3f); } // add camera editorCam = smgrEditor->addCameraSceneNode(0, vector3df(0, 0, CAM_POS_DEFAULT), vector3df(0, 0, -CAM_POS_DEFAULT)); X = 0; Y = 0; Z = 0; // camera View .. currentEksen = EKSEN_Z; editorParentNode->addChild(nodeEditorCurrMouse); deviceEditor->getCursorControl()->setVisible(false); // Unvisible mouse cursor mouseWheelBefore = 0; // mouse depth value set 0. smgrEditor->setActiveCamera(editorCam); } drawEditorFrame(driverEditor); driverEditor->draw3DLine(vector3df(-EDITOR_SCREEN_WIDTH, 0, 0), vector3df(EDITOR_SCREEN_WIDTH, 0, 0), SColor(255, 0, 255, 0)); driverEditor->draw3DLine(vector3df(0, -EDITOR_SCREEN_WIDTH, 0), vector3df(0, EDITOR_SCREEN_WIDTH, 0), SColor(255, 255, 0, 0)); driverEditor->draw3DLine(vector3df(0, 0, -EDITOR_SCREEN_WIDTH), vector3df(0, 0, EDITOR_SCREEN_WIDTH), SColor(0, 0, 0, 0)); /* Current node will be painted on editor */ nodeEditorCurrMouse->setPosition(vector3df(X, Y, Z)); #ifdef EDITOR_VIEW nodeEditorViewCurrMouse->setPosition(vector3df(X, Y, Z)); handleCameraDevice2(myRecEditorView, editorViewCam, eBoxEditorView, editorViewParentNode); #endif snprintf(stringEditorHelper, 100, "X: %d Y: %d Z: %d ", X, Y, Z); mbstowcs(stringEditor, stringEditorHelper, (size_t)100); eBoxEditor->setText(stringEditor); guienvEditor->drawAll(); smgrEditor->drawAll(); driverEditor->endScene(); #ifdef EDITOR_VIEW smgrEditorView->drawAll(); guienvEditorView->drawAll(); driverEditorView->endScene(); #endif } return positionNodes; }