ModuleBase.h
ModuleBase_ActionInfo.h
ModuleBase_ActionType.h
+ ModuleBase_BRepOwner.h
ModuleBase_Definitions.h
ModuleBase_DoubleSpinBox.h
ModuleBase_Events.h
ModuleBase_IWidgetCreator.h
ModuleBase_IWorkshop.h
ModuleBase_LabelValue.h
+ ModuleBase_ListView.h
ModuleBase_ModelWidget.h
ModuleBase_Operation.h
ModuleBase_OperationAction.h
ModuleBase_IViewer.h
ModuleBase_IWorkshop.h
ModuleBase_LabelValue.h
+ ModuleBase_ListView.h
ModuleBase_ModelDialogWidget.h
ModuleBase_ModelWidget.h
ModuleBase_Operation.h
SET(PROJECT_SOURCES
ModuleBase_ActionInfo.cpp
+ ModuleBase_BRepOwner.cpp
ModuleBase_DoubleSpinBox.cpp
ModuleBase_Filter.cpp
ModuleBase_FilterValidated.cpp
ModuleBase_IWidgetCreator.cpp
ModuleBase_IWorkshop.cpp
ModuleBase_LabelValue.cpp
+ ModuleBase_ListView.cpp
ModuleBase_ModelWidget.cpp
ModuleBase_Operation.cpp
ModuleBase_OperationAction.cpp
ActionEnter,
ActionEscape,
ActionDelete,
+ ActionSelection,
ActionUndo,
ActionRedo
};
--- /dev/null
+// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#include "ModuleBase_BRepOwner.h"
+
+IMPLEMENT_STANDARD_RTTIEXT(ModuleBase_BRepOwner, StdSelect_BRepOwner);
--- /dev/null
+// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#ifndef ModuleBase_BRepOwner_H
+#define ModuleBase_BRepOwner_H
+
+#include "ModuleBase.h"
+
+#include <Standard_DefineHandle.hxx>
+#include <StdSelect_BRepOwner.hxx>
+
+#include <QMap>
+
+DEFINE_STANDARD_HANDLE(ModuleBase_BRepOwner, StdSelect_BRepOwner)
+
+/**
+* \ingroup GUI
+* A redefinition of standard BRep Owner in order to provide specific selection
+* of CompSolid objects. This owner is created only for selection mode TopAbs_COMPSOLID
+*/
+class ModuleBase_BRepOwner: public StdSelect_BRepOwner
+{
+public:
+ /// Constructor
+ /// \param aShape an owner shape
+ /// \param aPriority drawig priority
+ /// \param ComesFromDecomposition decomposition flag
+ ModuleBase_BRepOwner(const TopoDS_Shape& aShape,
+ const Standard_Integer aPriority = 0,
+ const Standard_Boolean ComesFromDecomposition = Standard_False)
+ : StdSelect_BRepOwner(aShape, aPriority, ComesFromDecomposition) {}
+
+ /// Highlight the presentation with the given color
+ /// \param aPM a presentations manager
+ /// \param theStyle a style of presentation
+ /// \param theMode a drawing mode
+ virtual void HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& aPM,
+ const Handle(Graphic3d_HighlightStyle)& theStyle, const Standard_Integer theMode = 0)
+ {
+ Selectable()->HilightOwnerWithColor(aPM, theStyle, this);
+ }
+
+ DEFINE_STANDARD_RTTIEXT(ModuleBase_BRepOwner, StdSelect_BRepOwner)
+};
+
+#endif
\ No newline at end of file
/// Remove default selection filters of the module from the current viewer
virtual void deactivateSelectionFilters() {}
+ /// Update selection filters depending on the module active controls
+ virtual void updateActiveSelectionFilters() {}
+
/// Stores the current selection
virtual void storeSelection() {}
--- /dev/null
+// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#include "ModuleBase_ListView.h"
+#include "ModuleBase_Tools.h"
+
+#include <QAction>
+#include <QApplication>
+#include <QClipboard>
+#include <QListWidget>
+#include <QWidget>
+
+const int ATTRIBUTE_SELECTION_INDEX_ROLE = Qt::UserRole + 1;
+
+/**
+* Customization of a List Widget to make it to be placed on full width of container
+*/
+class CustomListWidget : public QListWidget
+{
+public:
+ /// Constructor
+ /// \param theParent a parent widget
+ CustomListWidget(QWidget* theParent)
+ : QListWidget(theParent)
+ {
+ }
+
+ /// Redefinition of virtual method
+ virtual QSize sizeHint() const
+ {
+ int aHeight = 2*QFontMetrics(font()).height();
+ QSize aSize = QListWidget::sizeHint();
+ return QSize(aSize.width(), aHeight);
+ }
+
+ /// Redefinition of virtual method
+ virtual QSize minimumSizeHint() const
+ {
+ int aHeight = 4/*2*/*QFontMetrics(font()).height();
+ QSize aSize = QListWidget::minimumSizeHint();
+ return QSize(aSize.width(), aHeight);
+ }
+
+#ifndef WIN32
+// The code is necessary only for Linux because
+//it can not update viewport on widget resize
+protected:
+ void resizeEvent(QResizeEvent* theEvent)
+ {
+ QListWidget::resizeEvent(theEvent);
+ QTimer::singleShot(5, viewport(), SLOT(repaint()));
+ }
+#endif
+};
+
+//********************************************************************
+ModuleBase_ListView::ModuleBase_ListView(QWidget* theParent, const QString& theObjectName,
+ const QString& theToolTip)
+{
+ myListControl = new CustomListWidget(theParent);
+
+ myListControl->setObjectName(theObjectName);
+ myListControl->setToolTip(theToolTip);
+ myListControl->setSelectionMode(QAbstractItemView::ExtendedSelection);
+
+ myCopyAction = ModuleBase_Tools::createAction(QIcon(":pictures/copy.png"), tr("Copy"),
+ theParent, this, SLOT(onCopyItem()));
+ myCopyAction->setShortcut(QKeySequence::Copy);
+ myCopyAction->setEnabled(false);
+ myListControl->addAction(myCopyAction);
+
+ myDeleteAction = ModuleBase_Tools::createAction(QIcon(":pictures/delete.png"), tr("Delete"),
+ theParent, this, SIGNAL(deleteActionClicked()));
+ myDeleteAction->setEnabled(false);
+ myListControl->addAction(myDeleteAction);
+
+ myListControl->setContextMenuPolicy(Qt::ActionsContextMenu);
+ connect(myListControl, SIGNAL(itemSelectionChanged()), SLOT(onListSelection()));
+}
+
+//********************************************************************
+void ModuleBase_ListView::addItem(const QString& theTextValue, const int theIndex)
+{
+ QListWidgetItem* anItem = new QListWidgetItem(theTextValue, myListControl);
+ anItem->setData(ATTRIBUTE_SELECTION_INDEX_ROLE, theIndex);
+ myListControl->addItem(anItem);
+}
+
+//********************************************************************
+void ModuleBase_ListView::getSelectedIndices(std::set<int>& theIndices)
+{
+ QList<QListWidgetItem*> aItems = myListControl->selectedItems();
+ foreach(QListWidgetItem* anItem, aItems) {
+ int anIndex = anItem->data(ATTRIBUTE_SELECTION_INDEX_ROLE).toInt();
+ if (theIndices.find(anIndex) == theIndices.end())
+ theIndices.insert(anIndex);
+ }
+}
+
+//********************************************************************
+void ModuleBase_ListView::removeSelectedItems()
+{
+ QList<QListWidgetItem*> aItems = myListControl->selectedItems();
+ foreach(QListWidgetItem* anItem, aItems)
+ myListControl->takeItem(myListControl->row(anItem));
+}
+
+//********************************************************************
+void ModuleBase_ListView::removeItems(std::set<int>& theIndices)
+{
+ QList<QListWidgetItem*> aItems;
+ for (int i = 0; i < myListControl->count(); i++) {
+ QListWidgetItem* anItem = myListControl->item(i);
+ int anIndex = anItem->data(ATTRIBUTE_SELECTION_INDEX_ROLE).toInt();
+ if (theIndices.find(anIndex) != theIndices.end())
+ aItems.append(anItem);
+ }
+ foreach(QListWidgetItem* anItem, aItems)
+ myListControl->takeItem(myListControl->row(anItem));
+}
+
+//********************************************************************
+void ModuleBase_ListView::restoreSelection(const QModelIndexList& theIndices)
+{
+ int aRows = myListControl->model()->rowCount();
+ if (aRows > 0) {
+ foreach(QModelIndex aIndex, theIndices) {
+ if (aIndex.row() < aRows)
+ myListControl->selectionModel()->select(aIndex, QItemSelectionModel::Select);
+ else {
+ QModelIndex aIdx = myListControl->model()->index(aRows - 1, 0);
+ myListControl->selectionModel()->select(aIdx, QItemSelectionModel::Select);
+ }
+ }
+ }
+}
+
+//********************************************************************
+void ModuleBase_ListView::onCopyItem()
+{
+ QList<QListWidgetItem*> aItems = myListControl->selectedItems();
+ QString aRes;
+ foreach(QListWidgetItem* aItem, aItems) {
+ if (!aRes.isEmpty())
+ aRes += "\n";
+ aRes += aItem->text();
+ }
+ if (!aRes.isEmpty()) {
+ QClipboard* aClipboard = QApplication::clipboard();
+ aClipboard->setText(aRes);
+ }
+}
+
+//********************************************************************
+void ModuleBase_ListView::onListSelection()
+{
+ QList<QListWidgetItem*> aItems = myListControl->selectedItems();
+ myCopyAction->setEnabled(!aItems.isEmpty());
+ myDeleteAction->setEnabled(!aItems.isEmpty());
+}
\ No newline at end of file
--- /dev/null
+// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#ifndef ModuleBase_ListView_H_
+#define ModuleBase_ListView_H_
+
+#include "ModuleBase.h"
+
+#include <QModelIndex>
+#include <QObject>
+
+#include <set>
+
+class QAction;
+class QListWidget;
+class QWidget;
+
+/**
+* \ingroup GUI
+* An extension of QListWidget to provide Undo/Redo functionality
+*/
+class MODULEBASE_EXPORT ModuleBase_ListView : public QObject
+{
+Q_OBJECT
+
+public:
+ /// Constructor
+ ModuleBase_ListView(QWidget* theParent = 0, const QString& theObjectName = QString(),
+ const QString& theToolTip = QString());
+ /// Destructor
+ virtual ~ModuleBase_ListView() {}
+
+ /// Returns current control
+ /// \return list view instance
+ QListWidget* getControl() const { return myListControl; }
+
+ /// Adds a new list widget item to the end of the list and connect it to the given index
+ /// \param theTextValue value visualized in the view
+ /// \param theIndex an item internal index
+ void addItem(const QString& theTextValue, const int theIndex);
+
+ /// Returns list of internal list view item indices
+ /// \param theIndices an output container for indices
+ void getSelectedIndices(std::set<int>& theIndices);
+
+ /// Removes selected items from the list widget
+ void removeSelectedItems();
+
+ /// Remove items contain parameter indices
+ /// \param theIndices an indices
+ void removeItems(std::set<int>& theIndices);
+
+ /// Set selected items if possible
+ /// \param theIndices container of indices to be selected
+ void restoreSelection(const QModelIndexList& theIndices);
+
+ /// Update enable/disable state of context menu actions
+ void updateActionsStatus();
+
+protected slots:
+ /// Slot for copy command in a list pop-up menu
+ void onCopyItem();
+
+ /// Slot is called on selection of list of selected items
+ void onListSelection();
+
+signals:
+ /// Signal about delete action click
+ void deleteActionClicked();
+
+protected:
+ QListWidget* myListControl; ///< List control
+
+ QAction* myCopyAction; ///< A copy action for pop-up menu in a list control
+ QAction* myDeleteAction; ///< A delete action for pop-up menu in a list control
+};
+
+#endif
/// The method called when widget is deactivated
virtual void deactivate();
+ /// The method called if widget should be activated always
+ virtual bool needToBeActiated() { return false; }
+
/// Returns list of widget controls
/// \return a control list
virtual QList<QWidget*> getControls() const = 0;
//
#include "ModuleBase_ResultPrs.h"
-#include "ModuleBase_Tools.h"
+
+#include <GeomAPI_PlanarEdges.h>
#include <ModelAPI_Events.h>
#include <ModelAPI_Tools.h>
#include <ModelAPI_ResultConstruction.h>
#include <ModelAPI_ResultCompSolid.h>
-#include <GeomAPI_PlanarEdges.h>
+
+#include "ModuleBase_Tools.h"
+#include "ModuleBase_BRepOwner.h"
#include <Events_InfoMessage.h>
#include <Events_Loop.h>
#include <Graphic3d_AspectMarker3d.hxx>
#include <TopExp_Explorer.hxx>
-IMPLEMENT_STANDARD_RTTIEXT(ModuleBase_BRepOwner, StdSelect_BRepOwner);
-
//*******************************************************************************************
IMPLEMENT_STANDARD_RTTIEXT(ModuleBase_ResultPrs, ViewerData_AISShape);
myAdditionalSelectionPriority = thePriority;
}
+bool ModuleBase_ResultPrs::setSubShapeHidden(const NCollection_List<TopoDS_Shape>& theShapes)
+{
+ bool isModified = false;
+
+ // restore hidden shapes if there are not the shapes in parameter container
+ NCollection_List<TopoDS_Shape> aVisibleSubShapes;
+ for (NCollection_List<TopoDS_Shape>::Iterator aHiddenIt(myHiddenSubShapes); aHiddenIt.More();
+ aHiddenIt.Next()) {
+ if (!theShapes.Contains(aHiddenIt.Value()))
+ aVisibleSubShapes.Append(aHiddenIt.Value());
+ }
+ isModified = !aVisibleSubShapes.IsEmpty();
+ for (NCollection_List<TopoDS_Shape>::Iterator aVisibleIt(aVisibleSubShapes); aVisibleIt.More();
+ aVisibleIt.Next())
+ myHiddenSubShapes.Remove(aVisibleIt.Value());
+
+ // append hidden shapes into internal container if there are not these shapes
+ for (NCollection_List<TopoDS_Shape>::Iterator aShapeIt(theShapes); aShapeIt.More();
+ aShapeIt.Next())
+ {
+ if (aShapeIt.Value().ShapeType() != TopAbs_FACE) // only face shape can be hidden
+ continue;
+
+ if (!myHiddenSubShapes.Contains(aShapeIt.Value())) {
+ myHiddenSubShapes.Append(aShapeIt.Value());
+ isModified = true;
+ }
+ }
+ return isModified;
+}
+
+bool ModuleBase_ResultPrs::hasSubShapeVisible(const TopoDS_Shape& theShape)
+{
+ int aNbOfHiddenSubShapes = myHiddenSubShapes.Size();
+
+ if (!myHiddenSubShapes.Contains(theShape))
+ aNbOfHiddenSubShapes++; // the shape to be hidden later
+
+ TopExp_Explorer anExp(myOriginalShape, TopAbs_FACE);
+ bool aHasVisibleShape = false;
+ for(TopExp_Explorer anExp(myOriginalShape, TopAbs_FACE); anExp.More() && !aHasVisibleShape;
+ anExp.Next())
+ {
+ aNbOfHiddenSubShapes--;
+ if (aNbOfHiddenSubShapes < 0)
+ aHasVisibleShape = true;
+ }
+ return aHasVisibleShape;
+}
+
void ModuleBase_ResultPrs::Compute(
const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
const Handle(Prs3d_Presentation)& thePresentation,
bool aReadyToDisplay = aShapePtr.get();
if (aReadyToDisplay) {
myOriginalShape = aShapePtr->impl<TopoDS_Shape>();
- if (!myOriginalShape.IsNull())
- Set(myOriginalShape);
+ if (myHiddenSubShapes.IsEmpty() || myOriginalShape.ShapeType() > TopAbs_FACE ) {
+ if (!myOriginalShape.IsNull())
+ Set(myOriginalShape);
+ }
+ else { // convert shape into SHELL
+ TopoDS_Shell aShell;
+ BRep_Builder aShellBuilder;
+ aShellBuilder.MakeShell(aShell);
+ bool isEmptyShape = true;
+ for(TopExp_Explorer anExp(myOriginalShape, TopAbs_FACE); anExp.More(); anExp.Next()) {
+ if (myHiddenSubShapes.Contains(anExp.Current()))
+ continue;
+ aShellBuilder.Add(aShell, anExp.Current());
+ isEmptyShape = false;
+ }
+ Set(aShell);
+ if (isEmptyShape)
+ aReadyToDisplay = false;
+ }
}
// change deviation coefficient to provide more precise circle
//ModuleBase_Tools::setDefaultDeviationCoefficient(myResult, Attributes());
#include <ModelAPI_Result.h>
+#include <NCollection_List.hxx>
#include <ViewerData_AISShape.hxx>
#include <Standard_DefineHandle.hxx>
-#include <StdSelect_BRepOwner.hxx>
#include <QMap>
-DEFINE_STANDARD_HANDLE(ModuleBase_BRepOwner, StdSelect_BRepOwner)
-
-/**
-* \ingroup GUI
-* A redefinition of standard BRep Owner in order to provide specific selection
-* of CompSolid objects. This owner is created only for selection mode TopAbs_COMPSOLID
-*/
-class ModuleBase_BRepOwner: public StdSelect_BRepOwner
-{
-public:
- /// Constructor
- /// \param aShape an owner shape
- /// \param aPriority drawig priority
- /// \param ComesFromDecomposition decomposition flag
- ModuleBase_BRepOwner(const TopoDS_Shape& aShape,
- const Standard_Integer aPriority = 0,
- const Standard_Boolean ComesFromDecomposition = Standard_False)
- : StdSelect_BRepOwner(aShape, aPriority, ComesFromDecomposition) {}
-
- /// Highlight the presentation with the given color
- /// \param aPM a presentations manager
- /// \param theStyle a style of presentation
- /// \param theMode a drawing mode
- virtual void HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& aPM,
- const Handle(Graphic3d_HighlightStyle)& theStyle, const Standard_Integer theMode = 0)
- {
- Selectable()->HilightOwnerWithColor(aPM, theStyle, this);
- }
-
- DEFINE_STANDARD_RTTIEXT(ModuleBase_BRepOwner, StdSelect_BRepOwner)
-};
-
-
-
DEFINE_STANDARD_HANDLE(ModuleBase_ResultPrs, ViewerData_AISShape)
/**
/// \param thePriority a new priority value
Standard_EXPORT void setAdditionalSelectionPriority(const int thePriority);
+ /// Change presentation to have given shape hidden.
+ /// It suports FACE type of the shape to be hidden.
+ /// If presentation type is greater than FACE, the SHELL with be shown with the FACE hidden
+ /// It is possible to hide more than one FACE by calling the method with given FACES
+ /// Visual state of the face is controlled by the second parameter
+ /// \param theShapes a container of shape objects
+ /// \returns true if the presentation is changed, or false (if for example it was hidden)
+ Standard_EXPORT bool setSubShapeHidden(const NCollection_List<TopoDS_Shape>& theShapes);
+
+ /// Returns true if there are no hidden sub shapes or original shape has at least one not hidden
+ /// \param theShapeToSkip the shape should be interpreted as additional hidden in the presentation
+ /// \return boolean value
+ Standard_EXPORT bool hasSubShapeVisible(const TopoDS_Shape& theShapeToSkip);
+
DEFINE_STANDARD_RTTIEXT(ModuleBase_ResultPrs, ViewerData_AISShape)
+
protected:
/// Redefinition of virtual function
Standard_EXPORT virtual void Compute(
/// Original shape of the result object
TopoDS_Shape myOriginalShape;
+ /// Container of original Shape sub shape to be hidden and not selectable
+ NCollection_List<TopoDS_Shape> myHiddenSubShapes;
+
/// selection priority that will be added to the standard
/// selection priority of the selection entity
int myAdditionalSelectionPriority;
#include <ModuleBase_IModule.h>
#include <ModuleBase_IconFactory.h>
#include <ModuleBase_ResultPrs.h>
+#include <ModuleBase_ViewerPrs.h>
#include <ModelAPI_Attribute.h>
#include <ModelAPI_AttributeRefAttr.h>
#include <ModelGeomAlgo_Point2D.h>
+#include <StdSelect_BRepOwner.hxx>
#include <TopoDS_Iterator.hxx>
#include <GeomDataAPI_Point2D.h>
return aShapeType;
}
+TopoDS_Shape getSelectedShape(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs)
+{
+ if (thePrs->shape().get())
+ return thePrs->shape()->impl<TopoDS_Shape>();
+
+ Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast(thePrs->owner());
+ if (!anOwner.IsNull())
+ return anOwner->Shape();
+
+ return TopoDS_Shape();
+}
+
void getParameters(QStringList& theParameters)
{
theParameters.clear();
class QLayout;
class QDoubleSpinBox;
class QAction;
+class ModuleBase_IWorkshop;
class ModuleBase_ParamIntSpinBox;
class ModuleBase_ParamSpinBox;
-class ModuleBase_IWorkshop;
+class ModuleBase_ViewerPrs;
class GeomAPI_Shape;
/// \param theObj an object
MODULEBASE_EXPORT TopAbs_ShapeEnum getCompoundSubType(const TopoDS_Shape& theShape);
+/// Returns either presentation shape or shape of BREP owner if it is casted to it
+/// \param thePrs selection presentation
+/// \return shape
+MODULEBASE_EXPORT TopoDS_Shape getSelectedShape(
+ const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
+
/// Returns list of parameters accessible in the active part and partset
/// \theParameters a list of parameter names
MODULEBASE_EXPORT void getParameters(QStringList& theParameters);
#include "ModuleBase_ViewerPrs.h"
#include <ModuleBase_ResultPrs.h>
+#include <StdSelect_BRepOwner.hxx>
ModuleBase_ViewerPrs::ModuleBase_ViewerPrs(ObjectPtr theResult,
const GeomShapePtr& theShape,
void ModuleBase_WidgetFeatureSelector::deactivate()
{
ModuleBase_ModelWidget::deactivate();
- disconnect(myWorkshop, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
activateFilters(false);
myWorkshop->deactivateSubShapesSelection();
}
//********************************************************************
-void ModuleBase_WidgetFeatureSelector::activateCustom()
+bool ModuleBase_WidgetFeatureSelector::processAction(ModuleBase_ActionType theActionType)
{
- connect(myWorkshop, SIGNAL(selectionChanged()), this,
- SLOT(onSelectionChanged()), Qt::UniqueConnection);
+ if (theActionType == ActionSelection)
+ onSelectionChanged();
+ else
+ return ModuleBase_WidgetValidated::processAction(theActionType);
+
+ return true;
+}
+//********************************************************************
+void ModuleBase_WidgetFeatureSelector::activateCustom()
+{
activateFilters(true);
QIntList aShapeTypes;
/// The method called when widget is deactivated
virtual void deactivate();
+ /// Processes Selection action.
+ virtual bool processAction(ModuleBase_ActionType theActionType);
+
protected:
/// The method called when widget is activated
virtual void activateCustom();
/// \param theDone a state whether the selection is set
virtual void updateOnSelectionChanged(const bool theDone);
-protected slots:
+protected:
/// Called on selection changed event
virtual void onSelectionChanged();
//
#include <ModuleBase_WidgetMultiSelector.h>
-#include <ModuleBase_WidgetShapeSelector.h>
+
+#include <ModuleBase_Definitions.h>
+#include <ModuleBase_Events.h>
+#include <ModuleBase_IconFactory.h>
+#include <ModuleBase_IModule.h>
#include <ModuleBase_ISelection.h>
-#include <ModuleBase_IWorkshop.h>
#include <ModuleBase_IViewer.h>
+#include <ModuleBase_IWorkshop.h>
+#include <ModuleBase_ListView.h>
#include <ModuleBase_Tools.h>
-#include <ModuleBase_Definitions.h>
-#include <ModuleBase_IModule.h>
#include <ModuleBase_ViewerPrs.h>
-#include <ModuleBase_IconFactory.h>
-#include <ModuleBase_Events.h>
+#include <ModuleBase_WidgetShapeSelector.h>
#include <ModelAPI_Data.h>
#include <ModelAPI_Object.h>
#include <QString>
#include <QComboBox>
#include <QEvent>
-#include <QAction>
#include <QApplication>
#include <QClipboard>
#include <QTimer>
#include <memory>
#include <string>
-const int ATTRIBUTE_SELECTION_INDEX_ROLE = Qt::UserRole + 1;
-
//#define DEBUG_UNDO_REDO
-/**
-* Customization of a List Widget to make it to be placed on full width of container
-*/
-class CustomListWidget : public QListWidget
-{
-public:
- /// Constructor
- /// \param theParent a parent widget
- CustomListWidget( QWidget* theParent )
- : QListWidget( theParent )
- {
- }
-
- /// Redefinition of virtual method
- virtual QSize sizeHint() const
- {
- int aHeight = 2*QFontMetrics( font() ).height();
- QSize aSize = QListWidget::sizeHint();
- return QSize( aSize.width(), aHeight );
- }
-
- /// Redefinition of virtual method
- virtual QSize minimumSizeHint() const
- {
- int aHeight = 4/*2*/*QFontMetrics( font() ).height();
- QSize aSize = QListWidget::minimumSizeHint();
- return QSize( aSize.width(), aHeight );
- }
-
-#ifndef WIN32
-// The code is necessary only for Linux because
-//it can not update viewport on widget resize
-protected:
- void resizeEvent(QResizeEvent* theEvent)
- {
- QListWidget::resizeEvent(theEvent);
- QTimer::singleShot(5, viewport(), SLOT(repaint()));
- }
-#endif
-};
-
#ifdef DEBUG_UNDO_REDO
void printHistoryInfo(const QString& theMethodName, int theCurrentHistoryIndex,
QList<QList<std::shared_ptr<ModuleBase_ViewerPrs> > > theSelectedHistoryValues)
}
QString aToolTip = QString::fromStdString(theData->widgetTooltip());
- myListControl = new CustomListWidget(this);
QString anObjName = QString::fromStdString(attributeID());
- myListControl->setObjectName(anObjName);
- myListControl->setToolTip(aToolTip);
- myListControl->setSelectionMode(QAbstractItemView::ExtendedSelection);
+ myListView = new ModuleBase_ListView(this, anObjName, aToolTip);
+ connect(myListView->getControl(), SIGNAL(itemSelectionChanged()), SLOT(onListSelection()));
+ connect(myListView, SIGNAL(deleteActionClicked()), SLOT(onDeleteItem()));
- aMainLay->addWidget(myListControl, 2, 0, 1, -1);
+ aMainLay->addWidget(myListView->getControl(), 2, 0, 1, -1);
aMainLay->setRowStretch(2, 1);
//aMainLay->addWidget(new QLabel(this)); //FIXME(sbh)???
//aMainLay->setRowMinimumHeight(3, 20);
//this->setLayout(aMainLay);
connect(myTypeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(onSelectionTypeChanged()));
- myCopyAction = ModuleBase_Tools::createAction(QIcon(":pictures/copy.png"), tr("Copy"),
- myWorkshop->desktop(), this, SLOT(onCopyItem()));
- myCopyAction->setShortcut(QKeySequence::Copy);
- myCopyAction->setEnabled(false);
- myListControl->addAction(myCopyAction);
-
- myDeleteAction = ModuleBase_Tools::createAction(QIcon(":pictures/delete.png"), tr("Delete"),
- myWorkshop->desktop(), this, SLOT(onDeleteItem()));
- myDeleteAction->setEnabled(false);
- myListControl->addAction(myDeleteAction);
-
- myListControl->setContextMenuPolicy(Qt::ActionsContextMenu);
- connect(myListControl, SIGNAL(itemSelectionChanged()), SLOT(onListSelection()));
-
myIsNeutralPointClear = theData->getBooleanAttribute("clear_in_neutral_point", true);
}
std::set<int> anAttributeIds;
getSelectedAttributeIndices(anAttributeIds);
- QModelIndexList aIndexes = myListControl->selectionModel()->selectedIndexes();
+ QModelIndexList anIndices = myListView->getControl()->selectionModel()->selectedIndexes();
// refill attribute by the items which indices are not in the list of ids
bool aDone = false;
}
// Restore selection
- int aRows = myListControl->model()->rowCount();
- if (aRows > 0) {
- foreach(QModelIndex aIndex, aIndexes) {
- if (aIndex.row() < aRows)
- myListControl->selectionModel()->select(aIndex, QItemSelectionModel::Select);
- else {
- QModelIndex aIdx = myListControl->model()->index(aRows - 1, 0);
- myListControl->selectionModel()->select(aIdx, QItemSelectionModel::Select);
- }
- }
- }
+ myListView->restoreSelection(anIndices);
+
appendSelectionInHistory();
return aDone;
}
{
QList<QWidget*> result;
//result << myTypeCombo;
- result << myListControl;
+ result << myListView->getControl();
return result;
}
{
// Set focus to List control in order to make possible
// to use Tab key for transfer the focus to next widgets
- ModuleBase_Tools::setFocus(myListControl,
+ ModuleBase_Tools::setFocus(myListView->getControl(),
"ModuleBase_WidgetMultiSelector::onSelectionTypeChanged()");
}
//********************************************************************
void ModuleBase_WidgetMultiSelector::updateSelectionList()
{
- myListControl->clear();
+ myListView->getControl()->clear();
DataPtr aData = myFeature->data();
AttributePtr anAttribute = aData->attribute(attributeID());
AttributeSelectionListPtr aSelectionListAttr = aData->selectionList(attributeID());
for (int i = 0; i < aSelectionListAttr->size(); i++) {
AttributeSelectionPtr aAttr = aSelectionListAttr->value(i);
- QListWidgetItem* anItem = new QListWidgetItem(aAttr->namingName().c_str(), myListControl);
- anItem->setData(ATTRIBUTE_SELECTION_INDEX_ROLE, i);
- myListControl->addItem(anItem);
+ myListView->addItem(aAttr->namingName().c_str(), i);
}
}
else if (aType == ModelAPI_AttributeRefList::typeId()) {
for (int i = 0; i < aRefListAttr->size(); i++) {
ObjectPtr anObject = aRefListAttr->object(i);
if (anObject.get()) {
- QListWidgetItem* anItem = new QListWidgetItem(anObject->data()->name().c_str(),
- myListControl);
- anItem->setData(ATTRIBUTE_SELECTION_INDEX_ROLE, i);
- myListControl->addItem(anItem);
+ myListView->addItem(anObject->data()->name().c_str(), i);
}
}
}
aName = anObject->data()->name().c_str();
}
}
- QListWidgetItem* anItem = new QListWidgetItem(aName, myListControl);
- anItem->setData(ATTRIBUTE_SELECTION_INDEX_ROLE, i);
- myListControl->addItem(anItem);
+ myListView->addItem(aName, i);
}
}
// We have to call repaint because sometimes the List control is not updated
- myListControl->repaint();
+ myListView->getControl()->repaint();
}
//********************************************************************
QList<ModuleBase_ViewerPrsPtr> anEmptyList;
// This method will call Selection changed event which will call onSelectionChanged
- // To clear mySelection, myListControl and storeValue()
+ // To clear mySelection, myListView and storeValue()
// So, we don't need to call it
myWorkshop->setSelected(anEmptyList);
myIsNeutralPointClear = isClearInNeutralPoint;
}
-//********************************************************************
-void ModuleBase_WidgetMultiSelector::onCopyItem()
-{
- QList<QListWidgetItem*> aItems = myListControl->selectedItems();
- QString aRes;
- foreach(QListWidgetItem* aItem, aItems) {
- if (!aRes.isEmpty())
- aRes += "\n";
- aRes += aItem->text();
- }
- if (!aRes.isEmpty()) {
- QClipboard *clipboard = QApplication::clipboard();
- clipboard->setText(aRes);
- }
-}
-
//********************************************************************
void ModuleBase_WidgetMultiSelector::onDeleteItem()
{
//********************************************************************
void ModuleBase_WidgetMultiSelector::onListSelection()
{
- QList<QListWidgetItem*> aItems = myListControl->selectedItems();
- myCopyAction->setEnabled(!aItems.isEmpty());
- myDeleteAction->setEnabled(!aItems.isEmpty());
-
myWorkshop->module()->customizeObject(myFeature, ModuleBase_IModule::CustomizeHighlightedObjects,
true);
}
//********************************************************************
void ModuleBase_WidgetMultiSelector::getSelectedAttributeIndices(std::set<int>& theAttributeIds)
{
- QList<QListWidgetItem*> aItems = myListControl->selectedItems();
- foreach(QListWidgetItem* anItem, aItems) {
- int anIndex = anItem->data(ATTRIBUTE_SELECTION_INDEX_ROLE).toInt();
- if (theAttributeIds.find(anIndex) == theAttributeIds.end())
- theAttributeIds.insert(anIndex);
- }
+ myListView->getSelectedIndices(theAttributeIds);
}
void ModuleBase_WidgetMultiSelector::convertIndicesToViewerSelection(std::set<int> theAttributeIds,
#include <QMap>
class QWidget;
-class QListWidget;
class QComboBox;
+class ModuleBase_ListView;
class ModuleBase_IWorkshop;
-class QAction;
-
/**
* \ingroup GUI
virtual void onSelectionChanged();
protected slots:
- /// Slot for copy command in a list pop-up menu
- void onCopyItem();
-
/// Slot for delete command in a list pop-up menu
void onDeleteItem();
ModuleBase_IWorkshop* theWorkshop);
protected:
- /// List control
- QListWidget* myListControl;
-
- /// Combobox of types
- QComboBox* myTypeCombo;
-
- /// Provides correspondance between Result object and its shape
- typedef QPair<ResultPtr, GeomShapePtr> GeomSelection;
-
- /// A copy action for pop-up menu in a list control
- QAction* myCopyAction;
-
- /// A delete action for pop-up menu in a list control
- QAction* myDeleteAction;
-
- /// A flag to store use_choice parameter state
- bool myIsUseChoice;
+ ModuleBase_ListView* myListView; ///< List control
+ QComboBox* myTypeCombo; ///< Combobox of types
+ bool myIsUseChoice; /// A flag to store use_choice parameter state
/// A flag to clear selection by click in empty place in the viewer
bool myIsNeutralPointClear;
#include <GeomDataAPI_Point.h>
#include <GeomDataAPI_Dir.h>
-#include <XGUI_Displayer.h>
-#include <XGUI_Workshop.h>
-#include <XGUI_OperationMgr.h>
-#include <XGUI_PropertyPanel.h>
-#include <XGUI_ModuleConnector.h>
+#include <XGUI_ActiveControlMgr.h>
+#include <XGUI_ActiveControlSelector.h>
+#include <XGUI_ActionsMgr.h>
#include <XGUI_ContextMenuMgr.h>
-#include <XGUI_Tools.h>
-#include <XGUI_ObjectsBrowser.h>
-#include <XGUI_SelectionMgr.h>
+#include <XGUI_CustomPrs.h>
#include <XGUI_DataModel.h>
+#include <XGUI_Displayer.h>
#include <XGUI_ErrorMgr.h>
-#include <XGUI_CustomPrs.h>
+#include <XGUI_FacesPanelSelector.h>
+#include <XGUI_ModuleConnector.h>
+#include <XGUI_ObjectsBrowser.h>
+#include <XGUI_OperationMgr.h>
+#include <XGUI_PropertyPanel.h>
#include <XGUI_SelectionMgr.h>
-#include <XGUI_ActionsMgr.h>
+#include <XGUI_Tools.h>
+#include <XGUI_Workshop.h>
#include <SketchPlugin_ConstraintAngle.h>
#include <SketchPlugin_ConstraintLength.h>
}
}
+void PartSet_Module::updateActiveSelectionFilters()
+{
+ XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(workshop());
+ XGUI_ActiveControlSelector* anActiveSelector = aWorkshop->activeControlMgr()->activeSelector();
+
+ if (anActiveSelector && anActiveSelector->getType() == XGUI_FacesPanelSelector::Type())
+ sketchMgr()->deactivateSelectionFilters();
+ else
+ sketchMgr()->activateSelectionFilters();
+}
+
void PartSet_Module::storeSelection()
{
// cash is used only to restore selection, so it should be filled in storeSelection and
virtual void activateSelectionFilters();
// Remove default selection filters of the module from the current viewer
virtual void deactivateSelectionFilters();
+ /// Update selection filters depending on the module active controls
+ virtual void updateActiveSelectionFilters();
// Stores the current selection
virtual void storeSelection();
}
XGUI_Displayer* aDisp = XGUI_Tools::workshop(theWorkshop)->displayer();
- aDisp->displayAIS(myPlane, true, 1/*shaded*/, false);
+ aDisp->displayAIS(myPlane, false/*load object in selection*/, 1/*shaded*/, false);
myPreviewIsDisplayed = true;
}
myIsConstraintsShown[PartSet_Tools::Expressions] = false;
mySketchPlane = new PartSet_PreviewSketchPlane();
+
+ myCirclePointFilter = new PartSet_CirclePointFilter(anIWorkshop);
+ myPlaneFilter = new ModuleBase_ShapeInPlaneFilter();
}
PartSet_SketcherMgr::~PartSet_SketcherMgr()
{
- if (!myPlaneFilter.IsNull())
- myPlaneFilter.Nullify();
+ myPlaneFilter.Nullify();
+ myCirclePointFilter.Nullify();
}
void PartSet_SketcherMgr::onEnterViewPort()
qDebug(QString("startSketch: %1, %2").arg(anInfo.size()).arg(anInfoStr).toStdString().c_str());
#endif
- if(myCirclePointFilter.IsNull()) {
- myCirclePointFilter = new PartSet_CirclePointFilter(myModule->workshop());
- }
-
- myModule->workshop()->viewer()->addSelectionFilter(myCirclePointFilter);
-
- if (myPlaneFilter.IsNull())
- myPlaneFilter = new ModuleBase_ShapeInPlaneFilter();
-
- myModule->workshop()->viewer()->addSelectionFilter(myPlaneFilter);
bool aHasPlane = false;
std::shared_ptr<GeomAPI_Pln> aPln;
aPln = PartSet_Tools::sketchPlane(myCurrentSketch);
myPlaneFilter->setPlane(aPln);
+ activateSelectionFilters();
+
Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
// all displayed objects should be activated in current selection modes according to switched
// plane filter
// The sketch was aborted
myCurrentSketch = CompositeFeaturePtr();
mySketchPlane->eraseSketchPlane(myModule->workshop());
- // TODO: move this outside of if-else
- myModule->workshop()->viewer()->removeSelectionFilter(myCirclePointFilter);
- myModule->workshop()->viewer()->removeSelectionFilter(myPlaneFilter);
// Erase all sketcher objects
QObjectPtrList aObjects = aDisplayer->displayedObjects();
myCurrentSketch = CompositeFeaturePtr();
mySketchPlane->eraseSketchPlane(myModule->workshop());
- myModule->workshop()->viewer()->removeSelectionFilter(myCirclePointFilter);
- myModule->workshop()->viewer()->removeSelectionFilter(myPlaneFilter);
-
Events_Loop::loop()->flush(aDispEvent);
}
+ deactivateSelectionFilters();
+
// restore the module selection modes, which were changed on startSketch
aConnector->activateModuleSelectionModes();
}
}
}
+void PartSet_SketcherMgr::activateSelectionFilters()
+{
+ myModule->workshop()->viewer()->addSelectionFilter(myCirclePointFilter);
+ myModule->workshop()->viewer()->addSelectionFilter(myPlaneFilter);
+}
+
+void PartSet_SketcherMgr::deactivateSelectionFilters()
+{
+ myModule->workshop()->viewer()->removeSelectionFilter(myCirclePointFilter);
+ myModule->workshop()->viewer()->removeSelectionFilter(myPlaneFilter);
+}
+
void PartSet_SketcherMgr::activatePlaneFilter(const bool& toActivate)
{
if (toActivate)
void PartSet_SketcherMgr::onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln)
{
- if (myPlaneFilter.IsNull())
- myPlaneFilter = new ModuleBase_ShapeInPlaneFilter();
-
myPlaneFilter->setPlane(thePln);
}
/// \param theOperation a committed operation
void commitNestedSketch(ModuleBase_Operation* theOperation);
+ /// Append the sketch selection filters in 3D viewer (plane and circle pointer)
+ void activateSelectionFilters();
+
+ // Remove sketch selection filter from the current viewer
+ virtual void deactivateSelectionFilters();
+
/// Append the sketch plane filter into the current viewer
/// \param toActivate state whether the filter should be activated/deactivated
void activatePlaneFilter(const bool& toActivate);
void PartSet_WidgetSketchLabel::onSelectionChanged()
{
+ std::shared_ptr<GeomAPI_Pln> aPlane = plane();
+ if (aPlane.get())
+ return;
+
QList<ModuleBase_ViewerPrsPtr> aSelected = getFilteredSelected();
if (aSelected.empty())
//myLabel->setText("");
//myLabel->setToolTip("");
XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myWorkshop);
- disconnect(aWorkshop->selector(), SIGNAL(selectionChanged()),
- this, SLOT(onSelectionChanged()));
// 4. deactivate face selection filter
activateFilters(false);
return aCanFillSketch;
}
+//********************************************************************
+bool PartSet_WidgetSketchLabel::processAction(ModuleBase_ActionType theActionType)
+{
+ if (theActionType == ActionSelection)
+ onSelectionChanged();
+ else
+ return ModuleBase_WidgetValidated::processAction(theActionType);
+
+ return true;
+}
+
bool PartSet_WidgetSketchLabel::fillSketchPlaneBySelection(const ModuleBase_ViewerPrsPtr& thePrs)
{
bool isOwnerSet = false;
mySizeOfViewWidget->setVisible(false);
activateSelection(true);
-
- connect(XGUI_Tools::workshop(myWorkshop)->selector(), SIGNAL(selectionChanged()),
- this, SLOT(onSelectionChanged()));
activateFilters(true);
}
/// The methiod called when widget is deactivated
virtual void deactivate();
+ /// The method called if widget should be activated always
+ virtual bool needToBeActiated() { return true; }
+
/// Returns sketcher plane
std::shared_ptr<GeomAPI_Pln> plane() const;
/// \param thePrs a presentation
static bool canFillSketch(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
+ /// Processes Selection action.
+ virtual bool processAction(ModuleBase_ActionType theActionType);
+
signals:
/// Signal on plane selection
void planeSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
/// Activate or deactivate selection
void activateSelection(bool toActivate);
- private slots:
+ private:
/// Slot on change selection
void onSelectionChanged();
+private slots:
/// A slot called on set sketch plane view
void onSetPlaneView();
SET(PROJECT_HEADERS
XGUI.h
XGUI_ActionsMgr.h
+ XGUI_ActiveControlMgr.h
+ XGUI_ActiveControlSelector.h
XGUI_ColorDialog.h
XGUI_ContextMenuMgr.h
XGUI_CustomPrs.h
XGUI_Displayer.h
XGUI_ErrorDialog.h
XGUI_ErrorMgr.h
+ XGUI_FacesPanel.h
+ XGUI_FacesPanelSelector.h
XGUI_HistoryMenu.h
XGUI_MenuGroup.h
XGUI_MenuMgr.h
XGUI_OperationMgr.h
XGUI_PropertyDialog.h
XGUI_PropertyPanel.h
+ XGUI_PropertyPanelSelector.h
XGUI_QtEvents.h
XGUI_SalomeConnector.h
XGUI_Selection.h
SET(PROJECT_MOC_HEADERS
XGUI_ActionsMgr.h
+ XGUI_ActiveControlMgr.h
+ XGUI_ActiveControlSelector.h
XGUI_ColorDialog.h
XGUI_ContextMenuMgr.h
XGUI_DataModel.h
XGUI_Displayer.h
XGUI_ErrorDialog.h
XGUI_ErrorMgr.h
+ XGUI_FacesPanel.h
+ XGUI_FacesPanelSelector.h
XGUI_HistoryMenu.h
XGUI_ModuleConnector.h
XGUI_ObjectsBrowser.h
XGUI_OperationMgr.h
XGUI_PropertyDialog.h
XGUI_PropertyPanel.h
+ XGUI_PropertyPanelSelector.h
XGUI_SelectionMgr.h
XGUI_TransparencyWidget.h
XGUI_ViewerProxy.h
SET(PROJECT_SOURCES
XGUI_ActionsMgr.cpp
+ XGUI_ActiveControlMgr.cpp
XGUI_ColorDialog.cpp
XGUI_ContextMenuMgr.cpp
XGUI_CustomPrs.cpp
XGUI_Displayer.cpp
XGUI_ErrorDialog.cpp
XGUI_ErrorMgr.cpp
+ XGUI_FacesPanel.cpp
+ XGUI_FacesPanelSelector.cpp
XGUI_HistoryMenu.cpp
XGUI_MenuGroup.cpp
XGUI_MenuMgr.cpp
XGUI_OperationMgr.cpp
XGUI_PropertyDialog.cpp
XGUI_PropertyPanel.cpp
+ XGUI_PropertyPanelSelector.cpp
XGUI_QtEvents.cpp
XGUI_SalomeConnector.cpp
XGUI_Selection.cpp
--- /dev/null
+// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#include <XGUI_ActiveControlMgr.h>
+#include <XGUI_ActiveControlSelector.h>
+
+#include <ModuleBase_IModule.h>
+#include <ModuleBase_IWorkshop.h>
+
+//********************************************************************
+XGUI_ActiveControlMgr::XGUI_ActiveControlMgr(ModuleBase_IWorkshop* theWorkshop)
+: myWorkshop(theWorkshop), myActiveSelector(0)
+{
+ connect(myWorkshop, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
+}
+
+//********************************************************************
+void XGUI_ActiveControlMgr::addSelector(XGUI_ActiveControlSelector* theSelector)
+{
+ mySelectors.append(theSelector);
+ connect(theSelector, SIGNAL(activated()), this, SLOT(onSelectorActivated()));
+ connect(theSelector, SIGNAL(deactivated()), this, SLOT(onSelectorDeactivated()));
+}
+
+//********************************************************************
+XGUI_ActiveControlSelector* XGUI_ActiveControlMgr::getSelector(const QString& theType)
+{
+ XGUI_ActiveControlSelector* aSelector;
+ for (int i = 0, aCount = mySelectors.count(); i < aCount; i++)
+ {
+ if (mySelectors[i]->getType() != theType)
+ continue;
+ aSelector = mySelectors[i];
+ break;
+ }
+ return aSelector;
+}
+
+//********************************************************************
+void XGUI_ActiveControlMgr::onSelectorActivated()
+{
+ XGUI_ActiveControlSelector* aSelector = qobject_cast<XGUI_ActiveControlSelector*>(sender());
+ if (!aSelector || aSelector == myActiveSelector)
+ return;
+
+ if (myActiveSelector)
+ myActiveSelector->setActive(false);
+
+ activateSelector(aSelector);
+}
+
+//********************************************************************
+void XGUI_ActiveControlMgr::onSelectorDeactivated()
+{
+ XGUI_ActiveControlSelector* aSelector = qobject_cast<XGUI_ActiveControlSelector*>(sender());
+ if (!aSelector)
+ return;
+
+ myActiveSelector = NULL;
+
+ aSelector->setActive(false);
+ myWorkshop->module()->updateActiveSelectionFilters();
+
+ XGUI_ActiveControlSelector* aSelectorToBeActivated = 0;
+ for (int i = 0, aCount = mySelectors.count(); i < aCount; i++)
+ {
+ if (!mySelectors[i]->needToBeActiated())
+ continue;
+ aSelectorToBeActivated = mySelectors[i];
+ break;
+ }
+ if (aSelectorToBeActivated)
+ activateSelector(aSelectorToBeActivated);
+}
+
+//********************************************************************
+void XGUI_ActiveControlMgr::onSelectionChanged()
+{
+ if (!myActiveSelector)
+ return;
+
+ myActiveSelector->processSelection();
+}
+
+//********************************************************************
+void XGUI_ActiveControlMgr::activateSelector(XGUI_ActiveControlSelector* theSelector)
+{
+ myActiveSelector = theSelector;
+ theSelector->setActive(true);
+
+ myWorkshop->module()->updateActiveSelectionFilters();
+}
--- /dev/null
+// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#ifndef XGUI_ActiveControlMgr_H
+#define XGUI_ActiveControlMgr_H
+
+#include "XGUI.h"
+
+#include <QList>
+#include <QObject>
+
+
+class XGUI_ActiveControlSelector;
+class ModuleBase_IWorkshop;
+
+/**
+* Interface of providing only one active control for workshop.
+* It has container of selectors, where only one might be active at the moment.
+* Selection in 3D view is processed by the active selector.
+*/
+class XGUI_ActiveControlMgr : public QObject
+{
+ Q_OBJECT
+public:
+ /// Constructor
+ /// \param theWorkshop the current workshop instance
+ XGUI_EXPORT XGUI_ActiveControlMgr(ModuleBase_IWorkshop* theWorkshop);
+
+ XGUI_EXPORT virtual ~XGUI_ActiveControlMgr() {};
+
+ /// Register selector to process activation of control
+ void addSelector(XGUI_ActiveControlSelector* theSelector);
+
+ /// Returns selector by type name
+ /// \param theType a selector type
+ /// \return selector instance
+ XGUI_EXPORT XGUI_ActiveControlSelector* getSelector(const QString& theType);
+
+ /// Returns the active selector
+ /// \return selector instance
+ XGUI_ActiveControlSelector* activeSelector() const { return myActiveSelector; }
+
+protected slots:
+ /// Deactivates active selector and set the sender selector as active
+ void onSelectorActivated();
+ /// Deactivate the active selector
+ void onSelectorDeactivated();
+ /// Listens workshop selection and pass it to the active selector
+ void onSelectionChanged();
+
+protected:
+ void activateSelector(XGUI_ActiveControlSelector* theSelector);
+
+protected:
+ ModuleBase_IWorkshop* myWorkshop; ///< the current workshop
+
+ QList<XGUI_ActiveControlSelector*> mySelectors; ///< workshop selectors
+ XGUI_ActiveControlSelector* myActiveSelector; ///< active selector
+};
+
+#endif
--- /dev/null
+// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#ifndef XGUI_ActiveControlSelector_H
+#define XGUI_ActiveControlSelector_H
+
+#include "XGUI.h"
+
+#include <QObject>
+
+/**
+* Interface to have an active control and process selection by the control.
+* Activation of control may set selection modes and selection filters of the control.
+*/
+class XGUI_ActiveControlSelector : public QObject
+{
+ Q_OBJECT
+
+public:
+ /// Constructor
+ /// \param theWorkshop the current workshop instance
+ XGUI_EXPORT XGUI_ActiveControlSelector() {};
+ /// Destructor
+ XGUI_EXPORT virtual ~XGUI_ActiveControlSelector() {};
+
+ /// Returns name of the selector
+ XGUI_EXPORT virtual QString getType() = 0;
+
+ /// Clear need to be activated widget if it exists
+ XGUI_EXPORT virtual void reset() {}
+
+ /// Sets enable/disable state of the selector. If disable, it will not react to selection
+ /// \param theEnabled if true, selector is enabled
+ XGUI_EXPORT void setEnable(const bool& theEnabled) { myIsEnabled = theEnabled; }
+
+ /// Returns whether the selector is enabled or not
+ /// \return boolean result
+ XGUI_EXPORT bool isEnabled() const { return myIsEnabled; }
+
+ /// Sets control active. It should activates/deactivates selection and selection filters.
+ /// \param isActive if true, the control becomes active
+ XGUI_EXPORT virtual void setActive(const bool& isActive) = 0;
+
+ /// Returns whether the selector should be activated as soon as possible (by deactivatate other)
+ /// \return boolean result
+ XGUI_EXPORT virtual bool needToBeActiated() const { return false; }
+
+ /// Processes current selection of workshop. Reaction to selection change in workshop.
+ XGUI_EXPORT virtual void processSelection() = 0;
+
+signals:
+ /// control is activated
+ void activated();
+ /// control is deactivated
+ void deactivated();
+
+protected:
+ bool myIsEnabled; ///< enable state of the selector
+};
+
+#endif
// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
//
+#include "XGUI_CustomPrs.h"
#include "XGUI_Displayer.h"
-#include "XGUI_Workshop.h"
-#include "XGUI_ViewerProxy.h"
-#include "XGUI_SelectionMgr.h"
+#include "XGUI_FacesPanel.h"
#include "XGUI_Selection.h"
-#include "XGUI_CustomPrs.h"
+#include "XGUI_SelectionMgr.h"
+#include "XGUI_ViewerProxy.h"
+#include "XGUI_Workshop.h"
#ifndef HAVE_SALOME
#include <AppElements_Viewer.h>
#include <ModelAPI_AttributeIntArray.h>
#include <ModelAPI_ResultCompSolid.h>
+#include <ModuleBase_BRepOwner.h>
+#include <ModuleBase_IModule.h>
+#include <ModuleBase_Preferences.h>
#include <ModuleBase_ResultPrs.h>
#include <ModuleBase_Tools.h>
-#include <ModuleBase_IModule.h>
#include <ModuleBase_ViewerPrs.h>
-#include <ModuleBase_Preferences.h>
#include <GeomAPI_Shape.h>
#include <GeomAPI_IPresentable.h>
if (!anAISIO.IsNull()) {
appendResultObject(theObject, theAIS);
- bool isCustomized = customizeObject(theObject);
+ bool isCustomized = customizeObject(theObject, true);
int aDispMode = isShading? Shading : Wireframe;
if (isShading)
}
}
// Customization of presentation
- bool isCustomized = customizeObject(theObject);
+ bool isCustomized = customizeObject(theObject, false);
#ifdef DEBUG_FEATURE_REDISPLAY
qDebug(QString("Redisplay: %1, isEqualShapes=%2, isCustomized=%3").
arg(!isEqualShapes || isCustomized).arg(isEqualShapes)
return isActivationChanged;
}
-bool XGUI_Displayer::customizeObject(ObjectPtr theObject)
+bool XGUI_Displayer::customizeObject(ObjectPtr theObject, const bool isDisplayed)
{
AISObjectPtr anAISObj = getAISObject(theObject);
// correct the result's color it it has the attribute
aCustomPrs->customisePresentation(aResult, anAISObj, myCustomPrs);
isCustomized = myWorkshop->module()->afterCustomisePresentation(aResult, anAISObj, myCustomPrs)
|| isCustomized;
+
+ // update presentation state if faces panel is active
+ if (anAISObj.get() && myWorkshop->facesPanel())
+ isCustomized = myWorkshop->facesPanel()->customizeObject(theObject, isDisplayed) ||
+ isCustomized;
+
return isCustomized;
}
/// If the object is result with the color attribute value set, it is used,
/// otherwise the customize is applyed to the object's feature if it is a custom prs
/// \param theObject an object instance
+ /// \param isDisplayed boolean state whether the object is displayed/redisplayed
/// \return the true state if there is changes and the presentation is customized
- bool customizeObject(ObjectPtr theObject);
+ bool customizeObject(ObjectPtr theObject, const bool isDisplayed);
/// Append the objects in the internal map. Checks whether the map already contains the object
/// \param theObject an object to display
--- /dev/null
+// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#include "XGUI_FacesPanel.h"
+
+#include <Events_Loop.h>
+#include "GeomAlgoAPI_CompoundBuilder.h"
+
+#include <ModelAPI_Events.h>
+
+#include <ModuleBase_ISelection.h>
+#include "ModuleBase_IWorkshop.h"
+#include "ModuleBase_ListView.h"
+#include "ModuleBase_ResultPrs.h"
+#include "ModuleBase_Tools.h"
+#include "ModuleBase_ViewerPrs.h"
+
+#include "XGUI_Displayer.h"
+#include "XGUI_Tools.h"
+#include "XGUI_Workshop.h"
+
+#include <QAction>
+#include <QCheckBox>
+#include <QFocusEvent>
+#include <QGridLayout>
+#include <QListWidget>
+#include <QMainWindow>
+
+static const int LayoutMargin = 3;
+
+//********************************************************************
+XGUI_FacesPanel::XGUI_FacesPanel(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop)
+ : QDockWidget(theParent), myIsActive(false), myWorkshop(theWorkshop)
+{
+ setWindowTitle(tr("Hide Faces"));
+ QAction* aViewAct = toggleViewAction();
+ setStyleSheet("::title { position: relative; padding-left: 5px; text-align: left center }");
+
+ QWidget* aContent = new QWidget(this);
+ QGridLayout* aMainLayout = new QGridLayout(aContent);
+ aMainLayout->setContentsMargins(LayoutMargin, LayoutMargin, LayoutMargin, LayoutMargin);
+ setWidget(aContent);
+
+ myHiddenOrTransparent = new QCheckBox(tr("Transparent"), aContent);
+ myListView = new ModuleBase_ListView(aContent, "", "Hidden/transparent faces in 3D view");
+ connect(myListView->getControl(), SIGNAL(itemSelectionChanged()), SLOT(onListSelection()));
+ connect(myListView, SIGNAL(deleteActionClicked()), SLOT(onDeleteItem()));
+
+ aMainLayout->addWidget(myHiddenOrTransparent, 0, 0);
+ aMainLayout->addWidget(myListView->getControl(), 1, 0);
+
+ myListView->getControl()->setFocusPolicy(Qt::StrongFocus);
+ myListView->getControl()->viewport()->installEventFilter(this);
+}
+
+//********************************************************************
+void XGUI_FacesPanel::reset(const bool isToFlushRedisplay)
+{
+ // restore presentation state
+ bool isModified = false;
+ std::set<ObjectPtr> aRestoredObjects;
+ for (QMap<int, ModuleBase_ViewerPrsPtr>::const_iterator anIt = myItems.begin();
+ anIt != myItems.end(); anIt++) {
+ if (aRestoredObjects.find(anIt.value()->object()) == aRestoredObjects.end())
+ aRestoredObjects.insert(anIt.value()->object());
+ }
+ // clear internal containers
+ myListView->getControl()->clear();
+ myLastItemIndex = 0;
+ myItems.clear();
+
+ isModified = redisplayObjects(aRestoredObjects, isToFlushRedisplay);
+
+ if (isToFlushRedisplay && isModified)
+ XGUI_Tools::workshop(myWorkshop)->displayer()->updateViewer();
+}
+
+//********************************************************************
+bool XGUI_FacesPanel::eventFilter(QObject* theObject, QEvent *theEvent)
+{
+ QWidget* aWidget = qobject_cast<QWidget*>(theObject);
+ if (theEvent->type() == QEvent::MouseButtonRelease)
+ {
+ if (myListView->getControl()->viewport() == aWidget)
+ setActivePanel(true);
+ }
+ // pass the event on to the parent class
+ return QObject::eventFilter(theObject, theEvent);
+}
+
+//********************************************************************
+void XGUI_FacesPanel::setActivePanel(const bool theIsActive)
+{
+ if (myIsActive == theIsActive)
+ return;
+
+ ModuleBase_Tools::setShadowEffect(myListView->getControl(), theIsActive);
+ myIsActive = theIsActive;
+
+ if (myIsActive)
+ {
+ emit activated();
+ // selection should be activated after emit signal, that deactivates current widget(selection)
+ activateSelection(theIsActive);
+ }
+ else
+ {
+ // selection should be activated after emit signal, that deactivates current widget(selection)
+ activateSelection(theIsActive);
+ emit deactivated();
+ }
+}
+
+//********************************************************************
+void XGUI_FacesPanel::restoreObjects(const std::set<ObjectPtr>& theHiddenObjects)
+{
+ std::set<int> anIndicesToBeRemoved;
+ for (QMap<int, ModuleBase_ViewerPrsPtr>::const_iterator anItemsIt = myItems.begin();
+ anItemsIt != myItems.end(); anItemsIt++)
+ {
+ ModuleBase_ViewerPrsPtr aPrs = anItemsIt.value();
+ ObjectPtr anObject = aPrs->object();
+ if (theHiddenObjects.find(anObject) == theHiddenObjects.end()) // not found
+ continue;
+ anIndicesToBeRemoved.insert(anItemsIt.key());
+ }
+
+ // remove from myItes container
+ for (std::set<int>::const_iterator aToBeRemovedIt = anIndicesToBeRemoved.begin();
+ aToBeRemovedIt != anIndicesToBeRemoved.end(); aToBeRemovedIt++)
+ myItems.remove(*aToBeRemovedIt);
+
+ myListView->removeItems(anIndicesToBeRemoved);
+
+ // remove from container of hidden objects
+ for (std::set<ObjectPtr>::const_iterator aHiddenIt = theHiddenObjects.begin();
+ aHiddenIt != theHiddenObjects.end(); aHiddenIt++)
+ {
+ if (myHiddenObjects.find(*aHiddenIt) != myHiddenObjects.end()) ///< found objects
+ myHiddenObjects.erase(*aHiddenIt);
+ }
+}
+
+//********************************************************************
+bool XGUI_FacesPanel::processAction(ModuleBase_ActionType theActionType)
+{
+ switch (theActionType) {
+ //case ActionEnter:
+ // return processEnter();
+ case ActionEscape:
+ setActivePanel(false);
+ return true;
+ case ActionDelete:
+ return processDelete();
+ //case ActionUndo:
+ //case ActionRedo:
+ default:
+ return false;
+ }
+}
+
+//********************************************************************
+void XGUI_FacesPanel::processSelection()
+{
+ QList<ModuleBase_ViewerPrsPtr> aSelected = myWorkshop->selection()->getSelected(
+ ModuleBase_ISelection::Viewer);
+ bool isModified = false;
+ for (int i = 0; i < aSelected.size(); i++) {
+ ModuleBase_ViewerPrsPtr aPrs = aSelected[i];
+ ObjectPtr anObject = aPrs->object();
+ if (!anObject.get())
+ continue;
+
+ if (ModuleBase_Tools::getSelectedShape(aPrs).ShapeType() != TopAbs_FACE)
+ continue;
+
+ myItems.insert(myLastItemIndex, aPrs);
+ myListView->addItem(generateName(aPrs), myLastItemIndex);
+ isModified = hideFace(myLastItemIndex) || isModified;
+
+ myLastItemIndex++;
+ }
+
+ if (isModified)
+ XGUI_Tools::workshop(myWorkshop)->displayer()->updateViewer();
+}
+
+//********************************************************************
+bool XGUI_FacesPanel::processDelete()
+{
+ //appendFirstSelectionInHistory();
+ QModelIndexList anIndices = myListView->getControl()->selectionModel()->selectedIndexes();
+
+ std::set<int> aSelectedIds;
+ myListView->getSelectedIndices(aSelectedIds);
+ if (aSelectedIds.empty())
+ return false;
+
+ bool isModified = false;
+ std::set<ObjectPtr> aRestoredObjects;
+ XGUI_Displayer* aDisplayer = XGUI_Tools::workshop(myWorkshop)->displayer();
+ for (std::set<int>::const_iterator anIt = aSelectedIds.begin(); anIt != aSelectedIds.end();
+ anIt++) {
+ ModuleBase_ViewerPrsPtr aPrs = myItems[*anIt];
+ if (aRestoredObjects.find(aPrs->object()) == aRestoredObjects.end())
+ aRestoredObjects.insert(aPrs->object());
+ myItems.remove(*anIt);
+ }
+ myListView->removeSelectedItems();
+
+ isModified = redisplayObjects(aRestoredObjects, true) || isModified;
+ if (isModified)
+ XGUI_Tools::workshop(myWorkshop)->displayer()->updateViewer();
+
+ // Restore selection
+ myListView->restoreSelection(anIndices);
+ //appendSelectionInHistory();
+ return true;
+}
+
+//********************************************************************
+bool XGUI_FacesPanel::redisplayObjects(
+ const std::set<std::shared_ptr<ModelAPI_Object> >& theObjects,
+ const bool isToFlushRedisplay)
+{
+ bool isModified = false;
+ XGUI_Displayer* aDisplayer = XGUI_Tools::workshop(myWorkshop)->displayer();
+ static Events_ID aDispEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
+
+ for (std::set<ObjectPtr>::const_iterator anIt = theObjects.begin(); anIt != theObjects.end();
+ anIt++)
+ {
+ ObjectPtr anObject = *anIt;
+ if (!anObject->isDisplayed()) {
+ // if the object was hidden by this panel
+ if (myHiddenObjects.find(anObject) != myHiddenObjects.end())
+ myHiddenObjects.erase(anObject);
+ anObject->setDisplayed(true); // it means that the object is hidden by hide all faces
+ ModelAPI_EventCreator::get()->sendUpdated(anObject, aDispEvent);
+ isModified = true;
+ //isModified = aDisplayer->display(anObject, false) || isModified;
+ }
+ else {
+ ModelAPI_EventCreator::get()->sendUpdated(anObject, aDispEvent);
+ isModified = true;
+ }
+ }
+ if (isToFlushRedisplay)
+ Events_Loop::loop()->flush(aDispEvent);
+ return isModified;
+}
+
+//********************************************************************
+bool XGUI_FacesPanel::hideFace(const int theIndex)
+{
+ XGUI_Displayer* aDisplayer = XGUI_Tools::workshop(myWorkshop)->displayer();
+
+ if (!myItems.contains(theIndex))
+ return false;
+
+ ModuleBase_ViewerPrsPtr aPrs = myItems[theIndex];
+
+ AISObjectPtr aAISObj = aDisplayer->getAISObject(aPrs->object());
+ if (aAISObj.get() == NULL)
+ return false;
+ Handle(ModuleBase_ResultPrs) aResultPrs = Handle(ModuleBase_ResultPrs)::DownCast(
+ aAISObj->impl<Handle(AIS_InteractiveObject)>());
+ if (aResultPrs.IsNull())
+ return false;
+ // set shape hidden to check whether the presentation should be erased from the viewer
+ bool isModified = false;
+ if (aResultPrs->hasSubShapeVisible(ModuleBase_Tools::getSelectedShape(aPrs)))
+ isModified = aDisplayer->redisplay(aPrs->object(), false) || isModified;
+ else
+ {
+ ObjectPtr anObject = aPrs->object();
+ myHiddenObjects.insert(anObject);
+ static Events_ID aDispEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
+ anObject->setDisplayed(false);
+ isModified = aDisplayer->erase(anObject, false) || isModified;
+ ModelAPI_EventCreator::get()->sendUpdated(anObject, aDispEvent);
+ Events_Loop::loop()->flush(aDispEvent);
+ }
+ return isModified;
+}
+
+//********************************************************************
+void XGUI_FacesPanel::closeEvent(QCloseEvent* theEvent)
+{
+ QDockWidget::closeEvent(theEvent);
+ emit closed();
+}
+
+//********************************************************************
+void XGUI_FacesPanel::activateSelection(bool toActivate)
+{
+ QIntList aShapeTypes;
+ aShapeTypes.append(TopAbs_FACE);
+
+ if (toActivate) {
+ myWorkshop->activateSubShapesSelection(aShapeTypes);
+ } else {
+ myWorkshop->deactivateSubShapesSelection();
+ }
+ if (toActivate)
+ activateSelectionFilters();
+ else
+ deactivateSelectionFilters();
+}
+
+//********************************************************************
+QString XGUI_FacesPanel::generateName(const ModuleBase_ViewerPrsPtr& thePrs)
+{
+ if (!thePrs.get() || !thePrs->object().get())
+ return "Undefined";
+
+ GeomShapePtr aContext;
+ ObjectPtr anObject = thePrs->object();
+ ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
+ if (aResult.get())
+ aContext = aResult->shape();
+ else {
+ // TODO if there is this case
+ }
+
+ QString aName = anObject->data()->name().c_str();
+ if (aContext.get()) {
+ GeomShapePtr aSubShape(new GeomAPI_Shape());
+ aSubShape->setImpl(new TopoDS_Shape(ModuleBase_Tools::getSelectedShape(thePrs)));
+ if (!aSubShape->isEqual(aContext))
+ aName += QString("_%1").arg(GeomAlgoAPI_CompoundBuilder::id(aContext, aSubShape));
+ }
+ return aName;
+}
+
+//********************************************************************
+bool XGUI_FacesPanel::customizeObject(const ObjectPtr& theObject, const bool isDisplayed)
+{
+ if (isDisplayed && myItems.isEmpty())
+ return false;
+
+ XGUI_Displayer* aDisplayer = XGUI_Tools::workshop(myWorkshop)->displayer();
+
+ AISObjectPtr aAISObj = aDisplayer->getAISObject(theObject);
+ if (aAISObj.get() == NULL)
+ return false;
+ Handle(ModuleBase_ResultPrs) aResultPrs = Handle(ModuleBase_ResultPrs)::DownCast(
+ aAISObj->impl<Handle(AIS_InteractiveObject)>());
+ if (aResultPrs.IsNull())
+ return false;
+
+ // if the object is displayed, the hidden faces are collected and set to the presentation
+ bool isModified = false;
+ NCollection_List<TopoDS_Shape> aHiddenSubShapes;
+ for (QMap<int, ModuleBase_ViewerPrsPtr>::const_iterator anIt = myItems.begin();
+ anIt != myItems.end(); anIt++) {
+ ModuleBase_ViewerPrsPtr aPrs = anIt.value();
+ if (aPrs.get() && aPrs->object() != theObject)
+ continue;
+ TopoDS_Shape aShape = ModuleBase_Tools::getSelectedShape(aPrs);
+ if (!aHiddenSubShapes.Contains(aShape))
+ aHiddenSubShapes.Append(aShape);
+ }
+ isModified = aResultPrs->setSubShapeHidden(aHiddenSubShapes);
+
+ return isModified;
+}
+
+//********************************************************************
+void XGUI_FacesPanel::onDeleteItem()
+{
+ processDelete();
+}
+
+//********************************************************************
+void XGUI_FacesPanel::onClosed()
+{
+ reset(true);
+}
--- /dev/null
+// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#ifndef XGUI_FacesPanel_H_
+#define XGUI_FacesPanel_H_
+
+#include "XGUI.h"
+
+#include <ModuleBase_ActionType.h>
+
+#include <QDockWidget>
+#include <QObject>
+#include <QMap>
+
+#include <set>
+
+class AIS_InteractiveObject;
+
+class ModelAPI_Object;
+class ModuleBase_IWorkshop;
+class ModuleBase_ListView;
+class ModuleBase_ViewerPrs;
+
+class QAction;
+class QCheckBox;
+class QEvent;
+
+/**
+* \ingroup GUI
+* A Hide Faces panel for making it possible to hide faces in the 3D view.
+* The panel has multi-selector filled by faces elements. When the control is active
+* it is possible to select faces in the viewer. The selected faces are hidden/transparent
+* after selection and the corresponding item is appeared in the multi selector.
+*
+* In order to redisplay a face, it is enough to click delete on the name of this face
+* in the multiselector.
+* When the panel is opened, the multiselector is empty.
+* When the panel is closed, the multiselector is emptied and the faces are displayed again.
+* The default position by of this dockable window is to the right of the view (in SALOME mode).
+* If no feature is processed (in neutral point), this panel can be activated too.
+* On feature edition start or finish, movement of the history line, undo/redo and other
+* modification of the model, the multiselector is emptied.
+*/
+class XGUI_EXPORT XGUI_FacesPanel : public QDockWidget
+{
+ Q_OBJECT
+public:
+ /// Constructor
+ /// \param theParent is a parent of the property panel
+ XGUI_FacesPanel(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop);
+ ~XGUI_FacesPanel() {}
+
+ /// Clear content of list widget
+ /// \param isToFlushRedisplay flag if redisplay should be flushed immediatelly
+ virtual void reset(const bool isToFlushRedisplay);
+
+ /// Returns whether the panel is active or not
+ bool isActivePanel() const { return myIsActive; }
+
+ /// Stores the state if panel is active and highlight the panel in an active color
+ /// \param theIsActive state whether the panel should be activated or deactivated
+ void setActivePanel(const bool theIsActive);
+
+ /// Returns true if the object is in internal container of hidden objects by this panel
+ /// \param theObject a checked object
+ /// \return boolean value
+ bool isObjectHiddenByPanel(const std::shared_ptr<ModelAPI_Object>& theObject) const
+ { return myHiddenObjects.find(theObject) != myHiddenObjects.end(); }
+
+ /// Removed faces of the objects from the panel
+ /// \param container of objects
+ void restoreObjects(const std::set<std::shared_ptr<ModelAPI_Object> >& theHiddenObjects);
+
+ /// Returns true if the event is processed. The default implementation is empty, returns false.
+ virtual bool processAction(ModuleBase_ActionType theActionType);
+
+ /// Append selected item in the list and customize presentations to hide faces
+ void processSelection();
+
+ /// Deletes item in a list of elements
+ /// \return whether the delete action is processed
+ bool processDelete();
+
+ /// Processing focus in/out for the faces control
+ /// \param theObject source object of event
+ /// \param theEvent an event
+ virtual bool eventFilter(QObject* theObject, QEvent *theEvent);
+
+ /// Hide/show faces of the object if:
+ /// - face selector is active
+ /// - object is mentioned in the list of selected elements
+ /// If the object is displayed, all panel faces selected on it will be moved into presentation
+ /// or, if redisplayed, fuction return if the object should be redisplayed or not
+ /// \param theObject a customized object
+ /// \param isDisplayed state if the object is displayed or redisplayed
+ /// \return true if the presentation is customized
+ bool customizeObject(const std::shared_ptr<ModelAPI_Object>& theObject, const bool isDisplayed);
+
+protected:
+ /// Add panel selection filters to the current viewer
+ virtual void activateSelectionFilters() {}
+
+ /// Remove panel selection filters from the current viewer
+ virtual void deactivateSelectionFilters() {}
+
+protected:
+ /// Reimplementation to emit a signal about the panel close
+ virtual void closeEvent(QCloseEvent* theEvent);
+
+signals:
+ /// Signal about activating pane
+ void activated();
+ /// Signal about deactivating pane
+ void deactivated();
+ /// Signal is emitted by the top widget cross button click
+ void closed();
+
+private:
+ /// Activate or deactivate selection and selection filters
+ void activateSelection(bool toActivate);
+
+ /// Redisplay or display objects. The viewer is not updated after redisplay.
+ /// \param theObjects container of objects
+ /// \param isToFlushRedisplay flag if redisplay should be flushed immediatelly
+ /// \return true if some of objects was redisplayed to update viewer
+ bool redisplayObjects(const std::set<std::shared_ptr<ModelAPI_Object> >& theObjects,
+ const bool isToFlushRedisplay);
+
+ /// Change the presentation to have the selected presentation hidden
+ /// \param theIndex an index of selected item that should be hidden
+ /// \return true if presentation is changed
+ bool hideFace(const int theIndex);
+
+ /// Generates a presentation name in form: <object_name>/<face>_<face_index>
+ /// \param thePrs a presentation
+ /// \return string value
+ static QString generateName(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
+
+protected slots:
+ /// Deletes element in list of items
+ void onDeleteItem();
+
+ /// Closes faces panel restore all hidden faces by calling reset()
+ void onClosed();
+
+protected:
+ QCheckBox* myHiddenOrTransparent; ///< if checked - transparent, else hidden
+ ModuleBase_ListView* myListView; ///< list control of processed faces
+ ModuleBase_IWorkshop* myWorkshop; ///< workshop
+
+ bool myIsActive; ///< current state about the panel is active
+ int myLastItemIndex; ///< last index to be used in the map of items for the next added item
+
+ QMap<int, std::shared_ptr<ModuleBase_ViewerPrs> > myItems; ///< selected face items
+ std::set<std::shared_ptr<ModelAPI_Object> > myHiddenObjects; ///< hidden objects
+};
+
+#endif
\ No newline at end of file
--- /dev/null
+// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#include <XGUI_FacesPanelSelector.h>
+
+#include <XGUI_FacesPanel.h>
+
+//********************************************************************
+XGUI_FacesPanelSelector::XGUI_FacesPanelSelector(XGUI_FacesPanel* thePanel)
+: myPanel(thePanel)
+{
+ connect(myPanel, SIGNAL(activated()), this, SIGNAL(activated()));
+ connect(myPanel, SIGNAL(deactivated()), this, SIGNAL(deactivated()));
+}
+
+//********************************************************************
+void XGUI_FacesPanelSelector::reset()
+{
+ myPanel->reset(true);
+}
+
+//********************************************************************
+void XGUI_FacesPanelSelector::setActive(const bool& isActive)
+{
+ myPanel->setActivePanel(isActive);
+}
+
+//********************************************************************
+void XGUI_FacesPanelSelector::processSelection()
+{
+ myPanel->processSelection();
+}
--- /dev/null
+// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#ifndef XGUI_FacesPanelSelector_H
+#define XGUI_FacesPanelSelector_H
+
+#include "XGUI.h"
+
+#include <XGUI_ActiveControlSelector.h>
+
+class XGUI_FacesPanel;
+
+/**
+* Processing selection by the faces panel.
+*/
+class XGUI_FacesPanelSelector : public XGUI_ActiveControlSelector
+{
+ Q_OBJECT
+
+public:
+ /// Constructor
+ /// \param thePanel the workshop faces panel
+ XGUI_EXPORT XGUI_FacesPanelSelector(XGUI_FacesPanel* thePanel);
+ /// Destructor
+ XGUI_EXPORT virtual ~XGUI_FacesPanelSelector() {};
+
+ /// Returns name of the selector
+ XGUI_EXPORT static QString Type() { return "XGUI_FacesPanelSelector"; }
+
+ /// Returns name of the selector
+ XGUI_EXPORT virtual QString getType() { return Type(); }
+
+ /// Set empty widget that need to be activated widget if it is not empty
+ XGUI_EXPORT virtual void reset();
+
+ /// Sets control active. It should activates/deactivates selection and selection filters.
+ /// \param isActive if true, the control becomes active
+ XGUI_EXPORT virtual void setActive(const bool& isActive);
+
+ /// Processes current selection of workshop. Reaction to selection change in workshop.
+ XGUI_EXPORT virtual void processSelection();
+
+protected:
+ XGUI_FacesPanel* myPanel; ///< processed panel
+};
+
+#endif
#include <ModuleBase_Tools.h>
+#include <XGUI_Workshop.h>
+
#include <QLayout>
#include <QLineEdit>
#include <QPixmap>
ObjectPtr aObj = aModel->object(theIndex);
if (aObj.get()) {
ResultPtr aResObj = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
+ XGUI_ObjectsBrowser* aObjBrowser = qobject_cast<XGUI_ObjectsBrowser*>(parent());
if (aResObj.get()) {
+ std::set<ObjectPtr> anObjects;
+ anObjects.insert(aResObj);
+ if (aObjBrowser && !aResObj->isDisplayed() &&
+ !aObjBrowser->workshop()->prepareForDisplay(anObjects))
+ return;
aResObj->setDisplayed(!aResObj->isDisplayed());
Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
update(theIndex);
}
// Update list of selected objects because this event happens after
// selection event in object browser
- XGUI_ObjectsBrowser* aObjBrowser = qobject_cast<XGUI_ObjectsBrowser*>(parent());
if (aObjBrowser) {
aObjBrowser->onSelectionChanged();
}
//
#include "XGUI_OperationMgr.h"
+
+#include "XGUI_ActiveControlMgr.h"
+#include "XGUI_ActiveControlSelector.h"
+#include "XGUI_FacesPanelSelector.h"
#include "XGUI_ModuleConnector.h"
#include "XGUI_Workshop.h"
#include "XGUI_ErrorMgr.h"
+#include "XGUI_FacesPanel.h"
#include "XGUI_Tools.h"
#include "XGUI_ObjectsBrowser.h"
#include "XGUI_ContextMenuMgr.h"
if (anActiveWgt)
isAccepted = anActiveWgt && anActiveWgt->processAction(ActionEscape);
}
+ if (!isAccepted)
+ {
+ XGUI_ActiveControlSelector* anActiveSelector =
+ XGUI_Tools::workshop(myWorkshop)->activeControlMgr()->activeSelector();
+ if (anActiveSelector && anActiveSelector->getType() == XGUI_FacesPanelSelector::Type())
+ isAccepted = XGUI_Tools::workshop(myWorkshop)->facesPanel()->processAction(ActionEscape);
+ }
// default Escape button functionality
if (!isAccepted && aOperation) {
onAbortOperation();
}
}
}
+ if (!isAccepted)
+ {
+ XGUI_ActiveControlSelector* anActiveSelector =
+ XGUI_Tools::workshop(myWorkshop)->activeControlMgr()->activeSelector();
+ if (anActiveSelector && anActiveSelector->getType() == XGUI_FacesPanelSelector::Type())
+ isAccepted = XGUI_Tools::workshop(myWorkshop)->facesPanel()->processAction(ActionDelete);
+ }
if (!isAccepted) {
// after widget, object browser and viewer should process delete
/// other widgets such as line edit controls should not lead to
// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
//
-#include <XGUI_PropertyPanel.h>
#include <XGUI_ActionsMgr.h>
+#include <XGUI_ActiveControlMgr.h>
+#include <XGUI_ActiveControlSelector.h>
+#include <XGUI_PropertyPanel.h>
+#include <XGUI_PropertyPanelSelector.h>
#include <XGUI_OperationMgr.h>
+#include <XGUI_Tools.h>
+#include <XGUI_Workshop.h>
+
//#include <AppElements_Constants.h>
#include <ModuleBase_WidgetMultiSelector.h>
#include <ModuleBase_Tools.h>
if (myActiveWidget)
myActiveWidget->deactivate();
+ XGUI_ActiveControlSelector* aPPSelector = XGUI_Tools::workshop(myOperationMgr->workshop())->
+ activeControlMgr()->getSelector(XGUI_PropertyPanelSelector::Type());
+ aPPSelector->reset(); // it removes need to be updated widget link
+
/// as the widgets are deleted later, it is important that the signals
/// of these widgets are not processed. An example of the error is issue 986.
/// In the given case, the property panel is firstly filled by new widgets
--- /dev/null
+// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#include <XGUI_PropertyPanelSelector.h>
+#include <XGUI_PropertyPanel.h>
+
+//********************************************************************
+XGUI_PropertyPanelSelector::XGUI_PropertyPanelSelector(XGUI_PropertyPanel* thePanel)
+: myPanel(thePanel), myWidgetToBeActivated (NULL)
+{
+ connect(myPanel, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)), this, SIGNAL(activated()));
+}
+
+//********************************************************************
+void XGUI_PropertyPanelSelector::reset()
+{
+ myWidgetToBeActivated = NULL;
+}
+
+//********************************************************************
+void XGUI_PropertyPanelSelector::setActive(const bool& isActive)
+{
+ if (isActive) {
+ if (myWidgetToBeActivated)
+ myPanel->activateWidget(myWidgetToBeActivated, true);
+ return;
+ }
+ ModuleBase_ModelWidget* aWidget = myPanel->activeWidget();
+ if (aWidget && aWidget->needToBeActiated())
+ {
+ myWidgetToBeActivated = aWidget;
+ }
+ myPanel->activateWidget(NULL, false);
+}
+
+//********************************************************************
+bool XGUI_PropertyPanelSelector::needToBeActiated() const
+{
+ return myWidgetToBeActivated != NULL;
+}
+
+//********************************************************************
+void XGUI_PropertyPanelSelector::processSelection()
+{
+ ModuleBase_ModelWidget* aWidget = myPanel->activeWidget();
+ if (!aWidget)
+ return;
+
+ aWidget->processAction(ActionSelection);
+}
--- /dev/null
+// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#ifndef XGUI_PropertyPanelSelector_H
+#define XGUI_PropertyPanelSelector_H
+
+#include "XGUI.h"
+
+#include <XGUI_ActiveControlSelector.h>
+
+class ModuleBase_ModelWidget;
+class XGUI_PropertyPanel;
+
+/**
+* Processing selection by the property panel.
+*/
+class XGUI_PropertyPanelSelector : public XGUI_ActiveControlSelector
+{
+ Q_OBJECT
+
+public:
+ /// Constructor
+ /// \param thePanel the workshop property panel
+ XGUI_EXPORT XGUI_PropertyPanelSelector(XGUI_PropertyPanel* thePanel);
+ /// Destructor
+ XGUI_EXPORT virtual ~XGUI_PropertyPanelSelector() {};
+
+ /// Returns name of the selector
+ XGUI_EXPORT static QString Type() { return "XGUI_PropertyPanelSelector"; }
+
+ /// Returns name of the selector
+ XGUI_EXPORT virtual QString getType() { return Type(); }
+
+ /// Clear need to be activated widget if it exists
+ XGUI_EXPORT virtual void reset();
+
+ /// Sets control active. It should activates/deactivates selection and selection filters.
+ /// \param isActive if true, the control becomes active
+ XGUI_EXPORT virtual void setActive(const bool& isActive);
+
+ /// Returns whether the selector should be activated as soon as possible (by deactivatate other)
+ /// \return boolean result
+ XGUI_EXPORT virtual bool needToBeActiated() const;
+
+ /// Processes current selection of workshop. Reaction to selection change in workshop.
+ XGUI_EXPORT virtual void processSelection();
+
+protected:
+ XGUI_PropertyPanel* myPanel; ///< processed panel
+ ModuleBase_ModelWidget* myWidgetToBeActivated; ///< used as need to be activated back
+
+};
+
+#endif
#include "XGUI_ViewerProxy.h"
#include "XGUI_ObjectsBrowser.h"
+#include "ModuleBase_BRepOwner.h"
#include "ModuleBase_ResultPrs.h"
-#include <ModuleBase_ViewerPrs.h>
+#include "ModuleBase_ViewerPrs.h"
#include <ModelAPI_Feature.h>
#include <ModelAPI_Tools.h>
#include "XGUI_Workshop.h"
#include "XGUI_ActionsMgr.h"
+#include "XGUI_ActiveControlMgr.h"
+#include "XGUI_ActiveControlSelector.h"
#include "XGUI_MenuMgr.h"
#include "XGUI_ColorDialog.h"
#include "XGUI_DeflectionDialog.h"
#include "XGUI_Displayer.h"
#include "XGUI_ErrorDialog.h"
#include "XGUI_ErrorMgr.h"
+#include "XGUI_FacesPanel.h"
+#include "XGUI_FacesPanelSelector.h"
#include "XGUI_ModuleConnector.h"
#include "XGUI_ObjectsBrowser.h"
#include "XGUI_OperationMgr.h"
#include "XGUI_PropertyPanel.h"
+#include "XGUI_PropertyPanelSelector.h"
#include "XGUI_PropertyDialog.h"
#include "XGUI_SalomeConnector.h"
#include "XGUI_Selection.h"
#include <ModelAPI_Feature.h>
#include <ModelAPI_Object.h>
#include <ModelAPI_ResultBody.h>
+#include <ModelAPI_ResultCompSolid.h>
#include <ModelAPI_ResultConstruction.h>
#include <ModelAPI_ResultGroup.h>
#include <ModelAPI_ResultParameter.h>
#include <ModelAPI_ResultField.h>
#include <ModelAPI_Session.h>
#include <ModelAPI_Validator.h>
-#include <ModelAPI_ResultCompSolid.h>
#include <ModelAPI_Tools.h>
//#include <PartSetPlugin_Part.h>
#include <dlfcn.h>
#endif
+//#define DEBUG_FACES_PANEL
+//#define DEBUG_WITH_MESSAGE_REPORT
+
QString XGUI_Workshop::MOVE_TO_END_COMMAND = QObject::tr("Move to the end");
//#define DEBUG_DELETE
//#define DEBUG_FEATURE_NAME
//#define DEBUG_CLEAN_HISTORY
+//******************************************************
XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
: QObject(),
myCurrentDir(QString()),
myModule(NULL),
mySalomeConnector(theConnector),
myPropertyPanel(0),
+ myFacesPanel(0),
myObjectBrowser(0),
myDisplayer(0)
//myViewerSelMode(TopAbs_FACE)
connect(mySelector, SIGNAL(selectionChanged()), this, SLOT(updateCommandStatus()));
myActionsMgr = new XGUI_ActionsMgr(this);
+ myActiveControlMgr = new XGUI_ActiveControlMgr(myModuleConnector);
myMenuMgr = new XGUI_MenuMgr(this);
myErrorDlg = new XGUI_ErrorDialog(QApplication::desktop());
myContextMenuMgr = new XGUI_ContextMenuMgr(this);
#endif
}
+//******************************************************
void XGUI_Workshop::activateModule()
{
myModule->activateSelectionFilters();
myOperationMgr->activate();
}
+//******************************************************
void XGUI_Workshop::deactivateModule()
{
myModule->deactivateSelectionFilters();
addHistoryMenu(aAction, SIGNAL(updateRedoHistory(const QList<ActionInfo>&)), SLOT(onRedo(int)));
salomeConnector()->addDesktopMenuSeparator("MEN_DESK_EDIT");
- //aAction = salomeConnector()->addDesktopCommand("REBUILD_CMD", tr("Rebuild"),
- // tr("Rebuild data objects"),
- // QIcon(":pictures/rebuild.png"), QKeySequence(),
- // false, "MEN_DESK_EDIT");
- //salomeConnector()->addActionInToolbar( aAction, aToolBarTitle );
-
- //connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onRebuild()));
- //salomeConnector()->addDesktopMenuSeparator("MEN_DESK_EDIT");
aAction = salomeConnector()->addDesktopCommand("SAVEAS_CMD", tr("Export native..."),
tr("Export the current document into a native file"),
SIGNAL(updateRedoHistory(const QList<ActionInfo>&)),
SLOT(onRedo(int)));
- //aCommand = aGroup->addFeature("REBUILD_CMD", tr("Rebuild"), tr("Rebuild data objects"),
- // QIcon(":pictures/rebuild.png"), QKeySequence());
- //aCommand->connectTo(this, SLOT(onRebuild()));
-
- //aCommand->disable();
-
aCommand = aGroup->addFeature("OPEN_CMD", tr("Open..."), tr("Open a new document"),
QIcon(":pictures/open.png"), QKeySequence::Open);
aCommand->connectTo(this, SLOT(onOpen()));
}
#ifndef HAVE_SALOME
+//******************************************************
AppElements_Workbench* XGUI_Workshop::addWorkbench(const QString& theName)
{
AppElements_MainMenu* aMenuBar = myMainWindow->menuObject();
return aHasNested;
}
+//******************************************************
void XGUI_Workshop::fillPropertyPanel(ModuleBase_Operation* theOperation)
{
ModuleBase_OperationFeature* aFOperation =
if (!aFOperation)
return;
- showPropertyPanel();
+ showPanel(myPropertyPanel);
myPropertyPanel->cleanContent();
QList<ModuleBase_ModelWidget*> aWidgets;
myErrorMgr->setPropertyPanel(myPropertyPanel);
}
+//******************************************************
void XGUI_Workshop::connectToPropertyPanel(const bool isToConnect)
{
XGUI_PropertyPanel* aPropertyPanel = propertyPanel();
ModuleBase_ISelection* aSel = mySelector->selection();
QObjectPtrList aObj = aSel->selectedPresentations();
//!< No need for property panel
- hidePropertyPanel();
+ hidePanel(myPropertyPanel);
myPropertyPanel->cleanContent();
connectToPropertyPanel(false);
activateObjectsSelection(anObjects);
}
-
+//******************************************************
void XGUI_Workshop::onOperationCommitted(ModuleBase_Operation* theOperation)
{
myModule->operationCommitted(theOperation);
}
+//******************************************************
void XGUI_Workshop::onOperationAborted(ModuleBase_Operation* theOperation)
{
myModule->operationAborted(theOperation);
}
+//******************************************************
void XGUI_Workshop::setGrantedFeatures(ModuleBase_Operation* theOperation)
{
ModuleBase_OperationFeature* aFOperation =
myDisplayer->updateViewer();
}
-//******************************************************
-//void XGUI_Workshop::onRebuild()
-//{
-// SessionPtr aMgr = ModelAPI_Session::get();
-// bool aWasOperation = aMgr->isOperation(); // keep this value
-// if (!aWasOperation) {
-// aMgr->startOperation("Rebuild");
-// }
-// static const Events_ID aRebuildEvent = Events_Loop::loop()->eventByName("Rebuild");
-// Events_Loop::loop()->send(std::shared_ptr<Events_Message>(
-// new Events_Message(aRebuildEvent, this)));
-// if (!aWasOperation) {
-// aMgr->finishOperation();
-// }
-// updateCommandStatus();
-//}
-
//******************************************************
void XGUI_Workshop::onWidgetStateChanged(int thePreviousState)
{
}
}
+//******************************************************
void XGUI_Workshop::onWidgetObjectUpdated()
{
operationMgr()->onValidateOperation();
}
+//******************************************************
ModuleBase_IModule* XGUI_Workshop::loadModule(const QString& theModule)
{
QString libName = QString::fromStdString(library(theModule.toStdString()));
emit commandStatusUpdated();
}
+//******************************************************
void XGUI_Workshop::updateHistory()
{
std::list<std::string> aUndoList = ModelAPI_Session::get()->undoList();
QDockWidget* aObjDock = createObjectBrowser(aDesktop);
aDesktop->addDockWidget(Qt::LeftDockWidgetArea, aObjDock);
myPropertyPanel = new XGUI_PropertyPanel(aDesktop, myOperationMgr);
+ myActiveControlMgr->addSelector(new XGUI_PropertyPanelSelector(myPropertyPanel));
+
myPropertyPanel->setupActions(myActionsMgr);
myPropertyPanel->setAllowedAreas(Qt::LeftDockWidgetArea |
Qt::RightDockWidgetArea |
Qt::BottomDockWidgetArea);
aDesktop->addDockWidget(Qt::LeftDockWidgetArea, myPropertyPanel);
- hidePropertyPanel(); ///<! Invisible by default
+ hidePanel(myPropertyPanel); ///<! Invisible by default
+
+ myFacesPanel = new XGUI_FacesPanel(aDesktop, myModuleConnector);
+ myActiveControlMgr->addSelector(new XGUI_FacesPanelSelector(myFacesPanel));
+ myFacesPanel->setAllowedAreas(Qt::LeftDockWidgetArea |
+ Qt::RightDockWidgetArea |
+ Qt::BottomDockWidgetArea);
+ connect(myFacesPanel, SIGNAL(closed()), myFacesPanel, SLOT(onClosed()));
+
+ aDesktop->addDockWidget(
+#ifdef HAVE_SALOME
+ Qt::RightDockWidgetArea,
+#else
+ Qt::LeftDockWidgetArea,
+#endif
+ myFacesPanel);
+ hidePanel(myFacesPanel); ///<! Invisible by default
+
+#ifdef DEBUG_FACES_PANEL
+ aDesktop->addDockWidget(Qt::RightDockWidgetArea, myFacesPanel);
+ showPanel(myFacesPanel);
+#endif
+
hideObjectBrowser();
+
+#ifdef DEBUG_FACES_PANEL
+#else
+#ifndef HAVE_SALOME
+ aDesktop->tabifyDockWidget(myFacesPanel, aObjDock);
+#endif
+#endif
+
aDesktop->tabifyDockWidget(aObjDock, myPropertyPanel);
myPropertyPanel->installEventFilter(myOperationMgr);
}
//******************************************************
-void XGUI_Workshop::showPropertyPanel()
+void XGUI_Workshop::showPanel(QDockWidget* theDockWidget)
{
- QAction* aViewAct = myPropertyPanel->toggleViewAction();
- ///<! Restore ability to close panel from the window's menu
- aViewAct->setEnabled(true);
- myPropertyPanel->show();
- myPropertyPanel->raise();
+ if (theDockWidget == myPropertyPanel) {
+ QAction* aViewAct = myPropertyPanel->toggleViewAction();
+ ///<! Restore ability to close panel from the window's menu
+ aViewAct->setEnabled(true);
+ }
+ theDockWidget->show();
+ theDockWidget->raise();
// The next code is necessary to made the property panel the active window
// in order to operation manager could process key events of the panel.
// otherwise they are ignored. It happens only if the same(activateWindow) is
// not happened by property panel activation(e.g. resume operation of Sketch)
- ModuleBase_Tools::setFocus(myPropertyPanel, "XGUI_Workshop::showPropertyPanel()");
+ ModuleBase_Tools::setFocus(theDockWidget, "XGUI_Workshop::showPanel()");
}
//******************************************************
-void XGUI_Workshop::hidePropertyPanel()
+void XGUI_Workshop::hidePanel(QDockWidget* theDockWidget)
{
- QAction* aViewAct = myPropertyPanel->toggleViewAction();
- ///<! Do not allow to show empty property panel
- aViewAct->setEnabled(false);
- myPropertyPanel->hide();
+ if (theDockWidget && theDockWidget == myPropertyPanel) {
+ QAction* aViewAct = theDockWidget->toggleViewAction();
+ ///<! Do not allow to show empty property panel
+ aViewAct->setEnabled(false);
+ }
+ theDockWidget->hide();
// the property panel is active window of the desktop, when it is
// hidden, it is undefined which window becomes active. By this reason
// are processed by this console. For example Undo actions.
// It is possible that this code is to be moved to SHAPER package
QMainWindow* aDesktop = desktop();
- ModuleBase_Tools::setFocus(aDesktop, "XGUI_Workshop::showPropertyPanel()");
+ ModuleBase_Tools::setFocus(aDesktop, "XGUI_Workshop::hidePanel()");
}
//******************************************************
if (!aContext.IsNull())
aParameters.Append(aContext);
+#ifdef DEBUG_WITH_MESSAGE_REPORT
+ Handle(Message_Report) aContextReport = aContext->GetReport();
+ aContextReport->SetActive (Standard_True);
+ aContextReport->SetLimit (1000);
+ if (!aContextReport.IsNull())
+ aParameters.Append(aContextReport);
+#endif
MyVCallBack = new VInspector_CallBack();
myDisplayer->setCallBack(MyVCallBack);
#ifndef HAVE_SALOME
MyTCommunicator->RegisterPlugin("TKDFBrowser");
MyTCommunicator->RegisterPlugin("TKShapeView");
MyTCommunicator->RegisterPlugin("TKVInspector");
+#ifdef DEBUG_WITH_MESSAGE_REPORT
+ MyTCommunicator->RegisterPlugin("TKMessageView");
+#endif
MyTCommunicator->RegisterPlugin("SMBrowser"); // custom plugin to view ModelAPI
//MyTCommunicator->RegisterPlugin("TKSMBrowser"); // custom plugin to view ModelAPI
MyTCommunicator->Init(aParameters);
MyTCommunicator->Activate("TKSMBrowser"); // to have button in TInspector
+#ifndef DEBUG_WITH_MESSAGE_REPORT
MyTCommunicator->Activate("TKVInspector"); // to have filled callback by model
+#endif
MyTCommunicator->Activate("TKDFBrowser");
+
+#ifdef DEBUG_WITH_MESSAGE_REPORT
+ MyTCommunicator->Activate("TKMessageView"); // temporary
+ MyTCommunicator->Activate("TKVInspector"); // to have filled callback by model
+#endif
}
MyTCommunicator->SetVisible(true);
}
//**************************************************************
void XGUI_Workshop::setViewerSelectionMode(int theMode)
{
+ XGUI_ActiveControlSelector* anActiveSelector = activeControlMgr()->activeSelector();
+ if (anActiveSelector && anActiveSelector->getType() == XGUI_FacesPanelSelector::Type())
+ facesPanel()->setActivePanel(false);
+
if (theMode == -1)
myViewerSelMode.clear();
else {
myDisplayer->activateObjects(aModes, theList);
}
+//**************************************************************
+bool XGUI_Workshop::prepareForDisplay(const std::set<ObjectPtr>& theObjects) const
+{
+ // generate container of objects taking into account sub elments of compsolid
+ std::set<ObjectPtr> anAllProcessedObjects;
+ for (std::set<ObjectPtr>::const_iterator anObjectsIt = theObjects.begin();
+ anObjectsIt != theObjects.end(); anObjectsIt++) {
+ ObjectPtr anObject = *anObjectsIt;
+ ResultCompSolidPtr aCompRes = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(anObject);
+ if (aCompRes.get()) {
+ if (aCompRes->numberOfSubs(true) == 0)
+ anAllProcessedObjects.insert(anObject);
+ else {
+ for (int i = 0; i < aCompRes->numberOfSubs(true); i++) {
+ ResultPtr aSubRes = aCompRes->subResult(i, true);
+ anAllProcessedObjects.insert(aCompRes->subResult(i, true));
+ }
+ }
+ }
+ else
+ anAllProcessedObjects.insert(anObject);
+ }
+
+ // find hidden objects in faces panel
+ std::set<ObjectPtr> aHiddenObjects;
+ QStringList aHiddenObjectNames;
+ for (std::set<ObjectPtr>::const_iterator anObjectsIt = theObjects.begin();
+ anObjectsIt != theObjects.end(); anObjectsIt++) {
+ if (!facesPanel()->isObjectHiddenByPanel(*anObjectsIt))
+ continue;
+ aHiddenObjects.insert(*anObjectsIt);
+ aHiddenObjectNames.append((*anObjectsIt)->data()->name().c_str());
+ }
+ if (aHiddenObjects.empty())
+ return true;
+
+ int anAnswer = QMessageBox::question(
+ desktop(), tr("Show object"),
+ tr("The following objects are hidden by the '%1' panel:\n %2.\
+ \nRemove objects from the panel to be displayed?")
+ .arg(facesPanel()->windowTitle()).arg(aHiddenObjectNames.join(','),
+ QMessageBox::Yes | QMessageBox::No, QMessageBox::No));
+
+ bool aToBeDisplayed = anAnswer == QMessageBox::Yes;
+ if (aToBeDisplayed)
+ facesPanel()->restoreObjects(aHiddenObjects);
+
+ return aToBeDisplayed;
+}
+
//**************************************************************
void XGUI_Workshop::deleteObjects()
{
return ModelAPI_Tools::removeFeaturesAndReferences(aFeatures);
}
+//******************************************************
bool hasResults(QObjectPtrList theObjects, const std::set<std::string>& theTypes)
{
bool isFoundResultType = false;
return std::list<FeaturePtr>(aObjectIt, aCurrentIt);
}
+//******************************************************
bool XGUI_Workshop::canMoveFeature()
{
QString anActionId = "MOVE_CMD";
return false;
}
+//******************************************************
void setColor(ResultPtr theResult, const std::vector<int>& theColor)
{
if (!theResult.get())
for (int i = 0; i < aDoc->size(aGroupName); i++) { \
aDoc->object(aGroupName, i)->setDisplayed(aDisplay); \
}
+
+//******************************************************
void XGUI_Workshop::showObjects(const QObjectPtrList& theList, bool isVisible)
{
+ if (isVisible) {
+ std::set<ObjectPtr> anObjects;
+ foreach (ObjectPtr aObj, theList) {
+ anObjects.insert(aObj);
+ }
+ if (!prepareForDisplay(anObjects))
+ return;
+ }
+
foreach (ObjectPtr aObj, theList) {
aObj->setDisplayed(isVisible);
}
viewer()->eraseAll();
#endif
+ std::set<ObjectPtr> anObjects;
+ foreach (ObjectPtr aObj, theList) {
+ anObjects.insert(aObj);
+ }
+
+ if (!prepareForDisplay(anObjects))
+ return;
+
// Show only objects from the list
foreach (ObjectPtr aObj, theList) {
aObj->setDisplayed(true);
#endif
}
-
//**************************************************************
void XGUI_Workshop::registerValidators() const
{
//objectBrowser()->dataModel()->blockEventsProcessing(isBlocked);
}
+//******************************************************
void XGUI_Workshop::addHistoryMenu(QObject* theObject, const char* theSignal, const char* theSlot)
{
XGUI_HistoryMenu* aMenu = NULL;
connect(aMenu, SIGNAL(actionSelected(int)), this, theSlot);
}
+//******************************************************
QList<ActionInfo> XGUI_Workshop::processHistoryList(const std::list<std::string>& theList) const
{
QList<ActionInfo> aResult;
return aResult;
}
+//******************************************************
void XGUI_Workshop::setStatusBarMessage(const QString& theMessage)
{
#ifdef HAVE_SALOME
#endif
}
+//******************************************************
void XGUI_Workshop::synchronizeViewer()
{
SessionPtr aMgr = ModelAPI_Session::get();
}
}
+//******************************************************
void XGUI_Workshop::synchronizeGroupInViewer(const DocumentPtr& theDoc,
const std::string& theGroup,
bool theUpdateViewer)
myDisplayer->updateViewer();
}
+//******************************************************
void XGUI_Workshop::highlightResults(const QObjectPtrList& theObjects)
{
FeaturePtr aFeature;
tr("Results not found"), QMessageBox::Ok);
}
+//******************************************************
void XGUI_Workshop::highlightFeature(const QObjectPtrList& theObjects)
{
ResultPtr aResult;
aMgr->startOperation();
aDoc->removeFromFolder(aFeatures, isBefore);
aMgr->finishOperation();
-}
\ No newline at end of file
+}
#endif
class XGUI_ActionsMgr;
+class XGUI_ActiveControlMgr;
class XGUI_ContextMenuMgr;
class XGUI_Displayer;
class XGUI_ErrorDialog;
class XGUI_ErrorMgr;
+class XGUI_FacesPanel;
class XGUI_MenuMgr;
class XGUI_ModuleConnector;
class XGUI_ObjectsBrowser;
return myActionsMgr;
}
+ //! ! Returns an active control manager
+ XGUI_ActiveControlMgr* activeControlMgr() const
+ {
+ return myActiveControlMgr;
+ }
+
//! ! Returns an actions manager
XGUI_MenuMgr* menuMgr() const
{
return myPropertyPanel;
}
+ //! Returns panel for hide object faces
+ XGUI_FacesPanel* facesPanel() const
+ {
+ return myFacesPanel;
+ }
+
//! Returns context menu manager object
XGUI_ContextMenuMgr* contextMenuMgr() const
{
/// \return a desktop instance
QMainWindow* desktop() const;
+ /// If faces panel made the object hidden, show message box whether the object should be
+ /// restored (removed from the panel) and displayed, if answer is No, returns false
+ /// \param theObject a model object
+ /// \return boolean state if the object should not be displayed
+ virtual bool prepareForDisplay(const std::set<ObjectPtr>& theObjects) const;
+
//! Delete features
void deleteObjects();
/// Redo previous command
void onRedo(int times = 1);
- // Rebuild data tree
- //void onRebuild();
-
/// Validates the operation to change the "Apply" button state.
/// \param thePreviousState the previous state of the widget
void onWidgetStateChanged(int thePreviousState);
/// Listens the corresponded signal of model widget and updates Apply button state by feature
void onWidgetObjectUpdated();
- /// Show property panel
- void showPropertyPanel();
+ /// Show dock widget panel
+ void showPanel(QDockWidget* theDockWidget);
- /// Hide property panel
- void hidePropertyPanel();
+ /// Hide dock widget panel
+ void hidePanel(QDockWidget* theDockWidget);
/// Show object Browser
void showObjectBrowser();
XGUI_ErrorMgr* myErrorMgr;
XGUI_ObjectsBrowser* myObjectBrowser;
XGUI_PropertyPanel* myPropertyPanel;
+ XGUI_FacesPanel* myFacesPanel; //< panel for hide object faces
XGUI_SelectionMgr* mySelector;
XGUI_Displayer* myDisplayer;
XGUI_OperationMgr* myOperationMgr; ///< manager to manipulate through the operations
XGUI_ActionsMgr* myActionsMgr;
+ XGUI_ActiveControlMgr* myActiveControlMgr; ///< manager to have none or one active control
XGUI_MenuMgr* myMenuMgr; ///< manager to build menu/tool bar using order defined in XML
XGUI_SalomeConnector* mySalomeConnector;
XGUI_ErrorDialog* myErrorDlg;
//
#include "XGUI_WorkshopListener.h"
-#include "XGUI_Workshop.h"
-#include "XGUI_Displayer.h"
-#include "XGUI_ErrorMgr.h"
-#include "XGUI_OperationMgr.h"
-#include "XGUI_SalomeConnector.h"
-#include "XGUI_ActionsMgr.h"
-#include "XGUI_PropertyPanel.h"
-#include "XGUI_ModuleConnector.h"
-#include "XGUI_QtEvents.h"
-#include "XGUI_SelectionMgr.h"
#ifndef HAVE_SALOME
#include <AppElements_MainWindow.h>
#endif
-#include <ModuleBase_IModule.h>
-#include <ModuleBase_Events.h>
+#include <Config_FeatureMessage.h>
+#include <Config_PointerMessage.h>
+#include <Config_Keywords.h>
+
+#include <Events_InfoMessage.h>
+#include <Events_Loop.h>
+#include <Events_LongOp.h>
#include <ModelAPI_Object.h>
#include <ModelAPI_Events.h>
#include <ModelAPI_ResultCompSolid.h>
#include <ModelAPI_Tools.h>
-#include <Events_Loop.h>
-#include <Events_LongOp.h>
-
+#include <ModuleBase_Events.h>
+#include <ModuleBase_IModule.h>
+#include <ModuleBase_IViewer.h>
#include <ModuleBase_IWorkshop.h>
-
#include <ModuleBase_Operation.h>
#include <ModuleBase_OperationDescription.h>
#include <ModuleBase_OperationFeature.h>
#include <ModuleBase_Tools.h>
-#include <ModuleBase_IViewer.h>
#include <ModuleBase_WidgetSelector.h>
-#include <Config_FeatureMessage.h>
-#include <Config_PointerMessage.h>
-#include <Config_Keywords.h>
-#include <Events_InfoMessage.h>
+#include "XGUI_ActionsMgr.h"
+#include "XGUI_Displayer.h"
+#include "XGUI_ErrorMgr.h"
+#include "XGUI_FacesPanel.h"
+#include "XGUI_OperationMgr.h"
+#include "XGUI_ModuleConnector.h"
+#include "XGUI_PropertyPanel.h"
+#include "XGUI_QtEvents.h"
+#include "XGUI_SalomeConnector.h"
+#include "XGUI_SelectionMgr.h"
+#include "XGUI_Workshop.h"
+
+#include <QAction>
#include <QApplication>
#include <QMainWindow>
#include <QThread>
-#include <QAction>
#ifdef _DEBUG
#include <QDebug>
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_UPDATE_VIEWER_UNBLOCKED));
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_EMPTY_AIS_PRESENTATION));
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_UPDATE_BY_WIDGET_SELECTION));
+
+ aLoop->registerListener(this, Events_Loop::eventByName("FinishOperation"));
+ aLoop->registerListener(this, Events_Loop::eventByName("AbortOperation"));
}
//******************************************************
if (aWidgetSelector)
workshop()->selector()->setSelected(aWidgetSelector->getAttributeSelection());
}
- }
+ } else if (theMessage->eventID() == Events_Loop::eventByName("FinishOperation") ||
+ theMessage->eventID() == Events_Loop::eventByName("AbortOperation"))
+ workshop()->facesPanel()->reset(false); // do not flush redisplay, it is flushed after event
//Update property panel on corresponding message. If there is no current operation (no
//property panel), or received message has different feature to the current - do nothing.