-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
#include "ModuleBase_ISelection.h"
+//********************************************************************
+ResultPtr ModuleBase_ISelection::getResult(const ModuleBase_ViewerPrs& thePrs)
+{
+ ResultPtr aResult;
+
+ if (!thePrs.owner().IsNull()) {
+ ObjectPtr anObject = getSelectableObject(thePrs.owner());
+ aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
+ }
+ else {
+ aResult = std::dynamic_pointer_cast<ModelAPI_Result>(thePrs.object());
+ }
+
+ return aResult;
+}
+
+//********************************************************************
+GeomShapePtr ModuleBase_ISelection::getShape(const ModuleBase_ViewerPrs& thePrs)
+{
+ GeomShapePtr aShape;
+
+ const TopoDS_Shape& aTDSShape = thePrs.shape();
+ // if only result is selected, an empty shape is set to the model
+ if (aTDSShape.IsNull()) {
+ }
+ else {
+ aShape = GeomShapePtr(new GeomAPI_Shape());
+ aShape->setImpl(new TopoDS_Shape(aTDSShape));
+ // If the result object is built on the same shape, the result shape here is empty one
+ ResultPtr aResult = getResult(thePrs);
+ if (aResult.get() && aShape->isEqual(aResult->shape()))
+ aShape = GeomShapePtr();
+ }
+ return aShape;
+}
+
+//********************************************************************
QList<ModuleBase_ViewerPrs> ModuleBase_ISelection::getViewerPrs(const QObjectPtrList& theObjects)
{
QList<ModuleBase_ViewerPrs> aSelectedPrs;
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
// File: ModuleBase_ISelection.h
// Created: 2 June 2014
#include "ModuleBase_Definitions.h"
#include "ModuleBase_ViewerPrs.h"
+#include <ModelAPI_Result.h>
+#include <GeomAPI_Shape.h>
+
#include <QModelIndexList>
#include <AIS_ListOfInteractive.hxx>
#include <NCollection_List.hxx>
virtual void selectedShapes(NCollection_List<TopoDS_Shape>& theList,
std::list<ObjectPtr>& theOwners) const = 0;
+ //! Return the shape from the viewer presentation.
+ //! If the shape is equal to the shape of selected object, it returns an empty shape
+ //! \param thePrs a selected object
+ //! \return a shape
+ MODULEBASE_EXPORT ResultPtr getResult(const ModuleBase_ViewerPrs& thePrs);
+
+ //! Return the shape from the viewer presentation.
+ //! If the shape is equal to the shape of selected object, it returns an empty shape
+ //! \param thePrs a selected object
+ //! \return a shape
+ MODULEBASE_EXPORT GeomShapePtr getShape(const ModuleBase_ViewerPrs& thePrs);
+
//! Wraps the object list into the viewer prs list
//! \param theObjects a list of objects
//! \return a list of prs, where only object is not empty
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
#include <ModuleBase_WidgetValidated.h>
#include <ModuleBase_FilterFactory.h>
//********************************************************************
bool ModuleBase_WidgetValidated::isValidSelection(const ModuleBase_ViewerPrs& theValue)
{
+ bool aValid = isValidSelectionCustom(theValue);
+ if (!aValid)
+ return aValid;
+
DataPtr aData = myFeature->data();
AttributePtr anAttribute = myFeature->attribute(attributeID());
storeAttributeValue();
// saves the owner value to the widget attribute
- bool aValid = setSelectionCustom(theValue);
-
+ aValid = setSelectionCustom(theValue);
if (aValid)
// checks the attribute validity
aValid = isValidAttribute();
return aValid;
}
+//********************************************************************
+bool ModuleBase_WidgetValidated::isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs)
+{
+ return true;
+}
+
//********************************************************************
bool ModuleBase_WidgetValidated::isValidAttribute() const
{
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
// File: ModuleBase_WidgetValidated.h
// Created: 12 Mar 2015
virtual ~ModuleBase_WidgetValidated();
/// Checks all widget validator if the owner is valid
- /// \param theOwner a selected owner in the view
+ /// \param theValue a selected presentation in the view
/// \return a boolean value
bool isValidSelection(const ModuleBase_ViewerPrs& theValue);
/// \param theValid a boolean flag, if restore happens for valid parameters
virtual void restoreAttributeValue(const bool theValid) = 0;
+ /// Checks the widget validity. By default, it returns true.
+ /// \param theValue a selected presentation in the view
+ /// \return a boolean value
+ virtual bool isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs);
+
/// Fills the attribute with the value of the selected owner
/// \param theOwner a selected owner
virtual bool setSelectionCustom(const ModuleBase_ViewerPrs& thePrs) = 0;
/// \param theAIS a presentation object
virtual void onObjectDisplayed(ObjectPtr theObject, AISObjectPtr theAIS);
+ /// Called on transformation in current viewer
+ /// \param theTrsfType type of tranformation
+ void onViewTransformed(int theTrsfType = 2);
+
protected slots:
/// Called when previous operation is finished
virtual void onSelectionChanged();
/// Processing of vertex selected
void onVertexSelected();
- /// Called on transformation in current viewer
- /// \param theTrsfType type of tranformation
- void onViewTransformed(int theTrsfType = 2);
-
void onTreeViewDoubleClick(const QModelIndex&);
private:
void PartSet_SketcherMgr::startSketch(ModuleBase_Operation* theOperation)
{
+ myModule->onViewTransformed();
+
// Display all sketcher sub-Objects
myCurrentSketch = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(theOperation->feature());
XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
AIS_ListIteratorOfListOfInteractive aLIt(aPrsList);
for(aLIt.Initialize(aPrsList); aLIt.More(); aLIt.Next()){
anAISIO = aLIt.Value();
- activate(anAISIO, myActiveSelectionModes, theUpdateViewer);
+ activate(anAISIO, myActiveSelectionModes, false);
}
+ if (theUpdateViewer)
+ updateViewer();
}
bool XGUI_Displayer::isActive(ObjectPtr theObject) const