From: vsv Date: Thu, 9 Oct 2014 09:05:23 +0000 (+0400) Subject: Provide local selection for operations outside of sketcher X-Git-Tag: V_0.5~107^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=703a9a0cd860fae14969ce510ed06ae13979298c;p=modules%2Fshaper.git Provide local selection for operations outside of sketcher --- diff --git a/src/FeaturesPlugin/extrusion_widget.xml b/src/FeaturesPlugin/extrusion_widget.xml index 0bcf41643..426bb3fd5 100644 --- a/src/FeaturesPlugin/extrusion_widget.xml +++ b/src/FeaturesPlugin/extrusion_widget.xml @@ -4,7 +4,8 @@ icon=":icons/sketch.png" tooltip="Select a face for extrusion" activate="true" - shape_types="face" + shape_types="face wire" + use_subshapes="true" /> diff --git a/src/GeomAPI/GeomAPI_Wire.cpp b/src/GeomAPI/GeomAPI_Wire.cpp index c70d5c5e8..6932444bf 100644 --- a/src/GeomAPI/GeomAPI_Wire.cpp +++ b/src/GeomAPI/GeomAPI_Wire.cpp @@ -18,9 +18,9 @@ GeomAPI_Wire::GeomAPI_Wire() : GeomAPI_Shape() { - TopoDS_Wire aBigWireImpl; + TopoDS_Compound aBigWireImpl; BRep_Builder aBuilder; - aBuilder.MakeWire(aBigWireImpl); + aBuilder.MakeCompound(aBigWireImpl); this->setImpl(new TopoDS_Shape(aBigWireImpl)); } diff --git a/src/ModuleBase/ModuleBase_Definitions.h b/src/ModuleBase/ModuleBase_Definitions.h index 56049acec..926de63ca 100644 --- a/src/ModuleBase/ModuleBase_Definitions.h +++ b/src/ModuleBase/ModuleBase_Definitions.h @@ -10,5 +10,4 @@ typedef QList QShortList; //!< list of short int values typedef QList QDoubleList; //!< list of double values typedef QList QFeatureList; //!< List of features typedef QList QResultList; //!< List of results - #endif diff --git a/src/ModuleBase/ModuleBase_IWorkshop.h b/src/ModuleBase/ModuleBase_IWorkshop.h index d4b9265ca..700f2baec 100644 --- a/src/ModuleBase/ModuleBase_IWorkshop.h +++ b/src/ModuleBase/ModuleBase_IWorkshop.h @@ -6,6 +6,7 @@ #define ModuleBase_IWorkshop_H #include "ModuleBase.h" +#include "ModuleBase_Definitions.h" #include @@ -32,6 +33,13 @@ Q_OBJECT virtual ModuleBase_ISelection* selection() const = 0; + /// Activate sub-shapes selection (opens local context) + /// Types has to be dined according to TopAbs_ShapeEnum + virtual void activateSubShapesSelection(const QIntList& theTypes) = 0; + + /// Deactivate sub-shapes selection (closes local context) + virtual void deactivateSubShapesSelection() = 0; + //! Returns instance of loaded module virtual ModuleBase_IModule* module() const = 0; diff --git a/src/ModuleBase/ModuleBase_Operation.cpp b/src/ModuleBase/ModuleBase_Operation.cpp index d8f50a4cd..d55bdc3f0 100644 --- a/src/ModuleBase/ModuleBase_Operation.cpp +++ b/src/ModuleBase/ModuleBase_Operation.cpp @@ -210,8 +210,8 @@ bool ModuleBase_Operation::commit() disconnect(myPropertyPanel, 0, this, 0); stopOperation(); - ModelAPI_Session::get()->finishOperation(); + emit stopped(); afterCommitOperation(); diff --git a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp index 3fb534b36..29443bf5d 100644 --- a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp @@ -59,7 +59,7 @@ ModuleBase_WidgetShapeSelector::ModuleBase_WidgetShapeSelector(QWidget* theParen const Config_WidgetAPI* theData, const std::string& theParentId) : ModuleBase_ModelWidget(theParent, theData, theParentId), - myWorkshop(theWorkshop), myIsActive(false) + myWorkshop(theWorkshop), myIsActive(false), myUseSubShapes(false) { myContainer = new QWidget(theParent); QHBoxLayout* aLayout = new QHBoxLayout(myContainer); @@ -88,6 +88,12 @@ ModuleBase_WidgetShapeSelector::ModuleBase_WidgetShapeSelector(QWidget* theParen std::string aTypes = theData->getProperty("shape_types"); myShapeTypes = QString(aTypes.c_str()).split(' '); + + std::string aUseSubShapes = theData->getProperty("use_subshapes"); + if (aUseSubShapes.length() > 0) { + QString aVal(aUseSubShapes.c_str()); + myUseSubShapes = (aVal.toUpper() == "TRUE"); + } } //******************************************************************** @@ -250,10 +256,19 @@ void ModuleBase_WidgetShapeSelector::activateSelection(bool toActivate) myTextLine->setPalette(myInactivePalet); updateSelectionName(); - if (myIsActive) + if (myIsActive) { connect(myWorkshop, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged())); - else + if (myUseSubShapes) { + QIntList aList; + foreach (QString aType, myShapeTypes) + aList.append(shapeType(aType)); + myWorkshop->activateSubShapesSelection(aList); + } + } else { disconnect(myWorkshop, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged())); + if (myUseSubShapes) + myWorkshop->deactivateSubShapesSelection(); + } } //******************************************************************** diff --git a/src/ModuleBase/ModuleBase_WidgetShapeSelector.h b/src/ModuleBase/ModuleBase_WidgetShapeSelector.h index c1decfa56..758638843 100644 --- a/src/ModuleBase/ModuleBase_WidgetShapeSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetShapeSelector.h @@ -91,6 +91,9 @@ private: ObjectPtr mySelectedObject; QStringList myShapeTypes; + /// If true then local selector has to be activated in context + bool myUseSubShapes; + QPalette myBasePalet; QPalette myInactivePalet; diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 0232196f9..3ada0450b 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -155,6 +155,7 @@ void PartSet_Module::onOperationStarted(ModuleBase_Operation* theOperation) aDisplayer->deactivateObjectsOutOfContext(); } else { Handle(AIS_InteractiveContext) aAIS = xWorkshop()->viewer()->AISContext(); + //TODO (VSV): We have to open Local context because at neutral point filters don't work (bug 25340) aAIS->AddFilter(myDocumentShapeFilter); } } diff --git a/src/PartSet/PartSet_OperationSketch.cpp b/src/PartSet/PartSet_OperationSketch.cpp index fdb56312b..2c8426c04 100644 --- a/src/PartSet/PartSet_OperationSketch.cpp +++ b/src/PartSet/PartSet_OperationSketch.cpp @@ -155,7 +155,10 @@ void PartSet_OperationSketch::stopOperation() PartSet_OperationSketchBase::stopOperation(); emit featureConstructed(feature(), FM_Hide); emit closeLocalContext(); +} +void PartSet_OperationSketch::afterCommitOperation() +{ FeaturePtr aFeature = feature(); std::list aResults = aFeature->results(); std::list::const_iterator aIt; diff --git a/src/PartSet/PartSet_OperationSketch.h b/src/PartSet/PartSet_OperationSketch.h index 94ddf02d9..f885503e3 100644 --- a/src/PartSet/PartSet_OperationSketch.h +++ b/src/PartSet/PartSet_OperationSketch.h @@ -112,6 +112,9 @@ signals: /// Default impl calls corresponding slot and commits immediately. virtual void startOperation(); + /// Virtual method called after operation committed (see commit() method for more description) + virtual void afterCommitOperation(); + private: std::list myFeatures; ///< the features to apply the edit operation }; diff --git a/src/XGUI/XGUI_ModuleConnector.cpp b/src/XGUI/XGUI_ModuleConnector.cpp index 4c36e61d1..aecada78b 100644 --- a/src/XGUI/XGUI_ModuleConnector.cpp +++ b/src/XGUI/XGUI_ModuleConnector.cpp @@ -47,3 +47,19 @@ ModuleBase_Operation* XGUI_ModuleConnector::currentOperation() const { return myWorkshop->operationMgr()->currentOperation(); } + + +void XGUI_ModuleConnector::activateSubShapesSelection(const QIntList& theTypes) +{ + Handle(AIS_InteractiveContext) aAIS = myWorkshop->viewer()->AISContext(); + if (!aAIS->HasOpenedContext()) + aAIS->OpenLocalContext(); + foreach(int aType, theTypes) + aAIS->ActivateStandardMode((TopAbs_ShapeEnum)aType); +} + +void XGUI_ModuleConnector::deactivateSubShapesSelection() +{ + Handle(AIS_InteractiveContext) aAIS = myWorkshop->viewer()->AISContext(); + aAIS->CloseAllContexts(); +} diff --git a/src/XGUI/XGUI_ModuleConnector.h b/src/XGUI/XGUI_ModuleConnector.h index c78c1d82a..054ad0872 100644 --- a/src/XGUI/XGUI_ModuleConnector.h +++ b/src/XGUI/XGUI_ModuleConnector.h @@ -27,6 +27,13 @@ Q_OBJECT //! Returns list of currently selected data objects virtual ModuleBase_ISelection* selection() const; + /// Activate sub-shapes selection (opens local context if it was not opened) + /// Types has to be dined according to TopAbs_ShapeEnum + virtual void activateSubShapesSelection(const QIntList& theTypes); + + /// Deactivate sub-shapes selection (closes local context) + virtual void deactivateSubShapesSelection(); + //! Returns instance of loaded module virtual ModuleBase_IModule* module() const; diff --git a/src/XGUI/XGUI_ViewerFilters.cpp b/src/XGUI/XGUI_ViewerFilters.cpp index c99c5bbfc..6efd9143e 100644 --- a/src/XGUI/XGUI_ViewerFilters.cpp +++ b/src/XGUI/XGUI_ViewerFilters.cpp @@ -15,7 +15,7 @@ IMPLEMENT_STANDARD_HANDLE(XGUI_ShapeDocumentFilter, SelectMgr_Filter); IMPLEMENT_STANDARD_RTTIEXT(XGUI_ShapeDocumentFilter, SelectMgr_Filter); -//TODO (VSV): Check bug in OCCT: Filter result is ignored +//TODO (VSV): Check bug in OCCT: Filter result is ignored (bug25340) Standard_Boolean XGUI_ShapeDocumentFilter::IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const { if (theOwner->HasSelectable()) {