X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_Workshop.cpp;h=0a1b1570ca901a64d408103893edbf3050ec8f3b;hb=e65bf14e2ff3cf853884bf8998fadcece6e3b34c;hp=94dce62bb9a75bbc8db01977526fc1fffaac9d09;hpb=3e6b2df389653eb72de9e0639b87fc4511754611;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 94dce62bb..0a1b1570c 100755 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -50,6 +50,7 @@ #include #include #include +#include #ifndef HAVE_SALOME #include @@ -174,6 +175,7 @@ XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector) myModule(NULL), mySalomeConnector(theConnector), myPropertyPanel(0), + myInspectionPanel(0), myFacesPanel(0), myObjectBrowser(0), myDisplayer(0) @@ -527,6 +529,21 @@ void XGUI_Workshop::onAcceptActionClicked() } } +//****************************************************** +void XGUI_Workshop::onAcceptPlusActionClicked() +{ + QAction* anAction = dynamic_cast(sender()); + XGUI_OperationMgr* anOperationMgr = operationMgr(); + if (anOperationMgr) { + ModuleBase_OperationFeature* aFOperation = dynamic_cast + (anOperationMgr->currentOperation()); + if (aFOperation) { + if (myOperationMgr->commitOperation()) + module()->launchOperation(aFOperation->id(), false); + } + } +} + //****************************************************** void XGUI_Workshop::onPreviewActionClicked() { @@ -595,13 +612,15 @@ void XGUI_Workshop::fillPropertyPanel(ModuleBase_Operation* theOperation) FeaturePtr aFeature = aFOperation->feature(); std::string aFeatureKind = aFeature->getKind(); foreach (ModuleBase_ModelWidget* aWidget, aWidgets) { - if (!aWidget->attributeID().empty() && !aFeature->attribute(aWidget->attributeID()).get()) { - std::string anErrorMsg = "The feature '%1' has no attribute '%2' used by widget '%3'."; - Events_InfoMessage("XGUI_Workshop", anErrorMsg) - .arg(aFeatureKind).arg(aWidget->attributeID()) - .arg(aWidget->metaObject()->className()).send(); - myPropertyPanel->cleanContent(); - return; + if (aWidget->usesAttribute()) { + if (!aWidget->attributeID().empty() && !aFeature->attribute(aWidget->attributeID()).get()) { + std::string anErrorMsg = "The feature '%1' has no attribute '%2' used by widget '%3'."; + Events_InfoMessage("XGUI_Workshop", anErrorMsg) + .arg(aFeatureKind).arg(aWidget->attributeID()) + .arg(aWidget->metaObject()->className()).send(); + myPropertyPanel->cleanContent(); + return; + } } } // for performance purpose, flush should be done after all controls are filled @@ -1018,12 +1037,14 @@ bool XGUI_Workshop::onSaveAs() void XGUI_Workshop::onUndo(int theTimes) { processUndoRedo(ActionUndo, theTimes); + myObjectBrowser->updateAllIndexes(1); } //****************************************************** void XGUI_Workshop::onRedo(int theTimes) { processUndoRedo(ActionRedo, theTimes); + myObjectBrowser->updateAllIndexes(1); } //****************************************************** @@ -1050,7 +1071,10 @@ void XGUI_Workshop::processUndoRedo(const ModuleBase_ActionType theActionType, i if (aOpMgr->canStopOperation(aOpMgr->currentOperation())) aOpMgr->abortOperation(aOpMgr->currentOperation()); else + { + myDisplayer->enableUpdateViewer(isUpdateEnabled); return; + } } objectBrowser()->treeView()->setCurrentIndex(QModelIndex()); std::list anActionList = theActionType == ActionUndo ? aMgr->undoList() @@ -1070,10 +1094,10 @@ void XGUI_Workshop::processUndoRedo(const ModuleBase_ActionType theActionType, i updateCommandStatus(); // unblock the viewer update functionality and make update on purpose - if (theActionType == ActionRedo) { - myDisplayer->enableUpdateViewer(isUpdateEnabled); - myDisplayer->updateViewer(); - } + myDisplayer->enableUpdateViewer(isUpdateEnabled); + myDisplayer->updateViewer(); + // Clear messages in status bar from previous operations if exists + setStatusBarMessage(""); } //****************************************************** @@ -1321,6 +1345,11 @@ void XGUI_Workshop::createDockWidgets() Qt::BottomDockWidgetArea); connect(myFacesPanel, SIGNAL(closed()), myFacesPanel, SLOT(onClosed())); + myInspectionPanel = new XGUI_InspectionPanel(aDesktop, mySelector); + myInspectionPanel->setAllowedAreas(Qt::LeftDockWidgetArea | + Qt::RightDockWidgetArea); + aDesktop->addDockWidget(Qt::RightDockWidgetArea, myInspectionPanel); + aDesktop->addDockWidget( #ifdef HAVE_SALOME Qt::RightDockWidgetArea, @@ -1357,6 +1386,9 @@ void XGUI_Workshop::createDockWidgets() QAction* aOkAct = myActionsMgr->operationStateAction(XGUI_ActionsMgr::Accept); connect(aOkAct, SIGNAL(triggered()), this, SLOT(onAcceptActionClicked())); + QAction* aOkContAct = myActionsMgr->operationStateAction(XGUI_ActionsMgr::AcceptPlus); + connect(aOkContAct, SIGNAL(triggered()), this, SLOT(onAcceptPlusActionClicked())); + QAction* aCancelAct = myActionsMgr->operationStateAction(XGUI_ActionsMgr::Abort); connect(aCancelAct, SIGNAL(triggered()), myOperationMgr, SLOT(onAbortOperation())); @@ -1634,7 +1666,7 @@ bool XGUI_Workshop::prepareForDisplay(const std::set& theObjects) con int anAnswer = QMessageBox::question( desktop(), tr("Show object"), tr("'%1'\n are hidden by %2:\nRemove objects from the panel to be displayed?") - .arg(aHiddenObjectNames.join(',')).arg(facesPanel()->windowTitle()), + .arg(aHiddenObjectNames.join(", ")).arg(facesPanel()->windowTitle()), QMessageBox::Yes | QMessageBox::No, QMessageBox::No); bool aToBeDisplayed = anAnswer == QMessageBox::Yes; @@ -1900,7 +1932,6 @@ void XGUI_Workshop::moveObjects() //************************************************************** bool XGUI_Workshop::deleteFeatures(const QObjectPtrList& theObjects) { - std::map > aReferences; std::set aFeatures; ModuleBase_Tools::convertToFeatures(theObjects, aFeatures); @@ -2004,6 +2035,17 @@ bool XGUI_Workshop::canMoveFeature() QObjectPtrList::const_iterator anIt = aObjects.begin(), aLast = aObjects.end(); for (; anIt != aLast && aCanMove; anIt++) { ObjectPtr aObject = *anIt; + if (!aObject.get() || !aObject->data().get() || !aObject->data()->isValid()) { + aCanMove = false; + break; + } + FeaturePtr aFeat = std::dynamic_pointer_cast(aObject); + // only groups can be moved to the end for now (#2451) + if (aFeat.get() && aFeat->getKind() != "Group") { + aCanMove = false; + break; + } + // 1. Get features placed between selected and current in the document std::list aFeaturesBetween = toCurrentFeatures(aObject); // if aFeaturesBetween is empty it means wrong order or aObject is the current feature @@ -2568,6 +2610,7 @@ void XGUI_Workshop::highlightResults(const QObjectPtrList& theObjects) { FeaturePtr aFeature; QObjectPtrList aSelList = theObjects; + QObjectPtrList aNewSel; bool aHasHidden = false; foreach(ObjectPtr aObj, theObjects) { aFeature = std::dynamic_pointer_cast(aObj); @@ -2578,6 +2621,7 @@ void XGUI_Workshop::highlightResults(const QObjectPtrList& theObjects) for(aIt = aResults.cbegin(); aIt != aResults.cend(); aIt++) { aHasHidden |= (*aIt)->isConcealed(); aSelList.append(*aIt); + aNewSel.append(*aIt); } } } @@ -2586,6 +2630,7 @@ void XGUI_Workshop::highlightResults(const QObjectPtrList& theObjects) bool aBlocked = objectBrowser()->blockSignals(true); objectBrowser()->setObjectsSelected(aSelList); objectBrowser()->blockSignals(aBlocked); + objectBrowser()->ensureVisible(aNewSel.first()); } if (aHasHidden) QMessageBox::information(desktop(), tr("Find results"), @@ -2597,6 +2642,7 @@ void XGUI_Workshop::highlightFeature(const QObjectPtrList& theObjects) { ResultPtr aResult; QObjectPtrList aSelList = theObjects; + QObjectPtrList aNewSel; FeaturePtr aFeature; foreach(ObjectPtr aObj, theObjects) { aResult = std::dynamic_pointer_cast(aObj); @@ -2604,6 +2650,7 @@ void XGUI_Workshop::highlightFeature(const QObjectPtrList& theObjects) aFeature = ModelAPI_Feature::feature(aResult); if (aFeature.get()) { aSelList.append(aFeature); + aNewSel.append(aFeature); } } } @@ -2612,6 +2659,7 @@ void XGUI_Workshop::highlightFeature(const QObjectPtrList& theObjects) bool aBlocked = objectBrowser()->blockSignals(true); objectBrowser()->setObjectsSelected(aSelList); objectBrowser()->blockSignals(aBlocked); + objectBrowser()->ensureVisible(aNewSel.first()); } } @@ -2632,6 +2680,8 @@ void XGUI_Workshop::insertFeatureFolder() aMgr->startOperation(aDescription.toStdString()); aDoc->addFolder(aFeature); aMgr->finishOperation(); + + updateCommandStatus(); } @@ -2652,9 +2702,15 @@ void XGUI_Workshop::insertToFolder(bool isBefore) QString aDescription = contextMenuMgr()->action( isBefore ? "ADD_TO_FOLDER_BEFORE_CMD" : "ADD_TO_FOLDER_AFTER_CMD")->text(); + QMap aStates = myObjectBrowser->getFoldersState(aDoc); + aMgr->startOperation(aDescription.toStdString()); aDoc->moveToFolder(aFeatures, aFolder); aMgr->finishOperation(); + + myObjectBrowser->setFoldersState(aStates); + + updateCommandStatus(); } void XGUI_Workshop::moveOutFolder(bool isBefore) @@ -2666,11 +2722,16 @@ void XGUI_Workshop::moveOutFolder(bool isBefore) SessionPtr aMgr = ModelAPI_Session::get(); DocumentPtr aDoc = aMgr->activeDocument(); - QString aDescription = contextMenuMgr()->action( isBefore ? "ADD_OUT_FOLDER_BEFORE_CMD" : "ADD_OUT_FOLDER_AFTER_CMD")->text(); + QMap aStates = myObjectBrowser->getFoldersState(aDoc); + aMgr->startOperation(aDescription.toStdString()); aDoc->removeFromFolder(aFeatures, isBefore); aMgr->finishOperation(); + + myObjectBrowser->setFoldersState(aStates); + + updateCommandStatus(); }