bool Document::setEdit(Gui::ViewProvider* p, int ModNum) { if (d->_pcInEdit) resetEdit(); // is it really a ViewProvider of this document? if (d->_ViewProviderMap.find(dynamic_cast<ViewProviderDocumentObject*>(p)->getObject()) == d->_ViewProviderMap.end()) return false; View3DInventor *activeView = dynamic_cast<View3DInventor *>(getActiveView()); // if the currently active view is not te 3d view search for it and activate it if (!activeView) { activeView = dynamic_cast<View3DInventor *>(getViewOfViewProvider(p)); if (activeView) getMainWindow()->setActiveWindow(activeView); } if (activeView && activeView->getViewer()->setEditingViewProvider(p,ModNum)) { d->_pcInEdit = p; Gui::TaskView::TaskDialog* dlg = Gui::Control().activeDialog(); if (dlg) dlg->setDocumentName(this->getDocument()->getName()); if (d->_pcInEdit->isDerivedFrom(ViewProviderDocumentObject::getClassTypeId())) signalInEdit(*(static_cast<ViewProviderDocumentObject*>(d->_pcInEdit))); } else { return false; } return true; }
bool ViewProviderThickness::setEdit(int ModNum) { if (ModNum == ViewProvider::Default ) { Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); TaskThickness* thicknessDlg = qobject_cast<TaskThickness*>(dlg); if (thicknessDlg && thicknessDlg->getObject() != this->getObject()) thicknessDlg = 0; // another pad left open its task panel if (dlg && !thicknessDlg) { if (dlg->canClose()) Gui::Control().closeDialog(); else return false; } // clear the selection (convenience) Gui::Selection().clearSelection(); // start the edit dialog if (thicknessDlg) Gui::Control().showDialog(thicknessDlg); else Gui::Control().showDialog(new TaskThickness(static_cast<Part::Thickness*>(getObject()))); return true; } else { return ViewProviderPart::setEdit(ModNum); } }
void CmdDrawingProjectShape::activated(int iMsg) { Gui::TaskView::TaskDialog* dlg = Gui::Control().activeDialog(); if (!dlg) { dlg = new DrawingGui::TaskProjection(); dlg->setButtonPosition(Gui::TaskView::TaskDialog::South); } Gui::Control().showDialog(dlg); }
void CmdRobotSimulate::activated(int iMsg) { #if 1 const char * SelFilter = "SELECT Robot::RobotObject \n" "SELECT Robot::TrajectoryObject "; Gui::SelectionFilter filter(SelFilter); Robot::RobotObject *pcRobotObject; Robot::TrajectoryObject *pcTrajectoryObject; if (filter.match()) { pcRobotObject = static_cast<Robot::RobotObject*>(filter.Result[0][0].getObject()); pcTrajectoryObject = static_cast<Robot::TrajectoryObject*>(filter.Result[1][0].getObject());; } else { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), QObject::tr("Select one Robot and one Trajectory object.")); return; } if(pcTrajectoryObject->Trajectory.getValue().getSize() < 2){ QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Trajectory not valid"), QObject::tr("You need at least two way points in a trajectory to simulate.")); return; } Gui::TaskView::TaskDialog* dlg = new TaskDlgSimulate(pcRobotObject,pcTrajectoryObject); Gui::Control().showDialog(dlg); #else const char * SelFilter = "SELECT Robot::RobotObject \n" "SELECT Robot::TrajectoryObject "; Gui::SelectionFilter filter(SelFilter); Robot::RobotObject *pcRobotObject; Robot::TrajectoryObject *pcTrajectoryObject; if(filter.match()){ pcRobotObject = dynamic_cast<Robot::RobotObject*>(filter.Result[0][0].getObject()); pcTrajectoryObject = dynamic_cast<Robot::TrajectoryObject*>(filter.Result[1][0].getObject());; }else{ QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), QObject::tr("Select one Robot and one Trajectory object.")); } RobotGui::TrajectorySimulate dlg(pcRobotObject,pcTrajectoryObject,Gui::getMainWindow()); dlg.exec(); #endif }
bool Document::setEdit(Gui::ViewProvider* p, int ModNum) { if (d->_pcInEdit) resetEdit(); View3DInventor *activeView = dynamic_cast<View3DInventor *>(getActiveView()); if (activeView && activeView->getViewer()->setEditingViewProvider(p,ModNum)) { d->_pcInEdit = p; Gui::TaskView::TaskDialog* dlg = Gui::Control().activeDialog(); if (dlg) dlg->setDocumentName(this->getDocument()->getName()); if (d->_pcInEdit->isDerivedFrom(ViewProviderDocumentObject::getClassTypeId())) signalInEdit(*(static_cast<ViewProviderDocumentObject*>(d->_pcInEdit))); } else return false; return true; }