void Config::configDownloaded(QDomDocument &rpc, size_t) { printf("Configuration downloaded\n"); // FIXME: This leaks model = new ConfigModel(rpc); configView->setModel(model); openModel(); on_configView_clicked(); }
void Config::openModel(const QModelIndex &index) { for (int i = 0; i < model->rowCount(index); i ++) { const QModelIndex child(model->index(i, 0, index)); configView->setExpanded(child, true); if (model->hasChildren(child)) openModel(child); } }
void MainWindow::createActions() { // file menu actions openModelAct = new QAction(QIcon("../images/open.png"), tr("&Open Model"), this); openModelAct->setShortcut(QKeySequence::New); openModelAct->setStatusTip(tr("open a mesh model")); connect(openModelAct, SIGNAL(triggered()), this, SLOT(openModel())); openTextureFileAct = new QAction(QIcon("../images/open.png"), tr("&Open Texture Image"), this); connect(openTextureFileAct, SIGNAL(triggered()), this, SLOT(openTextureImage())); openQuadFileAct = new QAction(QIcon("../images/open.png"), tr("&Open Quad File"), this); connect(openQuadFileAct, SIGNAL(triggered()), this, SLOT(openQuadFile())); saveModelAct = new QAction(QIcon("../images/save.png"), tr("&Save Model"), this); saveModelAct->setShortcut(QKeySequence::Save); saveModelAct->setStatusTip(tr("save this mesh model")); connect(saveModelAct, SIGNAL(triggered()), this, SLOT(saveModel())); saveAsBmpAct = new QAction(tr("Save as BMP"), this); connect(saveAsBmpAct, SIGNAL(triggered()), this, SLOT(saveAsBmp())); recentFileAct = new QAction(tr("Recent Files"), this); connect(recentFileAct, SIGNAL(triggered()), this, SLOT(recentFiles())); exitAct = new QAction(tr("E&xit"), this); exitAct->setShortcuts(QKeySequence::Quit); exitAct->setStatusTip(tr("Exit the application")); connect(exitAct, SIGNAL(triggered()), this, SLOT(close())); // toolbar menu actions toolBarAct = new QAction(tr("ToolBar"), this); connect(toolBarAct, SIGNAL(triggered()), this, SLOT(toobBar())); stateBarAct = new QAction(tr("StateBar"), this); connect(stateBarAct, SIGNAL(triggered()), this, SLOT(stateBar())); // quad menu actions // help menu actions aboutAct = new QAction(tr("About"), this); connect(aboutAct, SIGNAL(triggered()), this, SLOT(about())); // mouse actions mouseSpinAct = new QAction(QIcon("../images/rotate-left.png"), tr("Spin"), this); connect(mouseSpinAct, SIGNAL(triggered()), this, SLOT(mouseSpin())); mouseMoveAct = new QAction(QIcon("../images/move.png"), tr("Move"), this); connect(mouseMoveAct, SIGNAL(triggered()), this, SLOT(mouseMove())); mouseZoomAct = new QAction(QIcon("../images/zoom.png"), tr("Zoom"), this); connect(mouseZoomAct, SIGNAL(triggered()), this, SLOT(mouseZoom())); }
void MainWindow::on_revertAction_triggered() { if (config_.projectDir.isEmpty() || config_.origConfigFileName.isEmpty()) { return; } openModel(); }
QWidget *InternalArticleDelegat::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const { InternalArticleWidget *editor = new InternalArticleWidget(parent); editor->setModel(_sqlModel,1,0); editor->setStorage(_storage); editor->setContractor(_contractor); connect(editor,SIGNAL(insertedArticle()),SLOT(openModel())); return editor; }
void MainWindow::on_openAction_triggered() { QString dir = config_.projectDir; if (dir.isNull()) { dir = QDir::currentPath(); } QString filePath = QFileDialog::getOpenFileName(this, tr("Open file"), dir, tr("XML files (*.xml)")); if (filePath.isEmpty()) { return; } QFileInfo fileInfo(filePath); config_.projectDir = fileInfo.absolutePath() + '/'; config_.origConfigFileName = fileInfo.fileName(); config_.newConfigFileName = QString(); openModel(); }
bool milxQtFile::openModelCollection(vtkPolyDataCollection* collection, QStringList &filenames) { bool success = true; QPointer<QFileDialog> fileOpener = new QFileDialog; QSettings settings("Shekhar Chandra", "milxQt"); ///If filenames list is empty ask for them if(filenames.isEmpty()) { QString path = settings.value("recentPath").toString(); filenames = fileOpener->getOpenFileNames(NULL, tr("Select File(s) to Open"), path, tr(openModelExts.c_str())); } if(filenames.size() == 0) return !success; QFileInfo fi(filenames[0]); settings.setValue("recentPath", fi.absolutePath()); //!< Remember path if successful. for(int j = 0; j < filenames.size(); j ++) { vtkSmartPointer<vtkPolyData> data = vtkSmartPointer<vtkPolyData>::New(); success = openModel(filenames[j], data); ///Open supported model file if(!success) { cerr << "Encountered Error in Reading model. Aborting Collection Read." << endl; break; } else cout << "Opened " << filenames[j].toStdString() << " into collection." << endl; collection->AddItem(data); qApp->processEvents(); } return success; }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); // Menu QMenu* modelMenu = menuBar()->addMenu("&Model"); modelMenu->addAction("&Open model...", this, SLOT(openModel()) ); modelMenu->addSeparator(); modelMenu->addAction("&Close model", this, SLOT(closeModel()) ); QMenu* markMenu = menuBar()->addMenu("&Bookmarks"); markMenu->addAction("&New file...", this, SLOT(closeBookmarksFile()) ); markMenu->addAction("&Open file...", this, SLOT(openBookmarksFile()) ); markMenu->addSeparator(); markMenu->addAction("&Close file", this, SLOT(closeBookmarksFile()) ); markMenu->addSeparator(); markMenu->addAction("&Save file", this, SLOT(saveBookmarksFile())); markMenu->addAction("&Save file as...", this, SLOT(saveAsBookmarksFile())); QMenu* viewMenu = menuBar()->addMenu("&View"); viewMenu->addAction("&View as points", this, SLOT(viewAsPoints()) ); viewMenu->addAction("&View as wired", this, SLOT(viewAsWired()) ); viewMenu->addAction("&View as solid", this, SLOT(viewAsSolid()) ); viewMenu->addAction("&View as solid + wired",this, SLOT(viewAsSolidWire()) ); QMenu* modeMenu = menuBar()->addMenu("&Mode"); modeMenu->addAction("&Viewer", this, SLOT(viewerMode()) ); modeMenu->addAction("&Editor", this, SLOT(editorMode()) ); modeMenu->addAction("&Ask Me!", this, SLOT(testMode()) ); // Section list panel buttons. QObject::connect(ui->addButton, SIGNAL(clicked()), this, SLOT(showAddSectionPanel())); QObject::connect(ui->editButton, SIGNAL(clicked()), this, SLOT(showEditSectionPanel())); QObject::connect(ui->deleteButton, SIGNAL(clicked()), this, SLOT(deleteCurrentSection())); QObject::connect(ui->infoButton, SIGNAL(clicked()), this, SLOT(showInfoSectionPanel())); QObject::connect(ui->listWidget, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(listWidgetItemClicked(QListWidgetItem*))); // Add bookmark panel buttons. QObject::connect(ui->addModeButton, SIGNAL(clicked()), this, SLOT(setAddSelectionMode())); QObject::connect(ui->removeModeButton, SIGNAL(clicked()), this, SLOT(setRemoveSelectionMode())); QObject::connect(ui->saveButton, SIGNAL(clicked()), this, SLOT(saveBookmark())); QObject::connect(ui->discardButton, SIGNAL(clicked()), this, SLOT(discardBookmark())); QObject::connect(ui->brushSizeSlider, SIGNAL(valueChanged(int)), this, SLOT(setBrushSize(int))); // Information panel buttons QObject::connect(ui->backButton, SIGNAL(clicked()), this, SLOT(showListPanel())); // Test panel buttons QObject::connect(ui->nextQuestionButton, SIGNAL(clicked()), this, SLOT(nextQuestion())); QObject::connect(ui->glwidget, SIGNAL(pickResult(std::set<unsigned int>)), this, SLOT(checkResponse(std::set<unsigned int>))); // Set window title. setWindowTitle("untitled.txt"); // Initialize variables. _bookmarkList = new BookmarkList(); clearBookmarkList(); _model = new Model(); _indexTest = 0; // Set viewer mode. viewerMode(); // Show welcome message statusBar()->showMessage("Welcome to 3D Marker."); }
// This function performs the action after the delay is up. It returns // true if the program is still to quit bool ImodClipboard::executeMessage() { int returnValue, arg; int succeeded = 1; static int checkSum = 0; int newCheck; QString convName; QDir *curdir; ZapFuncs *zap; int movieVal, xaxis, yaxis, zaxis, taxis; int objNum, type, symbol, symSize, ptSize, mode, mask, interval; bool props1; Imod *imod; Iobj *obj; int symTable[] = { IOBJ_SYM_NONE, IOBJ_SYM_CIRCLE, IOBJ_SYM_SQUARE, IOBJ_SYM_TRIANGLE }; // Number of arguments required - for backward compatibility, going to // model mode does not require one but should have one int requiredArgs[] = {0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 5, 5, 0, 2, 4, 4, 3, 1, 1}; int numArgs = sMessageStrings.count(); // Loop on the actions in the list; set arg to numArgs to break loop for (arg = 0; arg < numArgs; arg++) { imod = App->cvi->imod; // Get the action, then check that there are enough values for it sMessageAction = sMessageStrings[arg].toInt(); if (sMessageAction >= 0 && sMessageAction < sizeof(requiredArgs) / sizeof(int) && arg + requiredArgs[sMessageAction] >= numArgs) { imodPrintStderr("imodExecuteMessage: not enough values sent" " with action command %d\n", sMessageAction); succeeded = 0; break; } // If still in initial load, skip the arguments (and one more if model mode message) if (sInitialLoad) { if (sMessageAction >= 0 && sMessageAction < sizeof(requiredArgs) / sizeof(int)) arg += requiredArgs[sMessageAction]; if (arg < numArgs - 1 && sMessageAction == MESSAGE_MODEL_MODE) arg++; // Stop processing after a plugin message because the length is unknown // and stop after seeing a quit if (sMessageAction == MESSAGE_PLUGIN_EXECUTE || sMessageAction == MESSAGE_QUIT) arg = numArgs; continue; } if (Imod_debug) { QTime curTime = QTime::currentTime(); wprint("%02d:%02d.%03d: Executing message action %d\n", curTime.minute(), curTime.second(), curTime.msec(), sMessageAction); imodPrintStderr("%02d:%02d.%03d: imodHCM in executeMessage: executing message " "action %d\n", curTime.minute(), curTime.second(), curTime.msec(), sMessageAction); if (imodDebug('C')) { newCheck = imodChecksum(App->cvi->imod); wprint("Checksum before = %d\n", newCheck); if (checkSum && newCheck != checkSum) wprint("\aIT CHANGED SINCE LAST TIME\n"); checkSum = newCheck; } } if (ImodvClosed || !Imodv->standalone) { switch (sMessageAction) { case MESSAGE_OPEN_MODEL: case MESSAGE_OPEN_KEEP_BW: curdir = new QDir(); convName = curdir->cleanPath(sMessageStrings[++arg]); delete curdir; // Since this could open a dialog with an indefinite delay, just send // the OK signal now succeeded = -1; sendResponse(1); inputRaiseWindows(); // DNM 6/3/04: switch to keeping BW values in the first place returnValue = openModel(LATIN1(convName), sMessageAction == MESSAGE_OPEN_KEEP_BW, false); if(returnValue == IMOD_IO_SUCCESS) { wprint("%s loaded.\n", LATIN1(QDir::convertSeparators(QString(Imod_filename)))); } else if(returnValue == IMOD_IO_SAVE_ERROR) { wprint("Error Saving Model. New model not loaded.\n"); arg = numArgs; } else if(returnValue == IMOD_IO_SAVE_CANCEL) { wprint("Operation cancelled. New model not loaded.\n"); arg = numArgs; } // The model does not exist yet. Try creating a new model. else if(returnValue == IMOD_IO_DOES_NOT_EXIST) { returnValue = createNewModel(LATIN1(convName)); if(returnValue == IMOD_IO_SUCCESS) { wprint("New model %s created.\n", LATIN1(QDir::convertSeparators(QString(Imod_filename)))); } else { wprint("Could not create a new model %s.\n", LATIN1(sMessageStrings[arg])); arg = numArgs; } } else if(returnValue == IMOD_IO_NO_ACCESS_ERROR) { wprint("Error opening model. Check file permissions\n."); arg = numArgs; } else { wprint("Unknown return code, new model not loaded!!\n"); arg = numArgs; } break; case MESSAGE_SAVE_MODEL: succeeded = -1; sendResponse(1); imod->blacklevel = App->cvi->black; imod->whitelevel = App->cvi->white; returnValue = SaveModel(imod); break; case MESSAGE_VIEW_MODEL: imod_autosave(imod); inputRaiseWindows(); imodv_open(); break; case MESSAGE_QUIT: arg = numArgs; break; case MESSAGE_RAISE_WINDOWS: inputRaiseWindows(); break; case MESSAGE_MODEL_MODE: movieVal = 1; if (arg < numArgs - 1) movieVal = sMessageStrings[++arg].toInt(); if (movieVal > 0) imod_set_mmode(IMOD_MMODEL); else { imod_set_mmode(IMOD_MMOVIE); if (movieVal < 0) { xaxis = (-movieVal) & 1 ? 1 : 0; yaxis = (-movieVal) & 2 ? 1 : 0; zaxis = (-movieVal) & 4 ? 1 : 0; taxis = (-movieVal) & 8 ? 1 : 0; imodMovieXYZT(App->cvi, xaxis, yaxis, zaxis, taxis); } } break; case MESSAGE_OPEN_BEADFIXER: imodPlugOpenByName("Bead Fixer"); break; case MESSAGE_ONE_ZAP_OPEN: inputRaiseWindows(); if (!imodDialogManager.windowCount(ZAP_WINDOW_TYPE) && imodLoopStarted()) imod_zap_open(App->cvi, 0); break; case MESSAGE_RUBBERBAND: zapReportRubberband(); break; case MESSAGE_SLICER_ANGLES: slicerReportAngles(); break; case MESSAGE_OBJ_PROPERTIES: case MESSAGE_NEWOBJ_PROPERTIES: case MESSAGE_OBJ_PROPS_2: case MESSAGE_NEWOBJ_PROPS_2: props1 = sMessageAction == MESSAGE_OBJ_PROPERTIES || sMessageAction == MESSAGE_NEWOBJ_PROPERTIES; objNum = sMessageStrings[++arg].toInt(); type = sMessageStrings[++arg].toInt(); symbol = sMessageStrings[++arg].toInt(); symSize = sMessageStrings[++arg].toInt(); if (props1) ptSize = sMessageStrings[++arg].toInt(); // Object is numbered from 1, so decrement and test for substituting // current object if (--objNum < 0) objNum = imod->cindex.object; if (objNum < 0 || objNum >= imod->objsize) { imodPrintStderr("imodExecuteMessage: illegal object # sent with " "object property command\n"); succeeded = 0; arg = numArgs; break; } obj = &imod->obj[objNum]; // If object has contours, skip for NEWOBJ message if (obj->contsize && (sMessageAction == MESSAGE_NEWOBJ_PROPERTIES || sMessageAction == MESSAGE_NEWOBJ_PROPS_2)) break; if (props1) { // Process the changes if not -1: object type if (type >= 0 && type < 3) { switch (type) { case 0: obj->flags &= ~(IMOD_OBJFLAG_OPEN | IMOD_OBJFLAG_SCAT); break; case 1: obj->flags |= IMOD_OBJFLAG_OPEN; obj->flags &= ~IMOD_OBJFLAG_SCAT; break; case 2: obj->flags |= IMOD_OBJFLAG_SCAT | IMOD_OBJFLAG_OPEN; break; } } // Symbol type and filled if (symbol >= 0) { if ((symbol & 7) < (sizeof(symTable) / sizeof(int))) obj->symbol = symTable[symbol & 7]; utilSetObjFlag(obj, 0, (symbol & 8) != 0, IOBJ_SYMF_FILL); } // Symbol size, 3d point size if (symSize > 0) obj->symsize = symSize; if (ptSize >= 0) obj->pdrawsize = ptSize; } else { // Points per contour if (type >= 0) obj->extra[IOBJ_EX_PNT_LIMIT] = type; // Planar contours if (symbol >= 0) utilSetObjFlag(obj, 0, symbol != 0, IMOD_OBJFLAG_PLANAR); // Sphere on sec only if (symSize >= 0) utilSetObjFlag(obj, 0, symSize != 0, IMOD_OBJFLAG_PNT_ON_SEC); } // The general draw updates object edit window, but need to call // imodv object edit for it to update imodDraw(App->cvi, IMOD_DRAW_MOD); imodvObjedNewView(); // If no contours and only 1 obj, set checksum to avoid save requests if (imod->objsize == 1 && !obj->contsize) { imod->csum = imodChecksum(imod); if (imodDebug('C')) wprint("handleMessage set checksum %d\n", imod->csum); } break; case MESSAGE_GHOST_MODE: mode = sMessageStrings[++arg].toInt(); mask = sMessageStrings[++arg].toInt(); App->cvi->ghostmode = (App->cvi->ghostmode & ~mask) | (mode & mask); interval = sMessageStrings[++arg].toInt(); if (interval >= 0) App->cvi->ghostdist = interval; imodDraw(App->cvi, IMOD_DRAW_MOD); break; case MESSAGE_ZAP_HQ_MODE: mode = sMessageStrings[++arg].toInt() != 0 ? 1 : 0; zap = getTopZapWindow(false); if (zap) { zap->stateToggled(ZAP_TOGGLE_RESOL, mode); zap->mQtWindow->setToggleState(ZAP_TOGGLE_RESOL, mode); } else zapSetNextOpenHQstate(mode); break; case MESSAGE_OPEN_DIALOGS: if (!ImodvClosed) imodvOpenSelectedWindows(LATIN1(sMessageStrings[arg + 1])); ImodInfoWin->openSelectedWindows(LATIN1(sMessageStrings[++arg]), ImodvClosed ? 0 : 1); break; case MESSAGE_PLUGIN_EXECUTE: arg++; if (imodPlugMessage(App->cvi, &sMessageStrings, &arg)) { succeeded = 0; arg = numArgs; break; } break; default: imodPrintStderr("imodExecuteMessage: action %d not recognized\n" , sMessageAction); succeeded = 0; arg = numArgs; } } else { // Messages for 3dmodv switch (sMessageAction) { case MESSAGE_QUIT: arg = numArgs; break; case MESSAGE_RAISE_WINDOWS: imodvInputRaise(); break; case MESSAGE_OPEN_DIALOGS: imodvOpenSelectedWindows(LATIN1(sMessageStrings[++arg])); break; default: imodPrintStderr("imodExecuteMessage: action %d not recognized by" " 3dmodv\n" , sMessageAction); succeeded = 0; arg = numArgs; } } } if (imodDebug('C')) { wprint("Checksum after = %d\n", newCheck); if (newCheck != checkSum) wprint("\aIT CHANGED IN THAT OPERATION\n"); checkSum = newCheck; } // Now set the clipboard with the response as long as we aren't doing deferred if (succeeded >= 0 && mDeferredHandling <= 0) sendResponse(succeeded); // Only do deferred handling once if (mDeferredHandling > 0) mDeferredHandling = 0; return sMessageAction == MESSAGE_QUIT; }
InternalArticleDelegat::InternalArticleDelegat(QObject *parent) : QItemDelegate(parent), _sqlModel(new QSqlQueryModel(this)) { openModel(); }