// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+#include "PartSet_WidgetFeaturePointSelector.h"
+#include "PartSet_Tools.h"
+#include "PartSet_ExternalObjectsMgr.h"
+
#include <Config_WidgetAPI.h>
#include <Events_Loop.h>
#include <ModuleBase_IWorkshop.h>
#include <ModuleBase_IModule.h>
-#include "PartSet_WidgetFeaturePointSelector.h"
-#include "PartSet_Tools.h"
-
#include <SketchPlugin_Point.h>
#include <XGUI_Tools.h>
myPreviewObjectAttribute = anAttributesList[2].toStdString();
myPreviewPointAttribute = anAttributesList[3].toStdString();
}
+ myExternalObjectMgr = new PartSet_ExternalObjectsMgr(theData->getProperty("use_external"),
+ theData->getProperty("can_create_external"), true);
}
PartSet_WidgetFeaturePointSelector::~PartSet_WidgetFeaturePointSelector()
{
+ delete myExternalObjectMgr;
}
//********************************************************************
if (theEvent->button() != Qt::LeftButton)
return;
+ ModuleBase_ISelection* aSelection = myWorkshop->selection();
+ QList<ModuleBase_ViewerPrsPtr> aSelected = aSelection->getSelected(ModuleBase_ISelection::Viewer);
+
+ ModuleBase_ViewerPrsPtr aPrs =
+ !aSelected.empty() ? aSelected.first() : ModuleBase_ViewerPrsPtr();
+ if (aPrs.get() && aPrs->object().get()) {
+ myPreviewObject = aSelection->getResult(aPrs);
+ GeomShapePtr aShape = aSelection->getShape(aPrs);
+ myExternalObjectMgr->getGeomSelection(aPrs, myPreviewObject, aShape,
+ myWorkshop, sketch(), true);
+ }
+ myPreviewPoint = PartSet_Tools::getPnt2d(theEvent, theWindow, mySketch);
+
ObjectPtr aPreviewObject;
GeomPnt2dPtr aPreviewPoint;
if (myHasPreview) {
// sub-segments in the viewer, secondly preselection of restart operation is processed by
// special reentrant message sent by the feature
}
+
+//********************************************************************
+void PartSet_WidgetFeaturePointSelector::getGeomSelection(const ModuleBase_ViewerPrsPtr& thePrs,
+ ObjectPtr& theObject, GeomShapePtr& theShape)
+{
+ ModuleBase_WidgetShapeSelector::getGeomSelection(thePrs, theObject, theShape);
+
+ myExternalObjectMgr->getGeomSelection(thePrs, theObject, theShape,
+ myWorkshop, sketch(), myIsInValidate);
+ myPreviewObject = theObject;
+}
+
+//********************************************************************
+void PartSet_WidgetFeaturePointSelector::restoreAttributeValue(const AttributePtr& theAttribute,
+ const bool theValid)
+{
+ ModuleBase_WidgetShapeSelector::restoreAttributeValue(theAttribute, theValid);
+ myExternalObjectMgr->removeExternal(sketch(), myFeature, myWorkshop, true);
+ myPreviewObject = ObjectPtr();
+}
class Config_WidgetAPI;
class ModuleBase_IViewWindow;
class ModuleBase_ViewerPrs;
+class PartSet_ExternalObjectsMgr;
class GeomAPI_Pnt;
class GeomAPI_Pnt2d;
/// a shape. If the attribute do not uses the shape, it is empty
virtual QList<std::shared_ptr<ModuleBase_ViewerPrs>> getAttributeSelection() const;
-protected:
/// The methiod called when widget is activated
virtual void activateCustom();
+ /// Return an object and geom shape by the viewer presentation
+ /// \param thePrs a selection
+ /// \param theObject an output object
+ /// \param theShape a shape of the selection
+ virtual void getGeomSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs,
+ ObjectPtr& theObject, GeomShapePtr& theShape);
+
+ /// Creates a backup of the current values of the attribute
+ /// It should be realized in the specific widget because of different
+ /// parameters of the current attribute
+ /// \param theAttribute an attribute
+ /// \param theValid a boolean flag, if restore happens for valid parameters
+ void restoreAttributeValue(const AttributePtr& theAttribute, const bool theValid);
+
protected:
bool fillFeature(const std::shared_ptr<ModuleBase_ViewerPrs>& theSelectedPrs,
ModuleBase_IViewWindow* theWnd,
bool myHasPreview;
std::shared_ptr<ModelAPI_Object> myPreviewObject;
std::shared_ptr<GeomAPI_Pnt2d> myPreviewPoint;
+ PartSet_ExternalObjectsMgr* myExternalObjectMgr; ///< reference to external objects manager
};
#endif
\ No newline at end of file