X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_Workshop.cpp;h=6ae78b95d4bd588ba7199f934272c0fb3a1c06b0;hb=06e7f5859095193fc7f498bd89a7d28009794f53;hp=f95053cbdbb8ae9961f31c07d4303b22433c2432;hpb=118e57882829bc841aa3500a3efd88a5e9308329;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index f95053cbd..6ae78b95d 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2021 CEA/DEN, EDF R&D +// Copyright (C) 2014-2023 CEA, EDF // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -90,6 +90,7 @@ #include #include #include +#include #include #include @@ -158,6 +159,7 @@ #include #ifdef TINSPECTOR +#include #include #include #include @@ -172,6 +174,8 @@ static Handle(VInspector_CallBack) MyVCallBack; #ifdef WIN32 #include +#pragma warning(disable : 4456) // for nested foreach +#pragma warning(disable : 4189) // for declaration of unused variables (MAYBE_UNUSED) #else #include #endif @@ -1158,6 +1162,12 @@ void XGUI_Workshop::onPreferences() } else if (aSection == ModuleBase_Preferences::MENU_SECTION) { myMainWindow->menuObject()->updateFromResources(); } + else if (aSection == ModuleBase_Preferences::GENERAL_SECTION && aPref.second == "create_init_part") { + bool aCreate = ModuleBase_Preferences::resourceMgr()->booleanValue( + ModuleBase_Preferences::GENERAL_SECTION, "create_init_part", true); + Events_MessageBool aCreateMsg(Events_Loop::eventByName(EVENT_CREATE_PART_ON_START), aCreate); + aCreateMsg.send(); + } } std::vector aColor; try { @@ -1311,6 +1321,11 @@ void XGUI_Workshop::processUndoRedo(const ModuleBase_ActionType theActionType, i facesPanel()->reset(true); updateCommandStatus(); + QObjectPtrList aList = myDisplayer->displayedObjects(); + foreach(ObjectPtr aObj, aList) { + module()->customizePresentation(aObj, myDisplayer->getAISObject(aObj)); + } + // unblock the viewer update functionality and make update on purpose myDisplayer->enableUpdateViewer(isUpdateEnabled); myDisplayer->updateViewer(); @@ -1718,11 +1733,14 @@ void XGUI_Workshop::showPanel(QDockWidget* theDockWidget) //****************************************************** void XGUI_Workshop::hidePanel(QDockWidget* theDockWidget) { - if (theDockWidget && theDockWidget == myPropertyPanel) { + if (!theDockWidget) return; + + if (theDockWidget == myPropertyPanel) { QAction* aViewAct = theDockWidget->toggleViewAction(); ///setEnabled(false); } + theDockWidget->hide(); // the property panel is active window of the desktop, when it is @@ -1773,6 +1791,8 @@ void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked) cleanHistory(); else if (theId == "MOVE_CMD" || theId == "MOVE_SPLIT_CMD") moveObjects(theId == "MOVE_SPLIT_CMD"); + else if (theId == "RECOVER_CMD") + recoverFeature(); else if (theId == "COLOR_CMD") changeColor(anObjects); else if (theId == "AUTOCOLOR_CMD") @@ -1810,6 +1830,10 @@ void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked) setDisplayMode(anObjects, XGUI_Displayer::Shading); else if (theId == "WIREFRAME_CMD") setDisplayMode(anObjects, XGUI_Displayer::Wireframe); + else if (theId == "SHOW_EDGES_DIRECTION_CMD") + toggleEdgesDirection(anObjects); + else if (theId == "BRING_TO_FRONT_CMD") + toggleBringToFront(anObjects); else if (theId == "HIDEALL_CMD") { QObjectPtrList aList = myDisplayer->displayedObjects(); foreach (ObjectPtr aObj, aList) { @@ -1856,7 +1880,10 @@ void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked) } #ifdef TINSPECTOR else if (theId == "TINSPECTOR_VIEW") { - Handle(TDocStd_Application) anApplication = ModelAPI_Session::get()->application(); + std::shared_ptr aSession = + std::dynamic_pointer_cast(ModelAPI_Session::get()); + + Handle(TDocStd_Application) anApplication = aSession->application(); if (!anApplication.IsNull()) { if (!MyTCommunicator) @@ -2014,8 +2041,9 @@ void XGUI_Workshop::deleteObjects() bool hasCompositeOwner = false; bool hasResultInHistory = false; bool hasFolder = false; + bool hasGroupsOnly = false; ModuleBase_Tools::checkObjects(anObjects, hasResult, hasFeature, hasParameter, hasCompositeOwner, - hasResultInHistory, hasFolder); + hasResultInHistory, hasFolder, hasGroupsOnly); if (!(hasResult || hasFeature || hasParameter || hasFolder)) return; @@ -2287,6 +2315,15 @@ void XGUI_Workshop::moveObjects(const bool theSplit) myViewerProxy->update(); } +void XGUI_Workshop::recoverFeature() +{ + if (!abortAllOperations()) + return; + + static const QString RECOVER_OP_NAME = "Recover"; + module()->launchOperation(RECOVER_OP_NAME, false); +} + //************************************************************** bool XGUI_Workshop::deleteFeatures(const QObjectPtrList& theObjects) { @@ -2377,6 +2414,7 @@ bool XGUI_Workshop::canMoveFeature() QObjectPtrList anObjects = mySelector->selection()->selectedObjects(); QObjectPtrList aValidatedObjects; + std::set aSelectedFeatures; foreach (ObjectPtr anObject, anObjects) { if (!myModule->canApplyAction(anObject, anActionId)) continue; @@ -2384,6 +2422,8 @@ bool XGUI_Workshop::canMoveFeature() if (anObject->document() != ModelAPI_Session::get()->activeDocument()) continue; aValidatedObjects.append(anObject); + FeaturePtr aFeat = std::dynamic_pointer_cast(anObject); + aSelectedFeatures.insert(aFeat); } if (aValidatedObjects.size() != anObjects.size()) anObjects = aValidatedObjects; @@ -2398,12 +2438,25 @@ bool XGUI_Workshop::canMoveFeature() break; } FeaturePtr aFeat = std::dynamic_pointer_cast(anObject); - // only groups can be moved to the end for now (#2451) - if (aFeat.get() && aFeat->getKind() != "Group") { - aCanMove = false; - break; + // only groups can be moved to the end for now (#2451 old_id, #23105 tuleap id) + // and groups created by other groups (#34401) + if (aFeat.get()) { + std::string aKindOfFeature = aFeat->getKind(); + if (aKindOfFeature != "Group" && + aKindOfFeature != "GroupSubstraction" && + aKindOfFeature != "GroupAddition" && + aKindOfFeature != "GroupIntersection") { + aCanMove = false; + break; + } } + // Check that the feature can be moved due to its dependencies + // i.e. Check that there are no features between the moved one and its destination + // with references to it + // Details on #21340 (old_id #660) + // NOTE: we can ignore dependend features, if they are also moved! + // 1. Get features placed between selected and current in the document std::list aFeaturesBetween = toCurrentFeatures(anObject); // if aFeaturesBetween is empty it means wrong order or anObject is the current feature @@ -2418,12 +2471,21 @@ bool XGUI_Workshop::canMoveFeature() if (aRefFeatures.empty()) continue; else { - // 3. Find any placed features in all reference features + // 3.1. Check, if any reference feature is going to be moved, too. + // If it is, we can ignore its dependency in our subsequent check (3.2) + std::set aNoMoveRefFeatures; + std::set_difference(aRefFeatures.begin(), aRefFeatures.end(), + aSelectedFeatures.begin(), aSelectedFeatures.end(), + std::inserter(aNoMoveRefFeatures, aNoMoveRefFeatures.begin())); + if (aNoMoveRefFeatures.empty()) + continue; + + // 3.2. Find any placed features in all remaining (non-moved) reference features std::set aIntersectionFeatures; - std::set_intersection(aRefFeatures.begin(), aRefFeatures.end(), + std::set_intersection(aNoMoveRefFeatures.begin(), aNoMoveRefFeatures.end(), aPlacedFeatures.begin(), aPlacedFeatures.end(), std::inserter(aIntersectionFeatures, aIntersectionFeatures.begin())); - // 4. Return false if any reference feature is placed before current feature + // 4. Return false if any (non-moved) reference feature is placed before current feature if (!aIntersectionFeatures.empty()) aCanMove = false; } @@ -2873,7 +2935,7 @@ void XGUI_Workshop::showOnlyObjects(const QObjectPtrList& theList) void XGUI_Workshop::updateColorScaleVisibility() { QObjectPtrList anObjects = mySelector->selection()->selectedObjects(); - viewer()->setColorScaleShown(false); + myViewerProxy->setColorScaleShown(false); if (anObjects.size() == 1) { FieldStepPtr aStep = std::dynamic_pointer_cast(anObjects.first()); @@ -2904,6 +2966,55 @@ void XGUI_Workshop::updateColorScaleVisibility() } } +//************************************************************** +void XGUI_Workshop::updateGroupsText() +{ + ModuleBase_IViewer::TextColor aText; + + int aSize = 10; + SUIT_ResourceMgr* aResMgr = ModuleBase_Preferences::resourceMgr(); + if (aResMgr->booleanValue("Viewer", "group_names_display")) { + // the first item in the TextColor list is font name -> text color + QColor aTextColor = aResMgr->colorValue("Viewer", "group_names_color"); + std::vector aTextCV; + aTextCV.push_back(aTextColor.red()); + aTextCV.push_back(aTextColor.green()); + aTextCV.push_back(aTextColor.blue()); + QString aFontName = aResMgr->stringValue("Viewer", "group_names_font"); + aText.push_back(std::pair >(aFontName.toStdWString(), aTextCV)); + aSize = aResMgr->integerValue("Viewer", "group_names_size"); + + DocumentPtr aDoc = ModelAPI_Session::get()->activeDocument(); + int aNbGroups = aDoc->size(ModelAPI_ResultGroup::group()); + for (int aGIndex = 0; aGIndex < aNbGroups; aGIndex++) + { + ResultGroupPtr aGroup = std::dynamic_pointer_cast( + aDoc->object(ModelAPI_ResultGroup::group(), aGIndex)); + if (aGroup.get() && !aGroup->isDisabled() && aGroup->isDisplayed()) + { + std::vector aColor; + ModelAPI_Tools::getColor(aGroup, aColor); + if (aColor.empty()) + { // default groups colors + std::string aSection, aName, aDefault; + aGroup->colorConfigInfo(aSection, aName, aDefault); + if (!aSection.empty() && !aName.empty()) { + aColor = Config_PropManager::color(aSection, aName); + } + } + if (aColor.empty()) + { + aColor.push_back(150.); + aColor.push_back(150.); + aColor.push_back(150.); + } + aText.push_back(std::pair >(aGroup->data()->name(), aColor)); + } + } + } + myViewerProxy->setText(aText, aSize); +} + //************************************************************** void XGUI_Workshop::setNormalView(bool toInvert) @@ -2982,6 +3093,49 @@ void XGUI_Workshop::setDisplayMode(const QObjectPtrList& theList, int theMode) myDisplayer->updateViewer(); } +//************************************************************** +void XGUI_Workshop::toggleEdgesDirection(const QObjectPtrList& theList) +{ + foreach(ObjectPtr anObj, theList) { + ResultPtr aResult = std::dynamic_pointer_cast(anObj); + if (aResult.get() != NULL) + { + bool aToShow = !ModelAPI_Tools::isShowEdgesDirection(aResult); + ResultBodyPtr aBodyResult = std::dynamic_pointer_cast(aResult); + if (aBodyResult.get() != NULL) { // change property for all sub-solids + std::list allRes; + ModelAPI_Tools::allSubs(aBodyResult, allRes); + std::list::iterator aRes; + for (aRes = allRes.begin(); aRes != allRes.end(); aRes++) { + ModelAPI_Tools::showEdgesDirection(*aRes, aToShow); + myDisplayer->redisplay(*aRes, false); + } + } + ModelAPI_Tools::showEdgesDirection(aResult, aToShow); + myDisplayer->redisplay(anObj, false); + } + } + if (theList.size() > 0) + myDisplayer->updateViewer(); +} + +//************************************************************** +void XGUI_Workshop::toggleBringToFront(const QObjectPtrList& theList) +{ + // Toggle the "BringToFront" state of all objects in the list + foreach(ObjectPtr anObj, theList) { + ResultPtr aResult = std::dynamic_pointer_cast(anObj); + if (aResult.get() != NULL) + { + bool aBringToFront = !ModelAPI_Tools::isBringToFront(aResult); + ModelAPI_Tools::bringToFront(aResult, aBringToFront); + myDisplayer->redisplay(anObj, false); + } + } + if (theList.size() > 0) + myDisplayer->updateViewer(); +} + //************************************************************** void XGUI_Workshop::closeDocument() {