From b851613e697ad60c47e633121933a5ee4b640789 Mon Sep 17 00:00:00 2001 From: vsv Date: Tue, 28 Oct 2014 12:41:32 +0300 Subject: [PATCH] Corrections of selection architecture --- src/ModuleBase/ModuleBase_IModule.cpp | 22 ++- src/ModuleBase/ModuleBase_IModule.h | 181 ++++++++++-------- src/ModuleBase/ModuleBase_ISelection.h | 6 +- src/ModuleBase/ModuleBase_Operation.cpp | 8 +- src/ModuleBase/ModuleBase_Operation.h | 7 +- src/ModuleBase/ModuleBase_ResultPrs.cpp | 2 + src/ModuleBase/ModuleBase_WidgetFactory.cpp | 1 + src/PartSet/PartSet_Module.cpp | 82 ++++---- src/PartSet/PartSet_Module.h | 49 ++--- src/PartSet/PartSet_OperationFeatureBase.cpp | 25 +-- src/PartSet/PartSet_OperationFeatureBase.h | 5 +- .../PartSet_OperationFeatureCreate.cpp | 37 ++-- src/PartSet/PartSet_OperationFeatureCreate.h | 7 +- src/PartSet/PartSet_OperationFeatureEdit.cpp | 134 +++++++------ src/PartSet/PartSet_OperationFeatureEdit.h | 18 +- .../PartSet_OperationFeatureEditMulti.cpp | 120 ++++++------ .../PartSet_OperationFeatureEditMulti.h | 23 +-- src/PartSet/PartSet_OperationSketch.cpp | 69 ++++--- src/PartSet/PartSet_OperationSketch.h | 18 +- src/PartSet/PartSet_OperationSketchBase.cpp | 24 +-- src/PartSet/PartSet_OperationSketchBase.h | 22 ++- src/PartSet/PartSet_Tools.cpp | 8 +- src/PartSet/PartSet_Tools.h | 5 +- src/PartSet/PartSet_Validators.cpp | 21 +- src/XGUI/XGUI_Displayer.cpp | 2 +- src/XGUI/XGUI_Selection.cpp | 10 +- src/XGUI/XGUI_Selection.h | 6 +- src/XGUI/XGUI_ViewWindow.cpp | 4 +- 28 files changed, 509 insertions(+), 407 deletions(-) diff --git a/src/ModuleBase/ModuleBase_IModule.cpp b/src/ModuleBase/ModuleBase_IModule.cpp index c8b347f76..773c84b5a 100644 --- a/src/ModuleBase/ModuleBase_IModule.cpp +++ b/src/ModuleBase/ModuleBase_IModule.cpp @@ -1,5 +1,6 @@ #include "ModuleBase_IModule.h" +#include "ModuleBase_IViewer.h" #include "ModuleBase_ViewerPrs.h" #include "ModuleBase_Operation.h" #include "ModuleBase_ISelection.h" @@ -11,13 +12,30 @@ #include +ModuleBase_IModule::ModuleBase_IModule(ModuleBase_IWorkshop* theParent) + : QObject(theParent), myWorkshop(theParent) +{ + connect(myWorkshop, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged())); + connect(myWorkshop->viewer(), SIGNAL(mousePress(QMouseEvent*)), this, + SLOT(onMousePressed(QMouseEvent*))); + connect(myWorkshop->viewer(), SIGNAL(mouseRelease(QMouseEvent*)), this, + SLOT(onMouseReleased(QMouseEvent*))); + connect(myWorkshop->viewer(), SIGNAL(mouseMove(QMouseEvent*)), this, + SLOT(onMouseMoved(QMouseEvent*))); + connect(myWorkshop->viewer(), SIGNAL(keyRelease(QKeyEvent*)), this, + SLOT(onKeyRelease(QKeyEvent*))); + connect(myWorkshop->viewer(), SIGNAL(mouseDoubleClick(QMouseEvent*)), this, + SLOT(onMouseDoubleClick(QMouseEvent*))); +} + + void ModuleBase_IModule::launchOperation(const QString& theCmdId) { ModuleBase_Operation* anOperation = createOperation(theCmdId.toStdString()); ModuleBase_ISelection* aSelection = myWorkshop->selection(); // Initialise operation with preliminary selection - std::list aSelected = aSelection->getSelected(); - std::list aHighlighted = aSelection->getHighlighted(); + QList aSelected = aSelection->getSelected(); + QList aHighlighted = aSelection->getHighlighted(); anOperation->initSelection(aSelected, aHighlighted); sendOperation(anOperation); } diff --git a/src/ModuleBase/ModuleBase_IModule.h b/src/ModuleBase/ModuleBase_IModule.h index 3bea34002..5787ccfb0 100644 --- a/src/ModuleBase/ModuleBase_IModule.h +++ b/src/ModuleBase/ModuleBase_IModule.h @@ -1,76 +1,107 @@ -#ifndef ModuleBase_IModule_H -#define ModuleBase_IModule_H - +#ifndef ModuleBase_IModule_H +#define ModuleBase_IModule_H + #include "ModuleBase.h" -#include "ModuleBase_IWorkshop.h" - -#include -#include - - -class QAction; -class Config_WidgetAPI; -class ModuleBase_ModelWidget; -class ModuleBase_Operation; -class ModuleBase_IWorkshop; - -/** - * Interface to a module - */ -class MODULEBASE_EXPORT ModuleBase_IModule : public QObject -{ - public: - - ModuleBase_IModule(ModuleBase_IWorkshop* theParent): QObject(theParent), myWorkshop(theParent) {} - - virtual ~ModuleBase_IModule() {} - - /// Reads description of features from XML file - virtual void createFeatures() = 0; - - /// Called on creation of menu item in desktop - virtual void featureCreated(QAction*) = 0; - - /// Creates an operation and send it to loop - /// \param theCmdId the operation name - virtual void launchOperation(const QString& theCmdId); - - /// Called when it is necessary to update a command state (enable or disable it) - //virtual bool isFeatureEnabled(const QString& theCmdId) const = 0; - - /// Creates custom widgets for property panel - virtual QWidget* createWidgetByType(const std::string& theType, QWidget* theParent, - Config_WidgetAPI* theWidgetApi, - QList& theModelWidgets) - { - return 0; - } - - ModuleBase_IWorkshop* workshop() const { return myWorkshop; } - - protected: - /// Sends the operation for launching - /// \param theOperation the operation - void sendOperation(ModuleBase_Operation* theOperation); - - /// Creates a new operation - /// \param theCmdId the operation name - /// \param theFeatureKind a kind of feature to get the feature xml description - virtual ModuleBase_Operation* createOperation(const std::string& theCmdId, - const std::string& theFeatureKind = "") = 0; - - -protected: - - ModuleBase_IWorkshop* myWorkshop; - -}; - -//! This function must return a new module instance. -extern "C" { -typedef ModuleBase_IModule* (*CREATE_FUNC)(ModuleBase_IWorkshop*); -} - -#define CREATE_MODULE "createModule" - -#endif //ModuleBase_IModule +#include "ModuleBase_IWorkshop.h" + +#include +#include + + +class QAction; +class QMouseEvent; +class QKeyEvent; +class Config_WidgetAPI; +class ModuleBase_ModelWidget; +class ModuleBase_Operation; +class ModuleBase_IWorkshop; + +/** + * Interface to a module + */ +class MODULEBASE_EXPORT ModuleBase_IModule : public QObject +{ + Q_OBJECT + public: + + ModuleBase_IModule(ModuleBase_IWorkshop* theParent); + + virtual ~ModuleBase_IModule() {} + + /// Reads description of features from XML file + virtual void createFeatures() = 0; + + /// Called on creation of menu item in desktop + virtual void featureCreated(QAction*) = 0; + + /// Creates an operation and send it to loop + /// \param theCmdId the operation name + virtual void launchOperation(const QString& theCmdId); + + /// Called when it is necessary to update a command state (enable or disable it) + //virtual bool isFeatureEnabled(const QString& theCmdId) const = 0; + + /// Creates custom widgets for property panel + virtual QWidget* createWidgetByType(const std::string& theType, QWidget* theParent, + Config_WidgetAPI* theWidgetApi, + QList& theModelWidgets) + { + return 0; + } + + ModuleBase_IWorkshop* workshop() const { return myWorkshop; } + +protected slots: + + /// Called on selection changed event + virtual void onSelectionChanged() {} + + /// SLOT, that is called by mouse press in the viewer. + /// The mouse released point is sent to the current operation to be processed. + /// \param theEvent the mouse event + virtual void onMousePressed(QMouseEvent* theEvent) {} + + /// SLOT, that is called by mouse release in the viewer. + /// The mouse released point is sent to the current operation to be processed. + /// \param theEvent the mouse event + virtual void onMouseReleased(QMouseEvent* theEvent) {} + + /// SLOT, that is called by mouse move in the viewer. + /// The mouse moved point is sent to the current operation to be processed. + /// \param theEvent the mouse event + virtual void onMouseMoved(QMouseEvent* theEvent) {} + + /// SLOT, that is called by the mouse double click in the viewer. + /// \param theEvent the mouse event + virtual void onMouseDoubleClick(QMouseEvent* theEvent) {} + + /// SLOT, that is called by the key in the viewer is clicked. + /// \param theEvent the mouse event + virtual void onKeyRelease(QKeyEvent* theEvent) {} + + protected: + /// Sends the operation for launching + /// \param theOperation the operation + void sendOperation(ModuleBase_Operation* theOperation); + + /// Creates a new operation + /// \param theCmdId the operation name + /// \param theFeatureKind a kind of feature to get the feature xml description + virtual ModuleBase_Operation* createOperation(const std::string& theCmdId, + const std::string& theFeatureKind = "") = 0; + + +protected: + + ModuleBase_IWorkshop* myWorkshop; + +}; + +//! This function must return a new module instance. +extern "C" { +typedef ModuleBase_IModule* (*CREATE_FUNC)(ModuleBase_IWorkshop*); +} + +#define CREATE_MODULE "createModule" + +#endif //ModuleBase_IModule diff --git a/src/ModuleBase/ModuleBase_ISelection.h b/src/ModuleBase/ModuleBase_ISelection.h index 72845616b..c1b06ca1b 100644 --- a/src/ModuleBase/ModuleBase_ISelection.h +++ b/src/ModuleBase/ModuleBase_ISelection.h @@ -14,7 +14,7 @@ #include #include -#include +#include class ModuleBase_ISelection { @@ -23,12 +23,12 @@ class ModuleBase_ISelection /// Returns a list of viewer selected presentations /// \param theShapeTypeToSkip the shapes with this type will be skipped during the result list build /// \return list of presentations - virtual std::list getSelected(int theShapeTypeToSkip = -1) const = 0; + virtual QList getSelected(int theShapeTypeToSkip = -1) const = 0; /// Returns a list of viewer highlited presentations /// \param theShapeTypeToSkip the shapes with this type will be skipped during the result list build /// \return list of presentations - virtual std::list getHighlighted(int theShapeTypeToSkip = -1) const = 0; + virtual QList getHighlighted(int theShapeTypeToSkip = -1) const = 0; /** * Returns list of features currently selected in 3d viewer diff --git a/src/ModuleBase/ModuleBase_Operation.cpp b/src/ModuleBase/ModuleBase_Operation.cpp index 19876df75..825c28360 100644 --- a/src/ModuleBase/ModuleBase_Operation.cpp +++ b/src/ModuleBase/ModuleBase_Operation.cpp @@ -238,11 +238,11 @@ void ModuleBase_Operation::activateByPreselection() return; ModuleBase_ModelWidget* aActiveWgt = myPropertyPanel->activeWidget(); if ((myPreSelection.size() > 0) && aActiveWgt) { - const ModuleBase_ViewerPrs& aPrs = myPreSelection.front(); + const ModuleBase_ViewerPrs& aPrs = myPreSelection.first(); ModuleBase_WidgetValueFeature aValue; aValue.setObject(aPrs.object()); if (aActiveWgt->setValue(&aValue)) { - myPreSelection.remove(aPrs); + myPreSelection.removeOne(aPrs); myPropertyPanel->activateNextWidget(); } // If preselection is enough to make a valid feature - apply it immediately @@ -250,8 +250,8 @@ void ModuleBase_Operation::activateByPreselection() } void ModuleBase_Operation::initSelection( - const std::list& theSelected, - const std::list& /*theHighlighted*/) + const QList& theSelected, + const QList& /*theHighlighted*/) { myPreSelection = theSelected; } diff --git a/src/ModuleBase/ModuleBase_Operation.h b/src/ModuleBase/ModuleBase_Operation.h index 80cab9e12..0d1ea591e 100644 --- a/src/ModuleBase/ModuleBase_Operation.h +++ b/src/ModuleBase/ModuleBase_Operation.h @@ -17,6 +17,7 @@ #include #include #include +#include class ModuleBase_ModelWidget; class ModuleBase_OperationDescription; @@ -116,8 +117,8 @@ Q_OBJECT /// Initialisation of operation with preliminary selection /// \param theSelected the list of selected presentations /// \param theHighlighted the list of highlighted presentations - virtual void initSelection(const std::list& theSelected, - const std::list& theHighlighted); + virtual void initSelection(const QList& theSelected, + const QList& theHighlighted); virtual void setPropertyPanel(ModuleBase_IPropertyPanel* theProp); @@ -230,7 +231,7 @@ signals: QStringList myNestedFeatures; /// List of pre-selected object - std::list myPreSelection; + QList myPreSelection; /// Access to property panel ModuleBase_IPropertyPanel* myPropertyPanel; diff --git a/src/ModuleBase/ModuleBase_ResultPrs.cpp b/src/ModuleBase/ModuleBase_ResultPrs.cpp index c8eea52c2..1bb9efc25 100644 --- a/src/ModuleBase/ModuleBase_ResultPrs.cpp +++ b/src/ModuleBase/ModuleBase_ResultPrs.cpp @@ -46,6 +46,8 @@ void ModuleBase_ResultPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& t const Standard_Integer theMode) { boost::shared_ptr aShapePtr = ModelAPI_Tools::shape(myResult); + if (!aShapePtr) + return; myOriginalShape = aShapePtr->impl(); Set(aShapePtr->impl()); AIS_Shape::Compute(thePresentationManager, thePresentation, theMode); diff --git a/src/ModuleBase/ModuleBase_WidgetFactory.cpp b/src/ModuleBase/ModuleBase_WidgetFactory.cpp index 057c4d5d3..985c56a50 100644 --- a/src/ModuleBase/ModuleBase_WidgetFactory.cpp +++ b/src/ModuleBase/ModuleBase_WidgetFactory.cpp @@ -57,6 +57,7 @@ ModuleBase_WidgetFactory::ModuleBase_WidgetFactory(const std::string& theXmlRepr ModuleBase_WidgetFactory::~ModuleBase_WidgetFactory() { + delete myWidgetApi; } void ModuleBase_WidgetFactory::createWidget(QWidget* theParent) diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index b2f838d1a..d3058ab2b 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -87,16 +87,6 @@ PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop) connect(aContextMenuMgr, SIGNAL(actionTriggered(const QString&, bool)), this, SLOT(onContextMenuCommand(const QString&, bool))); - connect(myWorkshop->viewer(), SIGNAL(mousePress(QMouseEvent*)), this, - SLOT(onMousePressed(QMouseEvent*))); - connect(myWorkshop->viewer(), SIGNAL(mouseRelease(QMouseEvent*)), this, - SLOT(onMouseReleased(QMouseEvent*))); - connect(myWorkshop->viewer(), SIGNAL(mouseMove(QMouseEvent*)), this, - SLOT(onMouseMoved(QMouseEvent*))); - connect(myWorkshop->viewer(), SIGNAL(keyRelease(QKeyEvent*)), this, - SLOT(onKeyRelease(QKeyEvent*))); - connect(myWorkshop->viewer(), SIGNAL(mouseDoubleClick(QMouseEvent*)), this, - SLOT(onMouseDoubleClick(QMouseEvent*))); } PartSet_Module::~PartSet_Module() @@ -224,14 +214,27 @@ void PartSet_Module::onMousePressed(QMouseEvent* theEvent) XGUI_Workshop* aXWshp = xWorkshop(); PartSet_OperationSketchBase* aPreviewOp = dynamic_cast(workshop()->currentOperation()); - Handle(V3d_View) aView = myWorkshop->viewer()->activeView(); - if (aPreviewOp && (!aView.IsNull())) { + if (aPreviewOp) { ModuleBase_ISelection* aSelection = workshop()->selection(); // Initialise operation with preliminary selection - std::list aSelected = aSelection->getSelected(); - std::list aHighlighted = aSelection->getHighlighted(); - - aPreviewOp->mousePressed(theEvent, aView, aSelected, aHighlighted); + //QList aSelected = aSelection->getSelected(); + //QList aHighlighted = aSelection->getHighlighted(); + //QList aObjList; + //bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier); + //if (aHasShift) { + // foreach(ModuleBase_ViewerPrs aPrs, aSelected) + // aObjList.append(aPrs.object()); + + // foreach (ModuleBase_ViewerPrs aPrs, aHighlighted) { + // if (!aObjList.contains(aPrs.object())) + // aObjList.append(aPrs.object()); + // } + //} else { + // foreach(ModuleBase_ViewerPrs aPrs, aHighlighted) + // aObjList.append(aPrs.object()); + //} + //onSetSelection(aObjList); + aPreviewOp->mousePressed(theEvent, myWorkshop->viewer(), aSelection); } } @@ -239,14 +242,10 @@ void PartSet_Module::onMouseReleased(QMouseEvent* theEvent) { PartSet_OperationSketchBase* aPreviewOp = dynamic_cast(myWorkshop->currentOperation()); - Handle(V3d_View) aView = myWorkshop->viewer()->activeView(); - if (aPreviewOp && (!aView.IsNull())) { + if (aPreviewOp) { ModuleBase_ISelection* aSelection = workshop()->selection(); // Initialise operation with preliminary selection - std::list aSelected = aSelection->getSelected(); - std::list aHighlighted = aSelection->getHighlighted(); - - aPreviewOp->mouseReleased(theEvent, aView, aSelected, aHighlighted); + aPreviewOp->mouseReleased(theEvent, myWorkshop->viewer(), aSelection); } } @@ -254,9 +253,8 @@ void PartSet_Module::onMouseMoved(QMouseEvent* theEvent) { PartSet_OperationSketchBase* aPreviewOp = dynamic_cast(myWorkshop->currentOperation()); - Handle(V3d_View) aView = myWorkshop->viewer()->activeView(); - if (aPreviewOp && (!aView.IsNull())) - aPreviewOp->mouseMoved(theEvent, aView); + if (aPreviewOp) + aPreviewOp->mouseMoved(theEvent, myWorkshop->viewer()); } void PartSet_Module::onKeyRelease(QKeyEvent* theEvent) @@ -276,9 +274,7 @@ void PartSet_Module::onMouseDoubleClick(QMouseEvent* theEvent) if (aPreviewOp && (!aView.IsNull())) { ModuleBase_ISelection* aSelection = workshop()->selection(); // Initialise operation with preliminary selection - std::list aSelected = aSelection->getSelected(); - std::list aHighlighted = aSelection->getHighlighted(); - aPreviewOp->mouseDoubleClick(theEvent, aView, aSelected, aHighlighted); + aPreviewOp->mouseDoubleClick(theEvent, aView, aSelection); } } @@ -314,8 +310,8 @@ void PartSet_Module::onRestartOperation(std::string theName, ObjectPtr theObject } ModuleBase_ISelection* aSelection = workshop()->selection(); // Initialise operation with preliminary selection - std::list aSelected = aSelection->getSelected(); - std::list aHighlighted = aSelection->getHighlighted(); + QList aSelected = aSelection->getSelected(); + QList aHighlighted = aSelection->getHighlighted(); aSketchOp->initSelection(aSelected, aHighlighted); } //else if (aFeature) { //anOperation->setFeature(aFeature); @@ -453,8 +449,10 @@ ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdI SLOT(onFeatureConstructed(ObjectPtr, int))); connect(aPreviewOp, SIGNAL(restartRequired(std::string, ObjectPtr)), this, SLOT(onRestartOperation(std::string, ObjectPtr))); - connect(aPreviewOp, SIGNAL(multiSelectionEnabled(bool)), this, - SLOT(onMultiSelectionEnabled(bool))); + // If manage multi selection the it will be impossible to select more then one + // object under operation Edit +// connect(aPreviewOp, SIGNAL(multiSelectionEnabled(bool)), this, +// SLOT(onMultiSelectionEnabled(bool))); connect(aPreviewOp, SIGNAL(stopSelection(const QList&, const bool)), this, SLOT(onStopSelection(const QList&, const bool))); @@ -605,3 +603,23 @@ gp_Pln PartSet_Module::getSketchPlane(FeaturePtr theSketch) const return gp_Pln(aOrig, aDir); } + +void PartSet_Module::onSelectionChanged() +{ + ModuleBase_ISelection* aSelect = myWorkshop->selection(); + QList aSelected = aSelect->getSelected(); + // We need to stop edit operation if selection is cleared + if (aSelected.size() == 0) { + PartSet_OperationFeatureEdit* anEditOp = + dynamic_cast(myWorkshop->currentOperation()); + if (!anEditOp) + return; + anEditOp->commit(); + } else { + PartSet_OperationSketchBase* aSketchOp = + dynamic_cast(myWorkshop->currentOperation()); + if (aSketchOp) { + aSketchOp->selectionChanged(aSelect); + } + } +} diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index 79379ffc4..f5851100c 100644 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -17,8 +17,6 @@ #include -class QMouseEvent; -class QKeyEvent; class PartSet_Listener; class ModelAPI_Feature; class XGUI_ViewerPrs; @@ -70,26 +68,6 @@ Q_OBJECT void onOperationStopped(ModuleBase_Operation* theOperation); /// SLOT, that is called afetr the popup menu action clicked. void onContextMenuCommand(const QString& theId, bool isChecked); - /// SLOT, that is called by mouse press in the viewer. - /// The mouse released point is sent to the current operation to be processed. - /// \param theEvent the mouse event - void onMousePressed(QMouseEvent* theEvent); - /// SLOT, that is called by mouse release in the viewer. - /// The mouse released point is sent to the current operation to be processed. - /// \param theEvent the mouse event - void onMouseReleased(QMouseEvent* theEvent); - /// SLOT, that is called by mouse move in the viewer. - /// The mouse moved point is sent to the current operation to be processed. - /// \param theEvent the mouse event - void onMouseMoved(QMouseEvent* theEvent); - - /// SLOT, that is called by the key in the viewer is clicked. - /// \param theEvent the mouse event - void onKeyRelease(QKeyEvent* theEvent); - - /// SLOT, that is called by the mouse double click in the viewer. - /// \param theEvent the mouse event - void onMouseDoubleClick(QMouseEvent* theEvent); /// SLOT, to apply to the current viewer the operation /// \param theX the X projection value @@ -129,6 +107,33 @@ Q_OBJECT /// \param the attribute of the feature void onStorePoint2D(ObjectPtr theFeature, const std::string& theAttribute); +protected slots: + /// Called on selection changed event + virtual void onSelectionChanged(); + + /// SLOT, that is called by mouse press in the viewer. + /// The mouse released point is sent to the current operation to be processed. + /// \param theEvent the mouse event + virtual void onMousePressed(QMouseEvent* theEvent); + + /// SLOT, that is called by mouse release in the viewer. + /// The mouse released point is sent to the current operation to be processed. + /// \param theEvent the mouse event + virtual void onMouseReleased(QMouseEvent* theEvent); + + /// SLOT, that is called by mouse move in the viewer. + /// The mouse moved point is sent to the current operation to be processed. + /// \param theEvent the mouse event + virtual void onMouseMoved(QMouseEvent* theEvent); + + /// SLOT, that is called by the mouse double click in the viewer. + /// \param theEvent the mouse event + virtual void onMouseDoubleClick(QMouseEvent* theEvent); + + /// SLOT, that is called by the key in the viewer is clicked. + /// \param theEvent the mouse event + virtual void onKeyRelease(QKeyEvent* theEvent); + protected: /// Creates a new operation /// \param theCmdId the operation name diff --git a/src/PartSet/PartSet_OperationFeatureBase.cpp b/src/PartSet/PartSet_OperationFeatureBase.cpp index 9955fa5f0..458410aba 100644 --- a/src/PartSet/PartSet_OperationFeatureBase.cpp +++ b/src/PartSet/PartSet_OperationFeatureBase.cpp @@ -25,6 +25,8 @@ #include #include #include "ModuleBase_IPropertyPanel.h" +#include "ModuleBase_ISelection.h" +#include "ModuleBase_IViewer.h" #include @@ -59,35 +61,36 @@ CompositeFeaturePtr PartSet_OperationFeatureBase::sketch() const return mySketch; } -void PartSet_OperationFeatureBase::mouseReleased(QMouseEvent* theEvent, Handle(V3d_View) theView, - const std::list& theSelected, - const std::list& /*theHighlighted*/) +void PartSet_OperationFeatureBase::mouseReleased(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer, + ModuleBase_ISelection* theSelection) { - gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theView); + Handle(V3d_View) aView = theViewer->activeView(); + gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView); double aX = aPoint.X(), anY = aPoint.Y(); + QList aSelected = theSelection->getSelected(); - if (theSelected.empty()) { - PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY); + if (aSelected.empty()) { + PartSet_Tools::convertTo2D(aPoint, sketch(), aView, aX, anY); } else { - ModuleBase_ViewerPrs aPrs = theSelected.front(); + ModuleBase_ViewerPrs aPrs = aSelected.first(); const TopoDS_Shape& aShape = aPrs.shape(); if (!aShape.IsNull()) { if (aShape.ShapeType() == TopAbs_VERTEX) { // a point is selected const TopoDS_Vertex& aVertex = TopoDS::Vertex(aShape); if (!aVertex.IsNull()) { aPoint = BRep_Tool::Pnt(aVertex); - PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY); + PartSet_Tools::convertTo2D(aPoint, sketch(), aView, aX, anY); ModuleBase_ModelWidget* aActiveWgt = myPropertyPanel->activeWidget(); PartSet_Tools::setConstraints(sketch(), feature(), aActiveWgt->attributeID(), aX, anY); } } else if (aShape.ShapeType() == TopAbs_EDGE) { // a line is selected - PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY); + PartSet_Tools::convertTo2D(aPoint, sketch(), aView, aX, anY); } } } ObjectPtr aFeature; - if (!theSelected.empty()) { - ModuleBase_ViewerPrs aPrs = theSelected.front(); + if (!aSelected.empty()) { + ModuleBase_ViewerPrs aPrs = aSelected.first(); aFeature = aPrs.object(); } else { aFeature = feature(); // for the widget distance only diff --git a/src/PartSet/PartSet_OperationFeatureBase.h b/src/PartSet/PartSet_OperationFeatureBase.h index a9651e6f8..cde5fb675 100644 --- a/src/PartSet/PartSet_OperationFeatureBase.h +++ b/src/PartSet/PartSet_OperationFeatureBase.h @@ -42,9 +42,8 @@ Q_OBJECT /// \param theView a viewer to have the viewer the eye position /// \param theSelected the list of selected presentations /// \param theHighlighted the list of highlighted presentations - virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView, - const std::list& theSelected, - const std::list& theHighlighted); + virtual void mouseReleased(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer, + ModuleBase_ISelection* theSelection); protected: diff --git a/src/PartSet/PartSet_OperationFeatureCreate.cpp b/src/PartSet/PartSet_OperationFeatureCreate.cpp index 0bc2d9238..c27800065 100644 --- a/src/PartSet/PartSet_OperationFeatureCreate.cpp +++ b/src/PartSet/PartSet_OperationFeatureCreate.cpp @@ -27,6 +27,8 @@ #include #include #include +#include +#include #include @@ -77,11 +79,12 @@ bool PartSet_OperationFeatureCreate::canBeCommitted() const return false; } -void PartSet_OperationFeatureCreate::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView) +void PartSet_OperationFeatureCreate::mouseMoved(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer) { double aX, anY; - gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theView); - PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY); + Handle(V3d_View) aView = theViewer->activeView(); + gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView); + PartSet_Tools::convertTo2D(aPoint, sketch(), aView, aX, anY); setWidgetValue(feature(), aX, anY); flushUpdated(); } @@ -101,37 +104,39 @@ void PartSet_OperationFeatureCreate::keyReleased(const int theKey) } } -void PartSet_OperationFeatureCreate::mouseReleased(QMouseEvent* theEvent, Handle(V3d_View) theView, - const std::list& theSelected, - const std::list& /*theHighlighted*/) +void PartSet_OperationFeatureCreate::mouseReleased(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer, + ModuleBase_ISelection* theSelection) { - gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theView); + Handle(V3d_View) aView = theViewer->activeView(); + gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView); double aX = aPoint.X(), anY = aPoint.Y(); bool isClosedContour = false; - if (theSelected.empty()) { - PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY); + QList aSelected = theSelection->getSelected(); + + if (aSelected.empty()) { + PartSet_Tools::convertTo2D(aPoint, sketch(), aView, aX, anY); } else { - ModuleBase_ViewerPrs aPrs = theSelected.front(); + ModuleBase_ViewerPrs aPrs = aSelected.first(); const TopoDS_Shape& aShape = aPrs.shape(); if (!aShape.IsNull()) { if (aShape.ShapeType() == TopAbs_VERTEX) { // a point is selected const TopoDS_Vertex& aVertex = TopoDS::Vertex(aShape); if (!aVertex.IsNull()) { aPoint = BRep_Tool::Pnt(aVertex); - PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY); + PartSet_Tools::convertTo2D(aPoint, sketch(), aView, aX, anY); ModuleBase_ModelWidget* aActiveWgt = myPropertyPanel->activeWidget(); PartSet_Tools::setConstraints(sketch(), feature(), aActiveWgt->attributeID(), aX, anY); isClosedContour = true; } } else if (aShape.ShapeType() == TopAbs_EDGE) { // a line is selected - PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY); + PartSet_Tools::convertTo2D(aPoint, sketch(), aView, aX, anY); } } } ObjectPtr aFeature; - if (!theSelected.empty()) { - ModuleBase_ViewerPrs aPrs = theSelected.front(); + if (!aSelected.empty()) { + ModuleBase_ViewerPrs aPrs = aSelected.first(); aFeature = aPrs.object(); } else { aFeature = feature(); // for the widget distance only @@ -155,7 +160,7 @@ void PartSet_OperationFeatureCreate::mouseReleased(QMouseEvent* theEvent, Handle void PartSet_OperationFeatureCreate::startOperation() { PartSet_OperationSketchBase::startOperation(); - emit multiSelectionEnabled(false); + //emit multiSelectionEnabled(false); } void PartSet_OperationFeatureCreate::abortOperation() @@ -167,7 +172,7 @@ void PartSet_OperationFeatureCreate::abortOperation() void PartSet_OperationFeatureCreate::stopOperation() { PartSet_OperationSketchBase::stopOperation(); - emit multiSelectionEnabled(true); + //emit multiSelectionEnabled(true); } void PartSet_OperationFeatureCreate::afterCommitOperation() diff --git a/src/PartSet/PartSet_OperationFeatureCreate.h b/src/PartSet/PartSet_OperationFeatureCreate.h index b13b8ece5..bbc83f500 100644 --- a/src/PartSet/PartSet_OperationFeatureCreate.h +++ b/src/PartSet/PartSet_OperationFeatureCreate.h @@ -42,16 +42,15 @@ Q_OBJECT /// Gives the current mouse point in the viewer /// \param thePoint a point clicked in the viewer /// \param theEvent the mouse event - virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView); + virtual void mouseMoved(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer); /// Gives the current selected objects to be processed by the operation /// \param theEvent the mouse event /// \param theView a viewer to have the viewer the eye position /// \param theSelected the list of selected presentations /// \param theHighlighted the list of highlighted presentations - virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView, - const std::list& theSelected, - const std::list& theHighlighted); + virtual void mouseReleased(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer, + ModuleBase_ISelection* theSelection); /// Processes the key pressed in the view /// \param theKey a key value virtual void keyReleased(const int theKey); diff --git a/src/PartSet/PartSet_OperationFeatureEdit.cpp b/src/PartSet/PartSet_OperationFeatureEdit.cpp index 16e2b4437..bc73304dd 100644 --- a/src/PartSet/PartSet_OperationFeatureEdit.cpp +++ b/src/PartSet/PartSet_OperationFeatureEdit.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include @@ -12,6 +13,8 @@ #include #include #include +#include +#include #include @@ -52,62 +55,82 @@ PartSet_OperationFeatureEdit::~PartSet_OperationFeatureEdit() } -void PartSet_OperationFeatureEdit::mousePressed(QMouseEvent* theEvent, Handle(V3d_View) theView, - const std::list& theSelected, - const std::list& theHighlighted) +void PartSet_OperationFeatureEdit::mousePressed(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer, ModuleBase_ISelection* theSelection) { ModuleBase_ModelWidget* aActiveWgt = myPropertyPanel->activeWidget(); if(aActiveWgt && aActiveWgt->isViewerSelector()) { // Almost do nothing, all stuff in on PartSet_OperationFeatureBase::mouseReleased - PartSet_OperationFeatureBase::mousePressed(theEvent, theView, theSelected, theHighlighted); + PartSet_OperationFeatureBase::mousePressed(theEvent, theViewer, theSelection); return; } + QList aSelected = theSelection->getSelected(); + QList aHighlighted = theSelection->getHighlighted(); + bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier); + if (aHasShift && !aHighlighted.empty()) { + foreach (ModuleBase_ViewerPrs aPrs, aHighlighted) { + aSelected.append(aPrs); + } + } ObjectPtr aObject; - if (!theHighlighted.empty()) - aObject = theHighlighted.front().object(); - if (!aObject && !theSelected.empty()) // changed for a constrain - aObject = theSelected.front().object(); + if (!aSelected.empty()) { + aObject = aSelected.first().object(); + } else { + if (!aHighlighted.empty()) + aObject = aHighlighted.first().object(); + } + //if (!theHighlighted.empty()) + // aObject = theHighlighted.front().object(); + //if (!aObject && !theSelected.empty()) // changed for a constrain + // aObject = theSelected.front().object(); FeaturePtr aFeature = ModelAPI_Feature::feature(aObject); - if (!aFeature || aFeature != feature()) { + if (!aFeature || aFeature != feature() || (aSelected.size() > 1)) { if (commit()) { emit featureConstructed(feature(), FM_Deactivation); + // If we have selection and prehilighting with shift pressed + // Then we have to select all these objects and restart as multi edit operfation //bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier); //if (aHasShift && !theHighlighted.empty()) { // QList aSelected; // std::list::const_iterator aIt; // for (aIt = theSelected.cbegin(); aIt != theSelected.cend(); ++aIt) // aSelected.append((*aIt).object()); - /*for (aIt = theHighlighted.cbegin(); aIt != theHighlighted.cend(); ++aIt) { - if (!aSelected.contains((*aIt).object())) - aSelected.append((*aIt).object()); - }*/ - //aSelected.push_back(feature()); - //aSelected.push_back(theHighlighted.front().object()); - //emit setSelection(aSelected); + + // for (aIt = theHighlighted.cbegin(); aIt != theHighlighted.cend(); ++aIt) { + // if (!aSelected.contains((*aIt).object())) + // aSelected.append((*aIt).object()); + // } + // emit setSelection(aSelected); //} else if (aFeature) { - restartOperation(PartSet_OperationFeatureEdit::Type(), aFeature); + std::string anOperationType = + (aSelected.size() > 1) ? + PartSet_OperationFeatureEditMulti::Type() : PartSet_OperationFeatureEdit::Type(); + restartOperation(anOperationType, aFeature); } + //} } - } + } } -void PartSet_OperationFeatureEdit::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView) +void PartSet_OperationFeatureEdit::mouseMoved(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer) { if (!(theEvent->buttons() & Qt::LeftButton)) return; + Handle(V3d_View) aView = theViewer->activeView(); + gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView); - gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theView); + if (theViewer->isSelectionEnabled()) + theViewer->enableSelection(false); - blockSelection(true); + //blockSelection(true); if (myCurPoint.myIsInitialized) { double aCurX, aCurY; - PartSet_Tools::convertTo2D(myCurPoint.myPoint, sketch(), theView, aCurX, aCurY); + PartSet_Tools::convertTo2D(myCurPoint.myPoint, sketch(), aView, aCurX, aCurY); double aX, anY; - PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY); + PartSet_Tools::convertTo2D(aPoint, sketch(), aView, aX, anY); double aDeltaX = aX - aCurX; double aDeltaY = anY - aCurY; @@ -127,29 +150,30 @@ void PartSet_OperationFeatureEdit::mouseMoved(QMouseEvent* theEvent, Handle(V3d_ } void PartSet_OperationFeatureEdit::mouseReleased( - QMouseEvent* theEvent, Handle(V3d_View) theView, - const std::list& theSelected, - const std::list& theHighlighted) + QMouseEvent* theEvent, ModuleBase_IViewer* theViewer, + ModuleBase_ISelection* theSelection) { ModuleBase_ModelWidget* aActiveWgt = 0; if (myPropertyPanel) aActiveWgt = myPropertyPanel->activeWidget(); if(aActiveWgt && aActiveWgt->isViewerSelector()) { // Almost do nothing, all stuff in on PartSet_OperationFeatureBase::mouseReleased - PartSet_OperationFeatureBase::mouseReleased(theEvent, theView, theSelected, theHighlighted); - } else { - blockSelection(false); - } + PartSet_OperationFeatureBase::mouseReleased(theEvent, theViewer, theSelection); + }// else { + //blockSelection(false); + //} + if (!theViewer->isSelectionEnabled()) + theViewer->enableSelection(true); } void PartSet_OperationFeatureEdit::mouseDoubleClick( QMouseEvent* theEvent, Handle_V3d_View theView, - const std::list& theSelected, - const std::list& theHighlighted) + ModuleBase_ISelection* theSelection) { // TODO the functionality is important only for constraint feature. Should be moved in another place - if (!theSelected.empty()) { - ModuleBase_ViewerPrs aFeaturePrs = theSelected.front(); + QList aSelected = theSelection->getSelected(); + if (!aSelected.empty()) { + ModuleBase_ViewerPrs aFeaturePrs = aSelected.first(); if (!aFeaturePrs.owner().IsNull()) { Handle(AIS_DimensionOwner) anOwner = Handle(AIS_DimensionOwner)::DownCast( aFeaturePrs.owner()); @@ -169,36 +193,36 @@ void PartSet_OperationFeatureEdit::mouseDoubleClick( void PartSet_OperationFeatureEdit::startOperation() { PartSet_OperationSketchBase::startOperation(); - emit multiSelectionEnabled(false); + //emit multiSelectionEnabled(false); myCurPoint.clear(); } void PartSet_OperationFeatureEdit::stopOperation() { - emit multiSelectionEnabled(true); + //emit multiSelectionEnabled(true); - blockSelection(false, false); + //blockSelection(false, false); } -void PartSet_OperationFeatureEdit::blockSelection(bool isBlocked, const bool isRestoreSelection) -{ - if (myIsBlockedSelection == isBlocked) - return; - - myIsBlockedSelection = isBlocked; - QList aFeatureList; - aFeatureList.append(feature()); - - if (isBlocked) { - emit setSelection(QList()); - emit stopSelection(aFeatureList, true); - } else { - emit stopSelection(aFeatureList, false); - if (isRestoreSelection) - emit setSelection(aFeatureList); - } -} +//void PartSet_OperationFeatureEdit::blockSelection(bool isBlocked, const bool isRestoreSelection) +//{ +// if (myIsBlockedSelection == isBlocked) +// return; +// +// myIsBlockedSelection = isBlocked; +// QList aFeatureList; +// aFeatureList.append(feature()); +// +// //if (isBlocked) { +// // emit setSelection(QList()); +// // emit stopSelection(aFeatureList, true); +// //} else { +// // emit stopSelection(aFeatureList, false); +// // if (isRestoreSelection) +// // emit setSelection(aFeatureList); +// //} +//} FeaturePtr PartSet_OperationFeatureEdit::createFeature(const bool theFlushMessage, CompositeFeaturePtr theCompositeFeature) diff --git a/src/PartSet/PartSet_OperationFeatureEdit.h b/src/PartSet/PartSet_OperationFeatureEdit.h index 1b741a56a..293c63d95 100644 --- a/src/PartSet/PartSet_OperationFeatureEdit.h +++ b/src/PartSet/PartSet_OperationFeatureEdit.h @@ -11,6 +11,7 @@ #include class QMouseEvent; +class ModuleBase_ISelection; /*! \class PartSet_OperationFeatureEdit @@ -75,21 +76,19 @@ Q_OBJECT /// \param theView a viewer to have the viewer the eye position /// \param theSelected the list of selected presentations /// \param theHighlighted the list of highlighted presentations - virtual void mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView, - const std::list& theSelected, - const std::list& theHighlighted); + virtual void mousePressed(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer, ModuleBase_ISelection* theSelection); + /// Gives the current mouse point in the viewer /// \param theEvent the mouse event /// \param theView a viewer to have the viewer the eye position - virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView); + virtual void mouseMoved(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer); /// Gives the current selected objects to be processed by the operation /// \param thePoint a point clicked in the viewer /// \param theEvent the mouse event /// \param theSelected the list of selected presentations /// \param theHighlighted the list of highlighted presentations - virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView, - const std::list& theSelected, - const std::list& theHighlighted); + virtual void mouseReleased(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer, + ModuleBase_ISelection* theSelection); /// Processes the mouse double click in the point /// \param theEvent the mouse event @@ -97,8 +96,7 @@ Q_OBJECT /// \param theSelected the list of selected presentations /// \param theHighlighted the list of highlighted presentations virtual void mouseDoubleClick(QMouseEvent* theEvent, Handle_V3d_View theView, - const std::list& theSelected, - const std::list& theHighlighted); + ModuleBase_ISelection* theSelection); protected: /// \brief Virtual method called when operation is started @@ -123,7 +121,7 @@ Q_OBJECT /// the internal operation features are to be selected /// \param isBlocked the state whether the operation is blocked or unblocked /// \param isRestoreSelection the state whether the selected objects should be reselected - void blockSelection(bool isBlocked, const bool isRestoreSelection = true); + //void blockSelection(bool isBlocked, const bool isRestoreSelection = true); /// Sends the features void sendFeatures(); diff --git a/src/PartSet/PartSet_OperationFeatureEditMulti.cpp b/src/PartSet/PartSet_OperationFeatureEditMulti.cpp index 9c9805860..7ae6d08d9 100644 --- a/src/PartSet/PartSet_OperationFeatureEditMulti.cpp +++ b/src/PartSet/PartSet_OperationFeatureEditMulti.cpp @@ -8,6 +8,7 @@ #include #include +#include #include @@ -47,11 +48,10 @@ PartSet_OperationFeatureEditMulti::~PartSet_OperationFeatureEditMulti() } -bool isContains(const std::list& theSelected, const ModuleBase_ViewerPrs& thePrs) +bool isContains(const QList& theSelected, const ModuleBase_ViewerPrs& thePrs) { - std::list::const_iterator anIt; - for (anIt = theSelected.cbegin(); anIt != theSelected.cend(); ++anIt) { - if ((*anIt).object() == thePrs.object()) + foreach (ModuleBase_ViewerPrs aPrs, theSelected) { + if (aPrs.object() == thePrs.object()) return true; } return false; @@ -59,8 +59,8 @@ bool isContains(const std::list& theSelected, const Module void PartSet_OperationFeatureEditMulti::initSelection( - const std::list& theSelected, - const std::list& theHighlighted) + const QList& theSelected, + const QList& theHighlighted) { //if (!theHighlighted.empty()) { // // if there is highlighted object, we check whether it is in the list of selected objects @@ -80,17 +80,16 @@ void PartSet_OperationFeatureEditMulti::initSelection( //} else myFeatures = theSelected; // add highlighted elements if they are not selected - std::list::const_iterator anIt; - for (anIt = theHighlighted.cbegin(); anIt != theHighlighted.cend(); ++anIt) { - if (!isContains(myFeatures, (*anIt))) - myFeatures.push_back(*anIt); + foreach (ModuleBase_ViewerPrs aPrs, theHighlighted) { + if (!isContains(myFeatures, aPrs)) + myFeatures.append(aPrs); } // Remove current feature if it is in the list (it will be moved as main feature) FeaturePtr aFea = feature(); - for (anIt = myFeatures.cbegin(); anIt != myFeatures.cend(); ++anIt) { - FeaturePtr aF = ModelAPI_Feature::feature((*anIt).object()); - if (ModelAPI_Feature::feature((*anIt).object()) == feature()) { - myFeatures.erase(anIt); + foreach (ModuleBase_ViewerPrs aPrs, myFeatures) { + FeaturePtr aF = ModelAPI_Feature::feature(aPrs.object()); + if (ModelAPI_Feature::feature(aPrs.object()) == feature()) { + myFeatures.removeOne(aPrs); break; } } @@ -101,27 +100,25 @@ CompositeFeaturePtr PartSet_OperationFeatureEditMulti::sketch() const return mySketch; } -void PartSet_OperationFeatureEditMulti::mousePressed( - QMouseEvent* theEvent, Handle(V3d_View) theView, - const std::list& /*theSelected*/, - const std::list& theHighlighted) +void PartSet_OperationFeatureEditMulti::mousePressed(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer, ModuleBase_ISelection* theSelection) { } -void PartSet_OperationFeatureEditMulti::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView) +void PartSet_OperationFeatureEditMulti::mouseMoved(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer) { if (!(theEvent->buttons() & Qt::LeftButton)) return; - gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theView); + Handle(V3d_View) aView = theViewer->activeView(); + gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView); - blockSelection(true); + //blockSelection(true); if (myCurPoint.myIsInitialized) { double aCurX, aCurY; - PartSet_Tools::convertTo2D(myCurPoint.myPoint, sketch(), theView, aCurX, aCurY); + PartSet_Tools::convertTo2D(myCurPoint.myPoint, sketch(), aView, aCurX, aCurY); double aX, anY; - PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY); + PartSet_Tools::convertTo2D(aPoint, sketch(), aView, aX, anY); double aDeltaX = aX - aCurX; double aDeltaY = anY - aCurY; @@ -130,10 +127,8 @@ void PartSet_OperationFeatureEditMulti::mouseMoved(QMouseEvent* theEvent, Handle SketchPlugin_Feature>(feature()); aSketchFeature->move(aDeltaX, aDeltaY); - std::list::const_iterator anIt = myFeatures.begin(), - aLast = myFeatures.end(); - for (; anIt != aLast; anIt++) { - ObjectPtr aObject = (*anIt).object(); + foreach (ModuleBase_ViewerPrs aPrs, myFeatures) { + ObjectPtr aObject = aPrs.object(); if (!aObject || aObject == feature()) continue; FeaturePtr aFeature = ModelAPI_Feature::feature(aObject); @@ -150,16 +145,12 @@ void PartSet_OperationFeatureEditMulti::mouseMoved(QMouseEvent* theEvent, Handle } void PartSet_OperationFeatureEditMulti::mouseReleased( - QMouseEvent* theEvent, Handle(V3d_View) theView, - const std::list& /*theSelected*/, - const std::list& /*theHighlighted*/) + QMouseEvent* theEvent, ModuleBase_IViewer* theViewer, + ModuleBase_ISelection* theSelection) { if (commit()) { - std::list aFeatures = myFeatures; - std::list::const_iterator anIt = aFeatures.begin(), aLast = - aFeatures.end(); - for (; anIt != aLast; anIt++) { - ObjectPtr aFeature = (*anIt).object(); + foreach (ModuleBase_ViewerPrs aPrs, myFeatures) { + ObjectPtr aFeature = aPrs.object(); if (aFeature) { emit featureConstructed(aFeature, FM_Deactivation); } @@ -170,54 +161,51 @@ void PartSet_OperationFeatureEditMulti::mouseReleased( void PartSet_OperationFeatureEditMulti::startOperation() { PartSet_OperationSketchBase::startOperation(); - emit multiSelectionEnabled(false); + //emit multiSelectionEnabled(false); - blockSelection(true); + //blockSelection(true); myCurPoint.clear(); } void PartSet_OperationFeatureEditMulti::stopOperation() { - emit multiSelectionEnabled(true); + //emit multiSelectionEnabled(true); - blockSelection(false, true); + //blockSelection(false, true); myFeatures.clear(); } -void PartSet_OperationFeatureEditMulti::blockSelection(bool isBlocked, - const bool isRestoreSelection) -{ - if (myIsBlockedSelection == isBlocked) - return; - - myIsBlockedSelection = isBlocked; - QList aFeatureList; - std::list::const_iterator anIt = myFeatures.begin(), aLast = - myFeatures.end(); - /*for(; anIt != aLast; anIt++) - aFeatureList.append((*anIt).feature());*/ - if (isBlocked) { - emit setSelection(QList()); - emit stopSelection(aFeatureList, true); - } else { - emit stopSelection(aFeatureList, false); - if (isRestoreSelection) { - emit setSelection(aFeatureList); - } - } -} +//void PartSet_OperationFeatureEditMulti::blockSelection(bool isBlocked, +// const bool isRestoreSelection) +//{ +// if (myIsBlockedSelection == isBlocked) +// return; +// +// myIsBlockedSelection = isBlocked; +// QList aFeatureList; +//// std::list::const_iterator anIt = myFeatures.begin(), aLast = +//// myFeatures.end(); +// /*for(; anIt != aLast; anIt++) +// aFeatureList.append((*anIt).feature());*/ +// //if (isBlocked) { +// // emit setSelection(QList()); +// // emit stopSelection(aFeatureList, true); +// //} else { +// // emit stopSelection(aFeatureList, false); +// // if (isRestoreSelection) { +// // emit setSelection(aFeatureList); +// // } +// //} +//} void PartSet_OperationFeatureEditMulti::sendFeatures() { static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_MOVED); - std::list aFeatures; - std::list::const_iterator anIt = myFeatures.begin(), aLast = - myFeatures.end(); - for (; anIt != aLast; anIt++) { - ObjectPtr aFeature = (*anIt).object(); + foreach (ModuleBase_ViewerPrs aPrs, myFeatures) { + ObjectPtr aFeature = aPrs.object(); if (!aFeature) continue; diff --git a/src/PartSet/PartSet_OperationFeatureEditMulti.h b/src/PartSet/PartSet_OperationFeatureEditMulti.h index 44de5817b..3454bdd5b 100644 --- a/src/PartSet/PartSet_OperationFeatureEditMulti.h +++ b/src/PartSet/PartSet_OperationFeatureEditMulti.h @@ -9,6 +9,7 @@ #include #include +#include class QMouseEvent; @@ -73,8 +74,8 @@ Q_OBJECT /// Initialisation of operation with preliminary selection /// \param theSelected the list of selected presentations /// \param theHighlighted the list of highlighted presentations - virtual void initSelection(const std::list& theSelected, - const std::list& theHighlighted); + virtual void initSelection(const QList& theSelected, + const QList& theHighlighted); /// Returns the operation sketch feature /// \returns the sketch instance @@ -85,21 +86,21 @@ Q_OBJECT /// \param theView a viewer to have the viewer the eye position /// \param theSelected the list of selected presentations /// \param theHighlighted the list of highlighted presentations - virtual void mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView, - const std::list& theSelected, - const std::list& theHighlighted); + virtual void mousePressed(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer, ModuleBase_ISelection* theSelection); + /// Gives the current mouse point in the viewer /// \param theEvent the mouse event /// \param theView a viewer to have the viewer the eye position - virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView); + virtual void mouseMoved(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer); + /// Gives the current selected objects to be processed by the operation /// \param thePoint a point clicked in the viewer /// \param theEvent the mouse event /// \param theSelected the list of selected presentations /// \param theHighlighted the list of highlighted presentations - virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView, - const std::list& theSelected, - const std::list& theHighlighted); + virtual void mouseReleased(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer, + ModuleBase_ISelection* theSelection); + protected: /// \brief Virtual method called when operation is started /// Virtual method called when operation started (see start() method for more description) @@ -116,14 +117,14 @@ Q_OBJECT /// the internal operation features are to be selected /// \param isBlocked the state whether the operation is blocked or unblocked /// \param isRestoreSelection the state whether the selected objects should be reselected - void blockSelection(bool isBlocked, const bool isRestoreSelection = true); + //void blockSelection(bool isBlocked, const bool isRestoreSelection = true); /// Sends the features void sendFeatures(); private: CompositeFeaturePtr mySketch; ///< the sketch feature - std::list myFeatures; ///< the features to apply the edit operation + QList myFeatures; ///< the features to apply the edit operation Point myCurPoint; ///< the current 3D point clicked or moved bool myIsBlockedSelection; ///< the state of the last state of selection blocked signal }; diff --git a/src/PartSet/PartSet_OperationSketch.cpp b/src/PartSet/PartSet_OperationSketch.cpp index 6deab5b28..7bfddff30 100644 --- a/src/PartSet/PartSet_OperationSketch.cpp +++ b/src/PartSet/PartSet_OperationSketch.cpp @@ -22,6 +22,8 @@ #include #include +#include +#include #include #include @@ -53,49 +55,63 @@ CompositeFeaturePtr PartSet_OperationSketch::sketch() const return boost::dynamic_pointer_cast(feature()); } -void PartSet_OperationSketch::mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView, - const std::list& theSelected, - const std::list& theHighlighted) +void PartSet_OperationSketch::mousePressed(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer, ModuleBase_ISelection* theSelection) { if (hasSketchPlane()) { // if shift button is pressed and there are some already selected objects, the operation should // not be started. We just want to combine some selected objects. bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier); - if (aHasShift && theSelected.size() > 0) - return; - - if (theHighlighted.size() == 1) { - ObjectPtr aFeature = theHighlighted.front().object(); + QList aSelected = theSelection->getSelected(); + QList aHighlighted = theSelection->getHighlighted(); + //if (aHasShift && (aSelected.size() > 0)) { + foreach(ModuleBase_ViewerPrs aPrs, aHighlighted) + aSelected.append(aPrs); + //} + //if (aHasShift && aSelected.size() > 0) + // return; + + if (aSelected.size() > 0) { + ObjectPtr aFeature = aSelected.first().object(); if (aFeature) { std::string anOperationType = - (theSelected.size() > 1) ? + (aSelected.size() > 1) ? PartSet_OperationFeatureEditMulti::Type() : PartSet_OperationFeatureEdit::Type(); + //theViewer->enableSelection(false); restartOperation(anOperationType, aFeature); } - } else - myFeatures = theHighlighted; - - } else { - if (!theHighlighted.empty()) { - ModuleBase_ViewerPrs aPrs = theHighlighted.front(); - const TopoDS_Shape& aShape = aPrs.shape(); - if (!aShape.IsNull()) - setSketchPlane(aShape); - } + } //else + //myFeatures = aSelected; + + } +} + + +void PartSet_OperationSketch::selectionChanged(ModuleBase_ISelection* theSelection) +{ + if (hasSketchPlane()) + return; + + QList aSelected = theSelection->getSelected(); + if (!aSelected.empty()) { + ModuleBase_ViewerPrs aPrs = aSelected.first(); + const TopoDS_Shape& aShape = aPrs.shape(); + if (!aShape.IsNull()) + setSketchPlane(aShape); } } -void PartSet_OperationSketch::mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView, - const std::list& theSelected, - const std::list& theHighlighted) + +void PartSet_OperationSketch::mouseReleased(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer, + ModuleBase_ISelection* theSelection) { + QList aSelected = theSelection->getSelected(); if (hasSketchPlane()) { /// TODO: OCC bug: 25034 - the highlighted list should be filled not only for AIS_Shape /// but for other IO, for example constraint dimensions. /// It is empty and we have to use the process mouse release to start edition operation /// for these objects - if (theSelected.size() == 1) { - ObjectPtr aObject = theSelected.front().object(); + if (aSelected.size() == 1) { + ObjectPtr aObject = aSelected.first().object(); if (aObject) { restartOperation(PartSet_OperationFeatureEdit::Type(), aObject); } @@ -103,13 +119,14 @@ void PartSet_OperationSketch::mouseReleased(QMouseEvent* theEvent, Handle_V3d_Vi } } -void PartSet_OperationSketch::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView) +void PartSet_OperationSketch::mouseMoved(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer) { if (!hasSketchPlane() || !(theEvent->buttons() & Qt::LeftButton) || myFeatures.empty()) return; if (myFeatures.size() != 1) { - FeaturePtr aFeature = PartSet_Tools::nearestFeature(theEvent->pos(), theView, feature(), + Handle(V3d_View) aView = theViewer->activeView(); + FeaturePtr aFeature = PartSet_Tools::nearestFeature(theEvent->pos(), aView, feature(), myFeatures); if (aFeature) restartOperation(PartSet_OperationFeatureEditMulti::Type(), aFeature); diff --git a/src/PartSet/PartSet_OperationSketch.h b/src/PartSet/PartSet_OperationSketch.h index d3ede8b3d..47601096f 100644 --- a/src/PartSet/PartSet_OperationSketch.h +++ b/src/PartSet/PartSet_OperationSketch.h @@ -12,6 +12,7 @@ #include #include +#include class Handle_AIS_InteractiveObject; @@ -50,22 +51,20 @@ Q_OBJECT /// \param theView a viewer to have the viewer the eye position /// \param theSelected the list of selected presentations /// \param theHighlighted the list of highlighted presentations - virtual void mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView, - const std::list& theSelected, - const std::list& theHighlighted); + virtual void mousePressed(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer, ModuleBase_ISelection* theSelection); + /// Processes the mouse release in the point /// \param theEvent the mouse event /// \param theView a viewer to have the viewer the eye position /// \param theSelected the list of selected presentations /// \param theHighlighted the list of highlighted presentations - virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView, - const std::list& theSelected, - const std::list& theHighlighted); + virtual void mouseReleased(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer, + ModuleBase_ISelection* theSelection); /// Gives the current mouse point in the viewer /// \param thePoint a point clicked in the viewer /// \param theEvent the mouse event - virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView); + virtual void mouseMoved(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer); /// Returns the list of the nested features /// \return the list of subfeatures @@ -88,6 +87,9 @@ Q_OBJECT /// Set the plane to the current sketch /// \param theShape the shape void setSketchPlane(const TopoDS_Shape& theShape); + + /// Called on selection changed when the operation is active + virtual void selectionChanged(ModuleBase_ISelection* theSelection); /// If operation needs to redisplay its result during operation /// then this method has to return True @@ -111,7 +113,7 @@ signals: virtual void afterCommitOperation(); private: - std::list myFeatures; ///< the features to apply the edit operation + QList myFeatures; ///< the features to apply the edit operation }; #endif diff --git a/src/PartSet/PartSet_OperationSketchBase.cpp b/src/PartSet/PartSet_OperationSketchBase.cpp index d8cd8ec7e..3ca38de90 100644 --- a/src/PartSet/PartSet_OperationSketchBase.cpp +++ b/src/PartSet/PartSet_OperationSketchBase.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include @@ -60,25 +61,24 @@ FeaturePtr PartSet_OperationSketchBase::createFeature(const bool theFlushMessage return myFeature; } -void PartSet_OperationSketchBase::mousePressed( - QMouseEvent* theEvent, Handle_V3d_View theView, - const std::list& theSelected, - const std::list& theHighlighted) +void PartSet_OperationSketchBase::mousePressed(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer, ModuleBase_ISelection* theSelection) { } void PartSet_OperationSketchBase::mouseReleased( - QMouseEvent* theEvent, Handle_V3d_View theView, - const std::list& theSelected, - const std::list& theHighlighted) + QMouseEvent* theEvent, ModuleBase_IViewer* theViewer, + ModuleBase_ISelection* theSelection) { } -void PartSet_OperationSketchBase::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView) +void PartSet_OperationSketchBase::mouseMoved(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer) { } void PartSet_OperationSketchBase::mouseDoubleClick( QMouseEvent* theEvent, Handle_V3d_View theView, - const std::list& theSelected, - const std::list& theHighlighted) + ModuleBase_ISelection* theSelection) +{ +} + +void PartSet_OperationSketchBase::selectionChanged(ModuleBase_ISelection* theSelection) { } @@ -103,11 +103,11 @@ void PartSet_OperationSketchBase::activateByPreselection() return; ModuleBase_ModelWidget* aActiveWgt = myPropertyPanel->activeWidget(); if ((myPreSelection.size() > 0) && aActiveWgt) { - const ModuleBase_ViewerPrs& aPrs = myPreSelection.front(); + const ModuleBase_ViewerPrs& aPrs = myPreSelection.first(); ModuleBase_WidgetValueFeature aValue; aValue.setObject(aPrs.object()); if (aActiveWgt->setValue(&aValue)) { - myPreSelection.remove(aPrs); + myPreSelection.removeOne(aPrs); if(isValid()) { //myActiveWidget = NULL; commit(); diff --git a/src/PartSet/PartSet_OperationSketchBase.h b/src/PartSet/PartSet_OperationSketchBase.h index c7d639348..5de7b7330 100644 --- a/src/PartSet/PartSet_OperationSketchBase.h +++ b/src/PartSet/PartSet_OperationSketchBase.h @@ -27,6 +27,8 @@ class Handle_V3d_View; class QMouseEvent; class GeomAPI_Shape; class ModuleBase_ViewerPrs; +class ModuleBase_ISelection; +class ModuleBase_IViewer; /*! \class PartSet_OperationSketchBase @@ -69,23 +71,20 @@ Q_OBJECT /// \param theView a viewer to have the viewer the eye position /// \param theSelected the list of selected presentations /// \param theHighlighted the list of highlighted presentations - virtual void mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView, - const std::list& theSelected, - const std::list& theHighlighted); + virtual void mousePressed(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer, ModuleBase_ISelection* theSelection); /// Processes the mouse release in the point /// \param theEvent the mouse event /// \param theView a viewer to have the viewer the eye position /// \param theSelected the list of selected presentations /// \param theHighlighted the list of highlighted presentations - virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView, - const std::list& theSelected, - const std::list& theHighlighted); + virtual void mouseReleased(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer, + ModuleBase_ISelection* theSelection); /// Processes the mouse move in the point /// \param theEvent the mouse event /// \param theView a viewer to have the viewer the eye position - virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView); + virtual void mouseMoved(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer); /// Processes the mouse double click in the point /// \param theEvent the mouse event @@ -93,8 +92,11 @@ Q_OBJECT /// \param theSelected the list of selected presentations /// \param theHighlighted the list of highlighted presentations virtual void mouseDoubleClick(QMouseEvent* theEvent, Handle_V3d_View theView, - const std::list& theSelected, - const std::list& theHighlighted); + ModuleBase_ISelection* theSelection); + + + /// Called on selection changed when the operation is active + virtual void selectionChanged(ModuleBase_ISelection* theSelection); /// Emits a signal about the operation start. This signal has an information about the feature. /// If the provided feature is empty, the current operation feature is used. @@ -123,7 +125,7 @@ signals: /// signal to enable/disable multi selection in the viewer /// \param theEnabled the boolean state - void multiSelectionEnabled(bool theEnabled); + //void multiSelectionEnabled(bool theEnabled); /// signal to enable/disable selection in the viewer /// \param theFeatures a list of features to be disabled diff --git a/src/PartSet/PartSet_Tools.cpp b/src/PartSet/PartSet_Tools.cpp index 892f610a0..74a83734c 100644 --- a/src/PartSet/PartSet_Tools.cpp +++ b/src/PartSet/PartSet_Tools.cpp @@ -139,21 +139,17 @@ void PartSet_Tools::convertTo3D(const double theX, const double theY, FeaturePtr FeaturePtr PartSet_Tools::nearestFeature(QPoint thePoint, Handle_V3d_View theView, FeaturePtr theSketch, - const std::list& theFeatures) + const QList& theFeatures) { double aX, anY; gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(thePoint, theView); PartSet_Tools::convertTo2D(aPoint, theSketch, theView, aX, anY); FeaturePtr aFeature; - std::list::const_iterator anIt = theFeatures.begin(), aLast = theFeatures - .end(); - FeaturePtr aDeltaFeature; double aMinDelta = -1; ModuleBase_ViewerPrs aPrs; - for (; anIt != aLast; anIt++) { - aPrs = *anIt; + foreach (ModuleBase_ViewerPrs aPrs, theFeatures) { if (!aPrs.object()) continue; boost::shared_ptr aSketchFeature = boost::dynamic_pointer_cast< diff --git a/src/PartSet/PartSet_Tools.h b/src/PartSet/PartSet_Tools.h index 160814747..872102d8b 100644 --- a/src/PartSet/PartSet_Tools.h +++ b/src/PartSet/PartSet_Tools.h @@ -10,13 +10,12 @@ #include #include +#include #include #include -#include - class Handle_V3d_View; class ModuleBase_ViewerPrs; class GeomDataAPI_Point2D; @@ -59,7 +58,7 @@ class PARTSET_EXPORT PartSet_Tools /// \param theSketch the sketch feature /// \param theFeatures the list of selected presentations static FeaturePtr nearestFeature(QPoint thePoint, Handle_V3d_View theView, FeaturePtr theSketch, - const std::list& theFeatures); + const QList& theFeatures); /// Returns pointer to the root document. static boost::shared_ptr document(); diff --git a/src/PartSet/PartSet_Validators.cpp b/src/PartSet/PartSet_Validators.cpp index d464e85ab..7a976bda3 100644 --- a/src/PartSet/PartSet_Validators.cpp +++ b/src/PartSet/PartSet_Validators.cpp @@ -9,17 +9,15 @@ #include #include #include +#include #include int shapesNbPoints(const ModuleBase_ISelection* theSelection) { - std::list aList = theSelection->getSelected(); - std::list::iterator it; - ModuleBase_ViewerPrs aPrs; + QList aList = theSelection->getSelected(); int aCount = 0; - for (it = aList.begin(); it != aList.end(); ++it) { - aPrs = *it; + foreach (ModuleBase_ViewerPrs aPrs, aList) { const TopoDS_Shape& aShape = aPrs.shape(); if (!aShape.IsNull()) { if (aShape.ShapeType() == TopAbs_VERTEX) @@ -31,12 +29,9 @@ int shapesNbPoints(const ModuleBase_ISelection* theSelection) int shapesNbLines(const ModuleBase_ISelection* theSelection) { - std::list aList = theSelection->getSelected(); - std::list::iterator it; - ModuleBase_ViewerPrs aPrs; + QList aList = theSelection->getSelected(); int aCount = 0; - for (it = aList.begin(); it != aList.end(); ++it) { - aPrs = *it; + foreach(ModuleBase_ViewerPrs aPrs, aList) { const TopoDS_Shape& aShape = aPrs.shape(); if (!aShape.IsNull()) { if (aShape.ShapeType() == TopAbs_EDGE) { @@ -78,12 +73,10 @@ bool PartSet_ParallelValidator::isValid(const ModuleBase_ISelection* theSelectio bool PartSet_RadiusValidator::isValid(const ModuleBase_ISelection* theSelection) const { - std::list aList = theSelection->getSelected(); - std::list::iterator it; + QList aList = theSelection->getSelected(); ModuleBase_ViewerPrs aPrs; int aCount = 0; - for (it = aList.begin(); it != aList.end(); ++it) { - aPrs = *it; + foreach (ModuleBase_ViewerPrs aPrs, aList) { const TopoDS_Shape& aShape = aPrs.shape(); if (!aShape.IsNull()) { if (aShape.ShapeType() == TopAbs_EDGE) { diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index 736de32d2..dfbb75db5 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -239,7 +239,7 @@ void XGUI_Displayer::setSelected(const QList& theResults, const bool if (anObj) { Handle(AIS_InteractiveObject) anAIS = anObj->impl(); if (!anAIS.IsNull()) - aContext->AddOrRemoveSelected(anAIS, false); + aContext->SetSelected(anAIS, false); } } if (isUpdateViewer) diff --git a/src/XGUI/XGUI_Selection.cpp b/src/XGUI/XGUI_Selection.cpp index 1b91cb3dc..7ef11f4f6 100644 --- a/src/XGUI/XGUI_Selection.cpp +++ b/src/XGUI/XGUI_Selection.cpp @@ -19,10 +19,10 @@ XGUI_Selection::XGUI_Selection(XGUI_Workshop* theWorkshop) { } -std::list XGUI_Selection::getSelected(int theShapeTypeToSkip) const +QList XGUI_Selection::getSelected(int theShapeTypeToSkip) const { std::set aPrsFeatures; - std::list aPresentations; + QList aPresentations; XGUI_Displayer* aDisplayer = myWorkshop->displayer(); Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext(); @@ -44,15 +44,15 @@ std::list XGUI_Selection::getSelected(int theShapeTypeToSk } Handle(SelectMgr_EntityOwner) anOwner = aContext->SelectedOwner(); aPrs.setOwner(anOwner); - aPresentations.push_back(aPrs); + aPresentations.append(aPrs); } return aPresentations; } -std::list XGUI_Selection::getHighlighted(int theShapeTypeToSkip) const +QList XGUI_Selection::getHighlighted(int theShapeTypeToSkip) const { std::set aPrsFeatures; - std::list aPresentations; + QList aPresentations; XGUI_Displayer* aDisplayer = myWorkshop->displayer(); Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext(); diff --git a/src/XGUI/XGUI_Selection.h b/src/XGUI/XGUI_Selection.h index 5f399a7ee..4868a9a80 100644 --- a/src/XGUI/XGUI_Selection.h +++ b/src/XGUI/XGUI_Selection.h @@ -16,8 +16,6 @@ #include #include -#include - class XGUI_Workshop; class XGUI_EXPORT XGUI_Selection : public ModuleBase_ISelection @@ -28,12 +26,12 @@ class XGUI_EXPORT XGUI_Selection : public ModuleBase_ISelection /// Returns a list of viewer selected presentations /// \param theShapeTypeToSkip the shapes with this type will be skipped during the result list build /// \return list of presentations - virtual std::list getSelected(int theShapeTypeToSkip = -1) const; + virtual QList getSelected(int theShapeTypeToSkip = -1) const; /// Returns a list of viewer highlited presentations /// \param theShapeTypeToSkip the shapes with this type will be skipped during the result list build /// \return list of presentations - virtual std::list getHighlighted(int theShapeTypeToSkip = -1) const; + virtual QList getHighlighted(int theShapeTypeToSkip = -1) const; /** * Returns list of currently selected objects diff --git a/src/XGUI/XGUI_ViewWindow.cpp b/src/XGUI/XGUI_ViewWindow.cpp index 2d2b4cc1c..b64386288 100644 --- a/src/XGUI/XGUI_ViewWindow.cpp +++ b/src/XGUI/XGUI_ViewWindow.cpp @@ -175,7 +175,9 @@ XGUI_ViewWindow::XGUI_ViewWindow(XGUI_Viewer* theViewer, V3d_TypeOfView theType) myEventStarted(false), myIsActive(false), myLastState(WindowNormalState), - myOperation(NOTHING) + myOperation(NOTHING), + myGripWgt(0), + myPicture(0) { mySelectedPoint = gp_Pnt(0., 0., 0.); setFrameStyle(QFrame::Raised); -- 2.39.2