#include <PartSet_Module.h>
#include <PartSet_OperationSketchBase.h>
#include <PartSet_OperationSketch.h>
+#include <PartSet_OperationFeatureCreate.h>
#include <XGUI_Displayer.h>
#include <XGUI_Workshop.h>
#include <Events_Loop.h>
#include <ModelAPI_Events.h>
+#include <ModelAPI_Feature.h>
#ifdef _DEBUG
#include <QDebug>
std::set<ObjectPtr>::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
for (; anIt != aLast; anIt++) {
ObjectPtr aObj = (*anIt);
- aDisplayer->deactivate(aObj);
- boost::shared_ptr<ModelAPI_Feature> aFeature =
- boost::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
- if (aFeature && (aFeature->getKind() == "Sketch")) // Activate sketcher for planes selection
- myModule->activateFeature(aFeature, false);
// If current operation is Sketch then there is no active sketching operation
- // and possible the object was created by Redo operatgion
- else if (aSketchOp) {
+ // and possible the object was created by Redo operation
+ if (aSketchOp) {
XGUI_Displayer* aDisplayer = myModule->xWorkshop()->displayer();
// Very possible it is not displayed
aDisplayer->display(aObj, false);
- std::list<int> aModes = aSketchOp->getSelectionModes(aObj);
- myModule->activateInLocalContext(aObj, aModes, false);
}
}
+ } else if (aType == EVENT_OBJECT_TO_REDISPLAY) {
+ PartSet_OperationFeatureCreate* aCreationOp =
+ dynamic_cast<PartSet_OperationFeatureCreate*>
+ (myModule->xWorkshop()->operationMgr()->currentOperation());
+ if (aCreationOp) {
+ // Deactivate currently creating objects for selection
+ XGUI_Displayer* aDisplayer = myModule->xWorkshop()->displayer();
+ FeaturePtr aFeature = aCreationOp->feature();
+ const std::list<ResultPtr>& aResults = aFeature->results();
+ boost::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
+ boost::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
+ std::set<ObjectPtr> aFeatures = aUpdMsg->objects();
+ std::set<ObjectPtr>::const_iterator aObjIt, aNoObj = aFeatures.cend();
+ std::list<ResultPtr>::const_iterator anIt = aResults.begin(), aLast = aResults.end();
+ for (; anIt != aLast; anIt++) {
+ aObjIt = aFeatures.find(*anIt);
+ if (aObjIt != aNoObj) {
+ aDisplayer->deactivate(*aObjIt);
+ }
+ }
+ }
} else if (aType == EVENT_OBJECT_DELETED) {
boost::shared_ptr<ModelAPI_ObjectDeletedMessage> aDelMsg =
boost::dynamic_pointer_cast<ModelAPI_ObjectDeletedMessage>(theMessage);
#include <GeomAPI_Shape.h>
#include <GeomAPI_AISObject.h>
#include <AIS_Shape.hxx>
+#include <AIS_DimensionSelectionMode.hxx>
-#include <StdSelect_FaceFilter.hxx>
#include <StdSelect_TypeOfFace.hxx>
#include <QObject>
void PartSet_Module::onOperationStarted(ModuleBase_Operation* theOperation)
{
+ XGUI_Workshop* aXWshp = xWorkshop();
+ XGUI_Displayer* aDisplayer = aXWshp->displayer();
PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(theOperation);
if (aPreviewOp) {
- XGUI_Workshop* aXWshp = xWorkshop();
XGUI_PropertyPanel* aPropPanel = aXWshp->propertyPanel();
connect(aPropPanel, SIGNAL(storedPoint2D(ObjectPtr, const std::string&)), this,
SLOT(onStorePoint2D(ObjectPtr, const std::string&)), Qt::UniqueConnection);
- XGUI_Displayer* aDisplayer = aXWshp->displayer();
- aDisplayer->openLocalContext();
- aDisplayer->deactivateObjectsOutOfContext();
+ //aDisplayer->deactivateObjectsOutOfContext();
+ PartSet_OperationSketch* aSketchOp = dynamic_cast<PartSet_OperationSketch*>(aPreviewOp);
+ if (aSketchOp) {
+ if (aSketchOp->isEditOperation()) {
+ aDisplayer->openLocalContext();
+ //setSketchingMode();
+ } else {
+ aDisplayer->openLocalContext();
+ aDisplayer->activateObjectsOutOfContext();
+ myPlaneFilter = new StdSelect_FaceFilter(StdSelect_Plane);
+ aDisplayer->addSelectionFilter(myPlaneFilter);
+ QIntList aModes = sketchSelectionModes(aPreviewOp->feature());
+ aDisplayer->setSelectionModes(aModes);
+ }
+ }
} 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);
+ aDisplayer->addSelectionFilter(myDocumentShapeFilter);
}
}
if (!theOperation)
return;
XGUI_Workshop* aXWshp = xWorkshop();
+ XGUI_Displayer* aDisplayer = aXWshp->displayer();
PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(theOperation);
if (aPreviewOp) {
XGUI_PropertyPanel* aPropPanel = aXWshp->propertyPanel();
+
+ PartSet_OperationSketch* aSketchOp = dynamic_cast<PartSet_OperationSketch*>(aPreviewOp);
+ if (aSketchOp) {
+ aDisplayer->closeLocalContexts();
+ } else {
+ PartSet_OperationFeatureCreate* aCreationOp =
+ dynamic_cast<PartSet_OperationFeatureCreate*>(aPreviewOp);
+ if (aCreationOp) {
+ // Activate just created object for selection
+ FeaturePtr aFeature = aCreationOp->feature();
+ QIntList aModes = sketchSelectionModes(aFeature);
+ const std::list<ResultPtr>& aResults = aFeature->results();
+ std::list<ResultPtr>::const_iterator anIt, aLast = aResults.end();
+ for (anIt = aResults.begin(); anIt != aLast; anIt++) {
+ aDisplayer->activate(*anIt, aModes);
+ }
+ aDisplayer->activate(aFeature, aModes);
+ }
+ }
} else {
// Activate results of current feature for selection
- FeaturePtr aFeature = theOperation->feature();
- XGUI_Displayer* aDisplayer = aXWshp->displayer();
- std::list<ResultPtr> aResults = aFeature->results();
- std::list<ResultPtr>::const_iterator aIt;
- for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) {
- aDisplayer->activate(*aIt);
- }
-
- Handle(AIS_InteractiveContext) aAIS = xWorkshop()->viewer()->AISContext();
- aAIS->RemoveFilter(myDocumentShapeFilter);
+ //FeaturePtr aFeature = theOperation->feature();
+ //XGUI_Displayer* aDisplayer = aXWshp->displayer();
+ //std::list<ResultPtr> aResults = aFeature->results();
+ //std::list<ResultPtr>::const_iterator aIt;
+ //for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) {
+ // aDisplayer->activate(*aIt);
+ //}
+
+ // The document limitation selection has to be only during operation
+ aDisplayer->removeSelectionFilter(myDocumentShapeFilter);
}
+ // Clear selection done during operation
+ aDisplayer->clearSelected();
}
void PartSet_Module::onContextMenuCommand(const QString& theId, bool isChecked)
void PartSet_Module::onPlaneSelected(double theX, double theY, double theZ)
{
- //erasePlanes();
myWorkshop->viewer()->setViewProjection(theX, theY, theZ);
- xWorkshop()->actionsMgr()->update();
-
- //PartSet_TestOCC::testSelection(myWorkshop);
+ xWorkshop()->actionsMgr()->update();
+ setSketchingMode();
}
void PartSet_Module::onFitAllView()
std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
aSketchOp->initSelection(aSelected, aHighlighted);
- } else if (aFeature) {
- anOperation->setFeature(aFeature);
- //Deactivate result of current feature in order to avoid its selection
- XGUI_Displayer* aDisplayer = xWorkshop()->displayer();
- std::list<ResultPtr> aResults = aFeature->results();
- std::list<ResultPtr>::const_iterator aIt;
- for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) {
- aDisplayer->deactivate(*aIt);
- }
- }
+ } //else if (aFeature) {
+ //anOperation->setFeature(aFeature);
+ ////Deactivate result of current feature in order to avoid its selection
+ //XGUI_Displayer* aDisplayer = xWorkshop()->displayer();
+ //std::list<ResultPtr> aResults = aFeature->results();
+ //std::list<ResultPtr>::const_iterator aIt;
+ //for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) {
+ // aDisplayer->deactivate(*aIt);
+ //}
+ //}
sendOperation(anOperation);
xWorkshop()->actionsMgr()->updateCheckState();
}
void PartSet_Module::onStopSelection(const QList<ObjectPtr>& theFeatures, const bool isStop)
{
XGUI_Displayer* aDisplayer = xWorkshop()->displayer();
- if (!isStop) {
- foreach(ObjectPtr aObject, theFeatures)
- {
- activateFeature(aObject, false);
- }
- }
+ //if (!isStop) {
+ // foreach(ObjectPtr aObject, theFeatures) {
+ // activateFeature(aObject);
+ // }
+ //}
aDisplayer->stopSelection(theFeatures, isStop, false);
ModuleBase_IViewer* aViewer = myWorkshop->viewer();
aDisplayer->updateViewer();
}
-void PartSet_Module::onCloseLocalContext()
+void PartSet_Module::setSketchingMode()
{
XGUI_Displayer* aDisplayer = xWorkshop()->displayer();
- aDisplayer->deactivateObjectsOutOfContext();
- aDisplayer->closeLocalContexts();
+ if (!myPlaneFilter.IsNull()) {
+ aDisplayer->removeSelectionFilter(myPlaneFilter);
+ myPlaneFilter.Nullify();
+ }
+ QIntList aModes;
+ //aModes << TopAbs_VERTEX << TopAbs_EDGE;
+ //aModes << AIS_DSM_Text << AIS_DSM_Line;
+ aDisplayer->setSelectionModes(aModes);
}
void PartSet_Module::onFeatureConstructed(ObjectPtr theFeature, int theMode)
if (aPrevOp) {
std::list<FeaturePtr> aList = aPrevOp->subFeatures();
XGUI_Displayer* aDisplayer = xWorkshop()->displayer();
- std::list<int> aModes = aPrevOp->getSelectionModes(aPrevOp->feature());
+ QIntList aModes = sketchSelectionModes(aPrevOp->feature());
std::list<FeaturePtr>::iterator aSFIt;
for (aSFIt = aList.begin(); aSFIt != aList.end(); ++aSFIt) {
std::list<ResultPtr> aResults = (*aSFIt)->results();
std::list<ResultPtr>::iterator aIt;
for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
- if (isDisplay)
- activateInLocalContext((*aIt), aModes, false);
- else
+ if (!isDisplay)
aDisplayer->erase((*aIt), false);
}
if (!isDisplay)
aDisplayer->erase((*aSFIt), false);
}
- aDisplayer->deactivateObjectsOutOfContext();
+ //aDisplayer->deactivateObjectsOutOfContext();
}
if (isDisplay)
ModelAPI_EventCreator::get()->sendUpdated(
connect(aPreviewOp, SIGNAL(setSelection(const QList<ObjectPtr>&)), this,
SLOT(onSetSelection(const QList<ObjectPtr>&)));
- connect(aPreviewOp, SIGNAL(closeLocalContext()), this, SLOT(onCloseLocalContext()));
-
PartSet_OperationSketch* aSketchOp = dynamic_cast<PartSet_OperationSketch*>(aPreviewOp);
if (aSketchOp) {
connect(aSketchOp, SIGNAL(planeSelected(double, double, double)), this,
return anOperation;
}
-//void PartSet_Module::sendOperation(ModuleBase_Operation* theOperation)
-//{
-// static Events_ID aModuleEvent = Events_Loop::eventByName(EVENT_OPERATION_LAUNCHED);
-// boost::shared_ptr<Config_PointerMessage> aMessage =
-// boost::shared_ptr<Config_PointerMessage>(new Config_PointerMessage(aModuleEvent, this));
-// aMessage->setPointer(theOperation);
-// Events_Loop::loop()->send(aMessage);
-//}
-
-void PartSet_Module::activateFeature(ObjectPtr theFeature, const bool isUpdateViewer)
-{
- ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
- PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
- if (aPreviewOp) {
- XGUI_Displayer* aDisplayer = xWorkshop()->displayer();
- std::list<int> aModes = aPreviewOp->getSelectionModes(theFeature);
- activateInLocalContext(theFeature, aModes, isUpdateViewer);
-
- // If this is a Sketcher then activate objects (planar faces) outside of context
- PartSet_OperationSketch* aSketchOp = dynamic_cast<PartSet_OperationSketch*>(aPreviewOp);
- if (aSketchOp) {
- Handle(StdSelect_FaceFilter) aFilter = new StdSelect_FaceFilter(StdSelect_Plane);
- aDisplayer->activateObjectsOutOfContext(aModes, aFilter);
- } else {
- aDisplayer->deactivateObjectsOutOfContext();
- }
- }
-}
void PartSet_Module::updateCurrentPreview(const std::string& theCmdId)
{
aDisplayer->erase(*aIt, false);
std::list<FeaturePtr> aList = aPreviewOp->subFeatures();
- std::list<int> aModes = aPreviewOp->getSelectionModes(aPreviewOp->feature());
std::list<FeaturePtr>::const_iterator anIt = aList.begin(), aLast = aList.end();
for (; anIt != aLast; anIt++) {
std::list<ResultPtr>::const_iterator aRIt;
for (aRIt = aResults.cbegin(); aRIt != aResults.cend(); ++aRIt) {
aDisplayer->display((*aRIt), false);
- activateInLocalContext((*aRIt), aModes, false);
+ aDisplayer->activate((*aRIt), sketchSelectionModes((*aRIt)));
}
aDisplayer->display(aSPFeature, false);
- activateInLocalContext(aSPFeature, aModes, false);
+ aDisplayer->activate(aSPFeature, sketchSelectionModes(aSPFeature));
}
aDisplayer->updateViewer();
}
}
-void PartSet_Module::activateInLocalContext(ObjectPtr theResult, const std::list<int>& theModes,
- const bool isUpdateViewer)
+QIntList PartSet_Module::sketchSelectionModes(ObjectPtr theFeature)
{
- XGUI_Displayer* aDisplayer = xWorkshop()->displayer();
- Handle(AIS_InteractiveContext) aContext = xWorkshop()->viewer()->AISContext();
- if (aContext.IsNull())
- return;
- // Open local context if there is no one
- if (!aContext->HasOpenedContext()) {
- aContext->ClearCurrents(false);
- //aContext->OpenLocalContext(false/*use displayed objects*/, true/*allow shape decomposition*/);
- aContext->OpenLocalContext();
- aContext->NotUseDisplayedObjects();
- }
- // display or redisplay presentation
- boost::shared_ptr<GeomAPI_AISObject> anAIS = aDisplayer->getAISObject(theResult);
- // Activate selection of objects from prs
- if (anAIS) {
- Handle(AIS_InteractiveObject) aAISObj = anAIS->impl<Handle(AIS_InteractiveObject)>();
- aContext->ClearSelected(false); // ToCheck
- //aContext->upClearSelected(false); // ToCheck
- aContext->Load(aAISObj, -1, true/*allow decomposition*/);
- aContext->Deactivate(aAISObj);
-
- std::list<int>::const_iterator anIt = theModes.begin(), aLast = theModes.end();
- for (; anIt != aLast; anIt++) {
- aContext->Activate(aAISObj, (*anIt));
+ QIntList aModes;
+ FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theFeature);
+ if (aFeature) {
+ if (aFeature->getKind() == SketchPlugin_Sketch::ID()) {
+ aModes.append(TopAbs_FACE);
+ return aModes;
+ } else if (PartSet_Tools::isConstraintFeature(aFeature->getKind())) {
+ aModes.append(AIS_DSM_Text);
+ aModes.append(AIS_DSM_Line);
+ return aModes;
}
- }
-
- if (isUpdateViewer)
- aDisplayer->updateViewer();
+ }
+ aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_VERTEX));
+ aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_EDGE));
+ return aModes;
}
#include <XGUI_Command.h>
#include <XGUI_ViewerFilters.h>
#include <ModelAPI_Feature.h>
+#include <StdSelect_FaceFilter.hxx>
#include <QMap>
#include <QObject>
/// \param theCmdId the operation name
//virtual void launchOperation(const QString& theCmdId);
- /// Activates the feature in the displayer
- /// \param theFeature the feature instance to be displayed
- /// \param isUpdateViewer the flag whether the viewer should be updated
- void activateFeature(ObjectPtr theFeature, const bool isUpdateViewer);
-
/// Updates current operation preview, if it has it.
/// \param theCmdId the operation name
void updateCurrentPreview(const std::string& theCmdId);
XGUI_Workshop* xWorkshop() const;
- /// Display the shape and activate selection of sub-shapes
- /// \param theFeature a feature instance
- /// \param theShape a shape
- /// \param theMode a list of local selection modes
- /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
- void activateInLocalContext(ObjectPtr theFeature, const std::list<int>& theModes,
- const bool isUpdateViewer = true);
+
+ /// Returns list of selection modes for the given object for sketch operation
+ static QIntList sketchSelectionModes(ObjectPtr theFeature);
public slots:
void onFeatureTriggered();
/// \param theFeatures a list of features to be selected
void onSetSelection(const QList<ObjectPtr>& theFeatures);
- /// SLOT, to close the viewer local context
- void onCloseLocalContext();
+ /// SLOT, Defines Sketch editing mode
+ void setSketchingMode();
/// SLOT, to visualize the feature in another local context mode
/// \param theFeature the feature to be put in another local context mode
/// A filter which provides selection within a current document or whole PartSet
Handle(XGUI_ShapeDocumentFilter) myDocumentShapeFilter;
+ Handle(StdSelect_FaceFilter) myPlaneFilter;
};
#endif
return false;
}
-std::list<int> PartSet_OperationFeatureCreate::getSelectionModes(ObjectPtr theFeature) const
-{
- std::list<int> aModes;
- if (theFeature != feature())
- aModes = PartSet_OperationSketchBase::getSelectionModes(theFeature);
- return aModes;
-}
-
void PartSet_OperationFeatureCreate::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView)
{
double aX, anY;
/// Destructor
virtual ~PartSet_OperationFeatureCreate();
- /// Returns the operation local selection mode
- /// \param theFeature the feature object to get the selection mode
- /// \return the selection mode
- virtual std::list<int> getSelectionModes(ObjectPtr theFeature) const;
-
/// Gives the current mouse point in the viewer
/// \param thePoint a point clicked in the viewer
/// \param theEvent the mouse event
{
}
-std::list<int> PartSet_OperationSketch::getSelectionModes(ObjectPtr theFeature) const
-{
- std::list<int> aModes;
- if (!hasSketchPlane())
- aModes.push_back(TopAbs_FACE);
- else
- aModes = PartSet_OperationSketchBase::getSelectionModes(theFeature);
-
- return aModes;
-}
-
FeaturePtr PartSet_OperationSketch::sketch() const
{
return feature();
{
PartSet_OperationSketchBase::stopOperation();
emit featureConstructed(feature(), FM_Hide);
- emit closeLocalContext();
}
void PartSet_OperationSketch::afterCommitOperation()
flushUpdated();
emit featureConstructed(feature(), FM_Hide);
- emit closeLocalContext();
emit planeSelected(aDir->x(), aDir->y(), aDir->z());
}
virtual bool isGranted(ModuleBase_Operation* theOperation) const;
- /// Returns the operation local selection mode
- /// \param theFeature the feature object to get the selection mode
- /// \return the selection mode
- virtual std::list<int> getSelectionModes(ObjectPtr theFeature) const;
-
/// Returns the operation sketch feature
/// \returns the sketch instance
virtual FeaturePtr sketch() const;
return std::list<FeaturePtr>();
}
-std::list<int> PartSet_OperationSketchBase::getSelectionModes(ObjectPtr theFeature) const
-{
- //TODO: Define position of selection modes definition
- std::list<int> aModes;
- FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theFeature);
- if (aFeature && PartSet_Tools::isConstraintFeature(aFeature->getKind())) {
- aModes.push_back(AIS_DSM_Text);
- aModes.push_back(AIS_DSM_Line);
- } else {
- aModes.push_back(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_VERTEX));
- aModes.push_back(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_EDGE));
- }
- return aModes;
-}
FeaturePtr PartSet_OperationSketchBase::createFeature(const bool theFlushMessage)
{
ModuleBase_Operation::createFeature(theFlushMessage);
/// \return the list of subfeatures
virtual std::list<FeaturePtr> subFeatures() const;
- /// Returns the operation local selection mode
- /// \param theFeature the feature object to get the selection mode
- /// \return the selection mode
- virtual std::list<int> getSelectionModes(ObjectPtr theFeature) const;
-
/// Returns the operation sketch feature
/// \returns the sketch instance
virtual FeaturePtr sketch() const = 0;
/// \param theFeatures a list of features to be disabled
void setSelection(const QList<ObjectPtr>& theFeatures);
- /// signal to close the operation local context if it is opened
- void closeLocalContext();
-
protected:
/// Creates an operation new feature
/// In addition to the default realization it appends the created line feature to
#include <AIS_ListIteratorOfListOfInteractive.hxx>
#include <AIS_DimensionSelectionMode.hxx>
#include <AIS_Shape.hxx>
+#include <AIS_Dimension.hxx>
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
#include <set>
}
}
-void XGUI_Displayer::activate(ObjectPtr theObject)
+void XGUI_Displayer::activate(ObjectPtr theObject, const QIntList& theModes)
{
if (isVisible(theObject)) {
Handle(AIS_InteractiveContext) aContext = AISContext();
boost::shared_ptr<GeomAPI_AISObject> anObj = myResult2AISObjectMap[theObject];
Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
- aContext->Activate(anAIS);
+ if (aContext->HasOpenedContext()) {
+ aContext->Load(anAIS, -1, true);
+ }
+ if (theModes.size() > 0) {
+ foreach(int aMode, theModes) {
+ aContext->Activate(anAIS, aMode);
+ }
+ } else
+ aContext->Activate(anAIS);
}
}
updateViewer();
}
+
+void XGUI_Displayer::clearSelected()
+{
+ Handle(AIS_InteractiveContext) aContext = AISContext();
+ if (aContext)
+ aContext->ClearSelected();
+}
+
void XGUI_Displayer::eraseAll(const bool isUpdateViewer)
{
Handle(AIS_InteractiveContext) ic = AISContext();
}
}
-void XGUI_Displayer::activateObjectsOutOfContext(const std::list<int>& theModes,
- Handle(SelectMgr_Filter) theFilter)
+void XGUI_Displayer::activateObjectsOutOfContext()
{
Handle(AIS_InteractiveContext) aContext = AISContext();
// Open local context if there is no one
return;
aContext->UseDisplayedObjects();
- std::list<int>::const_iterator anIt = theModes.begin(), aLast = theModes.end();
- for (; anIt != aLast; anIt++) {
- aContext->ActivateStandardMode((TopAbs_ShapeEnum)(*anIt));
+ ResultToAISMap::iterator aIt;
+ Handle(AIS_InteractiveObject) anAISIO;
+ for (aIt = myResult2AISObjectMap.begin(); aIt != myResult2AISObjectMap.end(); aIt++) {
+ anAISIO = (*aIt).second->impl<Handle(AIS_InteractiveObject)>();
+ aContext->Load(anAISIO, -1, true);
}
-
- if (!theFilter.IsNull())
- aContext->AddFilter(theFilter);
}
if (!aContext->HasOpenedContext())
return;
- aContext->RemoveFilters();
aContext->NotUseDisplayedObjects();
}
aContext->SetDisplayMode(aAISIO, theMode, toUpdate);
}
+void XGUI_Displayer::setSelectionModes(const QIntList& theModes)
+{
+ Handle(AIS_InteractiveContext) aContext = AISContext();
+ if (aContext.IsNull())
+ return;
+ if (!aContext->HasOpenedContext())
+ return;
+ // Clear previous mode
+ const TColStd_ListOfInteger& aModes = aContext->ActivatedStandardModes();
+ if (!aModes.IsEmpty()) {
+ TColStd_ListOfInteger aMModes;
+ aMModes.Assign(aModes);
+ TColStd_ListIteratorOfListOfInteger it(aMModes);
+ for(; it.More(); it.Next()) {
+ aContext->DeactivateStandardMode((TopAbs_ShapeEnum)it.Value());
+ }
+ }
+ foreach(int aMode, theModes) {
+ aContext->ActivateStandardMode((TopAbs_ShapeEnum)aMode);
+ }
+}
XGUI_Displayer::DisplayMode XGUI_Displayer::displayMode(ObjectPtr theObject) const
{
return (XGUI_Displayer::DisplayMode) aAISIO->DisplayMode();
}
+void XGUI_Displayer::addSelectionFilter(const Handle(SelectMgr_Filter)& theFilter)
+{
+ Handle(AIS_InteractiveContext) aContext = AISContext();
+ if (aContext.IsNull())
+ return;
+ aContext->AddFilter(theFilter);
+}
+
+void XGUI_Displayer::removeSelectionFilter(const Handle(SelectMgr_Filter)& theFilter)
+{
+ Handle(AIS_InteractiveContext) aContext = AISContext();
+ if (aContext.IsNull())
+ return;
+ aContext->RemoveFilter(theFilter);
+}
*/
void setSelected(const QList<ObjectPtr>& theFeatures, bool isUpdateViewer = true);
+
+ /// Un select all objects
+ void clearSelected();
+
/// Erase the feature and a shape.
/// \param theFeature a feature instance
/// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
/// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
void closeLocalContexts(const bool isUpdateViewer = true);
+ /*
+ * Set modes of selections. Selection mode has to be defined by TopAbs_ShapeEnum.
+ * It doesn't manages a local context
+ * \param theModes - list of selection modes. If the list is empty then all selectoin modes will be cleared.
+ */
+ void setSelectionModes(const QIntList& theModes);
+
+ void addSelectionFilter(const Handle(SelectMgr_Filter)& theFilter);
+
+ void removeSelectionFilter(const Handle(SelectMgr_Filter)& theFilter);
+
/// Updates the viewer
void updateViewer();
void deactivate(ObjectPtr theFeature);
/// Activates the given object (it can be selected)
- void activate(ObjectPtr theFeature);
+ void activate(ObjectPtr theFeature, const QIntList& theModes);
/// Returns true if the given object can be selected
bool isActive(ObjectPtr theObject) const;
/// Activates in local context displayed outside of the context.
/// \param theModes - selection modes to activate
/// \param theFilter - filter for selection
- void activateObjectsOutOfContext(const std::list<int>& theModes,
- Handle(SelectMgr_Filter) theFilter);
+ void activateObjectsOutOfContext();
void deactivateObjectsOutOfContext();
#include "XGUI_SelectionMgr.h"
#include "XGUI_Selection.h"
#include "XGUI_OperationMgr.h"
+#include "XGUI_Displayer.h"
XGUI_ModuleConnector::XGUI_ModuleConnector(XGUI_Workshop* theWorkshop)
: ModuleBase_IWorkshop(theWorkshop),
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);
- }
+ XGUI_Displayer* aDisp = myWorkshop->displayer();
+ aDisp->openLocalContext();
+ aDisp->activateObjectsOutOfContext();
+ aDisp->setSelectionModes(theTypes);
}
void XGUI_ModuleConnector::deactivateSubShapesSelection()
{
- Handle(AIS_InteractiveContext) aAIS = myWorkshop->viewer()->AISContext();
- aAIS->CloseAllContexts();
+ XGUI_Displayer* aDisp = myWorkshop->displayer();
+ aDisp->closeLocalContexts(false);
}
{
std::set<ObjectPtr> aObjects = theMsg->objects();
std::set<ObjectPtr>::const_iterator aIt;
+ QIntList aModes;
for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) {
ObjectPtr aObj = (*aIt);
if (!aObj->data() || !aObj->data()->isValid() || aObj->document()->isConcealed(aObj))
ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
if (!aOperation->hasObject(aObj))
if (!myDisplayer->isActive(aObj))
- myDisplayer->activate(aObj);
+ myDisplayer->activate(aObj, aModes);
}
} else {
if (myOperationMgr->hasOperation()) {