X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_Workshop.cpp;h=60fe451c633c6b168decae34a3bbc01adfe89891;hb=5544702339b340e6e612420ecbab44a033828d87;hp=52212d11bff20202126610c9e6f0ffc706be39e7;hpb=c3ae28ba30027cc4a6a757ef623f40adaae96ead;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 52212d11b..60fe451c6 100755 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -104,6 +104,9 @@ #include #endif + +QString XGUI_Workshop::MOVE_TO_END_COMMAND = QObject::tr("Move to the end"); + //#define DEBUG_DELETE XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector) @@ -129,7 +132,7 @@ XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector) myDisplayer = new XGUI_Displayer(this); mySelector = new XGUI_SelectionMgr(this); - //connect(mySelector, SIGNAL(selectionChanged()), this, SLOT(updateModuleCommands())); + connect(mySelector, SIGNAL(selectionChanged()), this, SLOT(updateCommandStatus())); myOperationMgr = new XGUI_OperationMgr(this, 0); myActionsMgr = new XGUI_ActionsMgr(this); @@ -160,11 +163,10 @@ XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector) SLOT(onOperationCommitted(ModuleBase_Operation*))); connect(myOperationMgr, SIGNAL(operationAborted(ModuleBase_Operation*)), SLOT(onOperationAborted(ModuleBase_Operation*))); - //connect(myOperationMgr, SIGNAL(validationStateChanged(bool)), - // myErrorMgr, SLOT(onValidationStateChanged())); #ifndef HAVE_SALOME connect(myMainWindow, SIGNAL(exitKeySequence()), SLOT(onExit())); + onTrihedronVisibilityChanged(true); #endif connect(this, SIGNAL(errorOccurred(const QString&)), myErrorDlg, SLOT(addError(const QString&))); @@ -215,6 +217,10 @@ void XGUI_Workshop::startApplication() onNew(); + myViewerProxy->connectViewProxy(); + connect(myViewerProxy, SIGNAL(trihedronVisibilityChanged(bool)), + SLOT(onTrihedronVisibilityChanged(bool))); + emit applicationStarted(); } @@ -227,7 +233,7 @@ void XGUI_Workshop::activateModule() connect(myDisplayer, SIGNAL(beforeObjectErase(ObjectPtr, AISObjectPtr)), myModule, SLOT(onBeforeObjectErase(ObjectPtr, AISObjectPtr))); - myActionsMgr->update(); + updateCommandStatus(); // activate visualized objects in the viewer XGUI_Displayer* aDisplayer = displayer(); @@ -280,13 +286,13 @@ void XGUI_Workshop::initMenu() addHistoryMenu(aAction, SIGNAL(updateRedoHistory(const QList&)), SLOT(onRedo(int))); salomeConnector()->addDesktopMenuSeparator("MEN_DESK_EDIT"); - aAction = salomeConnector()->addDesktopCommand("REBUILD_CMD", tr("Rebuild"), tr("Rebuild data objects"), - QIcon(":pictures/rebuild.png"), QKeySequence(), - false, "MEN_DESK_EDIT"); - salomeConnector()->addActionInToolbar( aAction, aToolBarTitle ); + //aAction = salomeConnector()->addDesktopCommand("REBUILD_CMD", tr("Rebuild"), tr("Rebuild data objects"), + // QIcon(":pictures/rebuild.png"), QKeySequence(), + // false, "MEN_DESK_EDIT"); + //salomeConnector()->addActionInToolbar( aAction, aToolBarTitle ); - connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onRebuild())); - salomeConnector()->addDesktopMenuSeparator("MEN_DESK_EDIT"); + //connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onRebuild())); + //salomeConnector()->addDesktopMenuSeparator("MEN_DESK_EDIT"); aAction = salomeConnector()->addDesktopCommand("SAVEAS_CMD", tr("Export NewGeom..."), tr("Export the current document into a NewGeom file"), QIcon(), QKeySequence(), @@ -310,6 +316,10 @@ void XGUI_Workshop::initMenu() aCommand->connectTo(this, SLOT(onSave())); //aCommand->disable(); + aCommand = aGroup->addFeature("SAVEAS_CMD", tr("Save as..."), tr("Save the document into a file"), + QIcon(":pictures/save.png"), QKeySequence()); + aCommand->connectTo(this, SLOT(onSaveAs())); + QString aUndoId = "UNDO_CMD"; aCommand = aGroup->addFeature(aUndoId, tr("Undo"), tr("Undo last command"), QIcon(":pictures/undo.png"), QKeySequence::Undo); @@ -328,13 +338,10 @@ void XGUI_Workshop::initMenu() SIGNAL(updateRedoHistory(const QList&)), SLOT(onRedo(int))); - aCommand = aGroup->addFeature("REBUILD_CMD", tr("Rebuild"), tr("Rebuild data objects"), - QIcon(":pictures/rebuild.png"), QKeySequence()); - aCommand->connectTo(this, SLOT(onRebuild())); + //aCommand = aGroup->addFeature("REBUILD_CMD", tr("Rebuild"), tr("Rebuild data objects"), + // QIcon(":pictures/rebuild.png"), QKeySequence()); + //aCommand->connectTo(this, SLOT(onRebuild())); - aCommand = aGroup->addFeature("SAVEAS_CMD", tr("Save as..."), tr("Save the document into a file"), - QIcon(":pictures/save.png"), QKeySequence()); - aCommand->connectTo(this, SLOT(onSaveAs())); //aCommand->disable(); aCommand = aGroup->addFeature("OPEN_CMD", tr("Open..."), tr("Open a new document"), @@ -386,27 +393,12 @@ void XGUI_Workshop::onAcceptActionClicked() ModuleBase_OperationFeature* aFOperation = dynamic_cast (anOperationMgr->currentOperation()); if (aFOperation) { - if (errorMgr()->canProcessClick(anAction, aFOperation->feature())) - myOperationMgr->onCommitOperation(); + //if (errorMgr()->canProcessClick(anAction, aFOperation->feature())) + myOperationMgr->onCommitOperation(); } } } -//****************************************************** -/*void XGUI_Workshop::onValidationStateChanged(bool theEnabled) -{ - XGUI_OperationMgr* anOperationMgr = operationMgr(); - if (anOperationMgr) { - ModuleBase_OperationFeature* aFOperation = dynamic_cast - (anOperationMgr->currentOperation()); - if (aFOperation) { - QAction* anAction = myActionsMgr->operationStateAction(XGUI_ActionsMgr::Accept); - myErrorMgr->updateActionState(anAction, aFOperation->feature(), theEnabled); - } - } -}*/ - - //****************************************************** void XGUI_Workshop::deactivateActiveObject(const ObjectPtr& theObject, const bool theUpdateViewer) { @@ -486,6 +478,7 @@ void XGUI_Workshop::onOperationResumed(ModuleBase_Operation* theOperation) if (theOperation->getDescription()->hasXmlRepresentation()) { //!< No need for property panel setPropertyPanel(theOperation); + connectToPropertyPanel(true); } updateCommandStatus(); @@ -743,6 +736,14 @@ void XGUI_Workshop::onPreferences() } #endif +//****************************************************** +void XGUI_Workshop::onTrihedronVisibilityChanged(bool theState) +{ + XGUI_Displayer* aDisplayer = displayer(); + if (aDisplayer) + aDisplayer->displayTrihedron(theState); +} + //****************************************************** bool XGUI_Workshop::onSave() { @@ -802,14 +803,18 @@ void XGUI_Workshop::onUndo(int theTimes) { objectBrowser()->treeView()->setCurrentIndex(QModelIndex()); SessionPtr aMgr = ModelAPI_Session::get(); + std::list aUndoList = aMgr->undoList(); if (aMgr->isOperation()) { /// this is important for nested operations /// when sketch operation is active, this condition is false and /// the sketch operation is not aborted operationMgr()->onAbortOperation(); } - for (int i = 0; i < theTimes; ++i) { + std::list::const_iterator aIt = aUndoList.cbegin(); + for (int i = 0; (i < theTimes) && (aIt != aUndoList.cend()); ++i, ++aIt) { aMgr->undo(); + if (QString((*aIt).c_str()) == MOVE_TO_END_COMMAND) + myObjectBrowser->rebuildDataTree(); } operationMgr()->updateApplyOfOperations(); @@ -827,14 +832,18 @@ void XGUI_Workshop::onRedo(int theTimes) objectBrowser()->treeView()->setCurrentIndex(QModelIndex()); SessionPtr aMgr = ModelAPI_Session::get(); + std::list aRedoList = aMgr->redoList(); if (aMgr->isOperation()) { /// this is important for nested operations /// when sketch operation is active, this condition is false and /// the sketch operation is not aborted operationMgr()->onAbortOperation(); } - for (int i = 0; i < theTimes; ++i) { + std::list::const_iterator aIt = aRedoList.cbegin(); + for (int i = 0; (i < theTimes) && (aIt != aRedoList.cend()); ++i, ++aIt) { aMgr->redo(); + if (QString((*aIt).c_str()) == MOVE_TO_END_COMMAND) + myObjectBrowser->rebuildDataTree(); } operationMgr()->updateApplyOfOperations(); updateCommandStatus(); @@ -845,21 +854,21 @@ void XGUI_Workshop::onRedo(int theTimes) } //****************************************************** -void XGUI_Workshop::onRebuild() -{ - SessionPtr aMgr = ModelAPI_Session::get(); - bool aWasOperation = aMgr->isOperation(); // keep this value - if (!aWasOperation) { - aMgr->startOperation("Rebuild"); - } - static const Events_ID aRebuildEvent = Events_Loop::loop()->eventByName("Rebuild"); - Events_Loop::loop()->send(std::shared_ptr( - new Events_Message(aRebuildEvent, this))); - if (!aWasOperation) { - aMgr->finishOperation(); - } - updateCommandStatus(); -} +//void XGUI_Workshop::onRebuild() +//{ +// SessionPtr aMgr = ModelAPI_Session::get(); +// bool aWasOperation = aMgr->isOperation(); // keep this value +// if (!aWasOperation) { +// aMgr->startOperation("Rebuild"); +// } +// static const Events_ID aRebuildEvent = Events_Loop::loop()->eventByName("Rebuild"); +// Events_Loop::loop()->send(std::shared_ptr( +// new Events_Message(aRebuildEvent, this))); +// if (!aWasOperation) { +// aMgr->finishOperation(); +// } +// updateCommandStatus(); +//} //****************************************************** void XGUI_Workshop::onWidgetStateChanged(int thePreviousState) @@ -989,7 +998,7 @@ void XGUI_Workshop::updateCommandStatus() aCmd->setEnabled(false); } } - myActionsMgr->update(); + myActionsMgr->updateCommandsStatus(); emit commandStatusUpdated(); } @@ -1044,11 +1053,11 @@ void XGUI_Workshop::createDockWidgets() QAction* aCancelAct = myActionsMgr->operationStateAction(XGUI_ActionsMgr::Abort); connect(aCancelAct, SIGNAL(triggered()), myOperationMgr, SLOT(onAbortOperation())); - connect(myPropertyPanel, SIGNAL(noMoreWidgets()), myModule, SLOT(onNoMoreWidgets())); connect(myPropertyPanel, SIGNAL(keyReleased(QKeyEvent*)), myOperationMgr, SLOT(onKeyReleased(QKeyEvent*))); - //connect(myOperationMgr, SIGNAL(validationStateChanged(bool)), - // this, SLOT(onValidationStateChanged(bool))); + + connect(myPropertyPanel, SIGNAL(enterClicked()), + myOperationMgr, SLOT(onProcessEnter())); } //****************************************************** @@ -1064,8 +1073,8 @@ void XGUI_Workshop::showPropertyPanel() // in order to operation manager could process key events of the panel. // otherwise they are ignored. It happens only if the same(activateWindow) is // not happened by property panel activation(e.g. resume operation of Sketch) - myPropertyPanel->activateWindow(); - myPropertyPanel->setFocus(); + ModuleBase_Tools::activateWindow(myPropertyPanel, "XGUI_Workshop::showPropertyPanel()"); + ModuleBase_Tools::setFocus(myPropertyPanel, "XGUI_Workshop::showPropertyPanel()"); } //****************************************************** @@ -1084,8 +1093,8 @@ void XGUI_Workshop::hidePropertyPanel() // are processed by this console. For example Undo actions. // It is possible that this code is to be moved to NewGeom package QMainWindow* aDesktop = desktop(); - aDesktop->activateWindow(); - aDesktop->setFocus(); + ModuleBase_Tools::activateWindow(aDesktop, "XGUI_Workshop::hidePropertyPanel()"); + ModuleBase_Tools::setFocus(aDesktop, "XGUI_Workshop::showPropertyPanel()"); } //****************************************************** @@ -1122,12 +1131,16 @@ void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked) moveObjects(); else if (theId == "COLOR_CMD") changeColor(aObjects); - else if (theId == "SHOW_CMD") + else if (theId == "SHOW_CMD") { showObjects(aObjects, true); + mySelector->updateSelectionBy(ModuleBase_ISelection::Browser); + } else if (theId == "HIDE_CMD") showObjects(aObjects, false); - else if (theId == "SHOW_ONLY_CMD") + else if (theId == "SHOW_ONLY_CMD") { showOnlyObjects(aObjects); + mySelector->updateSelectionBy(ModuleBase_ISelection::Browser); + } else if (theId == "SHADING_CMD") setDisplayMode(aObjects, XGUI_Displayer::Shading); else if (theId == "WIREFRAME_CMD") @@ -1345,9 +1358,6 @@ bool XGUI_Workshop::deleteFeatures(const QObjectPtrList& theList, if (!anObjectGroups.contains(aGroupName.c_str())) continue; - if (!myModule->canApplyAction(aObj, anActionId)) - continue; - FeaturePtr aFeature = ModelAPI_Feature::feature(aObj); if (aFeature) { /*// TODO: to learn the workshop to delegate the Part object deletion to the PartSet module