ModuleBase_WidgetSwitch.h
ModuleBase_WidgetShapeSelector.h
ModuleBase_IWorkshop.h
- ModuleBase_WidgetValue.h
- ModuleBase_WidgetValueFeature.h
ModuleBase_Definitions.h
ModuleBase_SelectionValidator.h
ModuleBase_ISelection.h
ModuleBase_WidgetFactory.cpp
ModuleBase_WidgetSwitch.cpp
ModuleBase_WidgetShapeSelector.cpp
- ModuleBase_WidgetValue.cpp
- ModuleBase_WidgetValueFeature.cpp
ModuleBase_WidgetChoice.cpp
ModuleBase_WidgetFileSelector.cpp
ModuleBase_DoubleSpinBox.cpp
#define MODULEBASE_MODELWIDGET_H
#include <ModuleBase.h>
+#include <ModuleBase_ViewerPrs.h>
#include <ModelAPI_Feature.h>
#include <memory>
class Config_WidgetAPI;
-class ModuleBase_WidgetValue;
class QKeyEvent;
/**\class ModuleBase_ModelWidget
/// Set the given wrapped value to the current widget
/// This value should be processed in the widget according to the needs
/// \param theValue the wrapped widget value
- virtual bool setValue(ModuleBase_WidgetValue* theValue)
+ virtual bool setSelection(ModuleBase_ViewerPrs theValue)
{
return false;
}
#include "ModuleBase_OperationDescription.h"
#include "ModuleBase_ModelWidget.h"
-#include "ModuleBase_WidgetValueFeature.h"
#include "ModuleBase_ViewerPrs.h"
#include "ModuleBase_IPropertyPanel.h"
#include "ModuleBase_ISelection.h"
ModuleBase_ModelWidget* aWgt, *aFilledWgt = 0;
QList<ModuleBase_ModelWidget*>::const_iterator aWIt;
- QList<ModuleBase_WidgetValueFeature*>::const_iterator aPIt;
+ QList<ModuleBase_ViewerPrs>::const_iterator aPIt;
bool isSet = false;
for (aWIt = aWidgets.constBegin(), aPIt = myPreSelection.constBegin();
(aWIt != aWidgets.constEnd()) && (aPIt != myPreSelection.constEnd());
++aWIt) {
aWgt = (*aWIt);
- ModuleBase_WidgetValueFeature* aValue = (*aPIt);
+ ModuleBase_ViewerPrs aValue = (*aPIt);
if (!aWgt->canSetValue())
continue;
++aPIt;
- if (!aWgt->setValue(aValue)) {
+ if (!aWgt->setSelection(aValue)) {
isSet = false;
break;
} else {
// convert the selection values to the values, which are set to the operation widgets
- Handle(V3d_View) aView = theViewer->activeView();
- foreach (ModuleBase_ViewerPrs aPrs, aPreSelected) {
- ModuleBase_WidgetValueFeature* aValue = new ModuleBase_WidgetValueFeature();
- aValue->setObject(aPrs.object());
-
- double aX, anY;
- if (getViewerPoint(aPrs, theViewer, aX, anY))
- aValue->setPoint(std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(aX, anY)));
- myPreSelection.append(aValue);
- }
+ //Handle(V3d_View) aView = theViewer->activeView();
+ //foreach (ModuleBase_ViewerPrs aPrs, aPreSelected) {
+ // ModuleBase_WidgetValueFeature* aValue = new ModuleBase_WidgetValueFeature();
+ // aValue->setObject(aPrs.object());
+
+ // double aX, anY;
+ // if (getViewerPoint(aPrs, theViewer, aX, anY))
+ // aValue->setPoint(std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(aX, anY)));
+ // myPreSelection.append(aValue);
+ //}
+ myPreSelection = aPreSelected;
}
//void ModuleBase_Operation::onWidgetActivated(ModuleBase_ModelWidget* theWidget)
void ModuleBase_Operation::clearPreselection()
{
- while (!myPreSelection.isEmpty()) {
- delete myPreSelection.takeFirst();
- }
+ myPreSelection.clear();
}
void ModuleBase_Operation::setPropertyPanel(ModuleBase_IPropertyPanel* theProp)
class ModuleBase_IPropertyPanel;
class ModuleBase_ISelection;
class ModuleBase_IViewer;
-class ModuleBase_WidgetValueFeature;
class QKeyEvent;
QStringList myNestedFeatures;
/// List of pre-selected object
- QList<ModuleBase_WidgetValueFeature*> myPreSelection;
+ QList<ModuleBase_ViewerPrs> myPreSelection;
/// Access to property panel
ModuleBase_IPropertyPanel* myPropertyPanel;
#include <ModuleBase_IWorkshop.h>
#include <ModuleBase_IViewer.h>
#include <ModuleBase_Tools.h>
-#include <ModuleBase_WidgetValueFeature.h>
#include <Config_WidgetAPI.h>
#include <Events_Loop.h>
// In order to make reselection possible
// TODO: check with MPV clearAttribute();
- QObjectPtrList aObjects = myWorkshop->selection()->selectedPresentations();
- if (aObjects.size() > 0) {
- ObjectPtr aObject = aObjects.first();
- if ((!mySelectedObject) && (!aObject))
- return;
+ //QObjectPtrList aObjects = myWorkshop->selection()->selectedPresentations();
+ QList<ModuleBase_ViewerPrs> aSelected = myWorkshop->selection()->getSelected();
+ if (aSelected.size() > 0)
+ setSelection(aSelected.first());
+}
- // Check that the selected object is result (others can not be accepted)
- ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aObject);
- if (!aRes)
- return;
+//********************************************************************
+bool ModuleBase_WidgetShapeSelector::setSelection(ModuleBase_ViewerPrs theValue)
+{
+ ObjectPtr aObject = theValue.object();
+ if ((!mySelectedObject) && (!aObject))
+ return false;
- if (myFeature) {
- // We can not select a result of our feature
- const std::list<std::shared_ptr<ModelAPI_Result>>& aResList = myFeature->results();
- std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aIt;
- for (aIt = aResList.cbegin(); aIt != aResList.cend(); ++aIt) {
- if ((*aIt) == aRes)
- return;
- }
+ // Check that the selected object is result (others can not be accepted)
+ ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aObject);
+ if (!aRes)
+ return false;
+
+ if (myFeature) {
+ // We can not select a result of our feature
+ const std::list<std::shared_ptr<ModelAPI_Result>>& aResList = myFeature->results();
+ std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aIt;
+ for (aIt = aResList.cbegin(); aIt != aResList.cend(); ++aIt) {
+ if ((*aIt) == aRes)
+ return false;
}
- // Check that object belongs to active document or PartSet
- DocumentPtr aDoc = aRes->document();
- SessionPtr aMgr = ModelAPI_Session::get();
- if (!(aDoc == aMgr->activeDocument()) && !(aDoc == aMgr->moduleDocument()))
- return;
+ }
+ // Check that object belongs to active document or PartSet
+ DocumentPtr aDoc = aRes->document();
+ SessionPtr aMgr = ModelAPI_Session::get();
+ if (!(aDoc == aMgr->activeDocument()) && !(aDoc == aMgr->moduleDocument()))
+ return false;
- // Check that the result has a shape
- GeomShapePtr aShape = ModelAPI_Tools::shape(aRes);
- if (!aShape)
- return;
+ // Check that the result has a shape
+ GeomShapePtr aShape = ModelAPI_Tools::shape(aRes);
+ if (!aShape)
+ return false;
- /// Check that object has acceptable type
- if (!acceptObjectType(aObject))
- return;
+ /// Check that object has acceptable type
+ if (!acceptObjectType(aObject))
+ return false;
- // Get sub-shapes from local selection
- if (myUseSubShapes) {
- NCollection_List<TopoDS_Shape> aShapeList;
- std::list<ObjectPtr> aOwners;
- myWorkshop->selection()->selectedShapes(aShapeList, aOwners);
- if (aShapeList.Extent() > 0) {
- aShape = std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape());
- aShape->setImpl(new TopoDS_Shape(aShapeList.First()));
- }
+ // Get sub-shapes from local selection
+ if (myUseSubShapes) {
+ if (!theValue.shape().IsNull()) {
+ aShape = std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape());
+ aShape->setImpl(new TopoDS_Shape(theValue.shape()));
}
+ }
- // Check that the selection corresponds to selection type
- if (myUseSubShapes) {
- if (!acceptSubShape(aShape))
- return;
- } else {
- if (!acceptObjectShape(aObject))
- return;
- }
- if (isValid(aObject, aShape)) {
- setObject(aObject, aShape);
- emit focusOutWidget(this);
- }
+ // Check that the selection corresponds to selection type
+ if (myUseSubShapes) {
+ if (!acceptSubShape(aShape))
+ return false;
+ } else {
+ if (!acceptObjectShape(aObject))
+ return false;
}
+ if (isValid(aObject, aShape)) {
+ setObject(aObject, aShape);
+ emit focusOutWidget(this);
+ }
+ return true;
}
//********************************************************************
}
//********************************************************************
-bool ModuleBase_WidgetShapeSelector::setValue(ModuleBase_WidgetValue* theValue)
-{
- if (theValue) {
- ModuleBase_WidgetValueFeature* aFeatureValue =
- dynamic_cast<ModuleBase_WidgetValueFeature*>(theValue);
- if (aFeatureValue && aFeatureValue->object()) {
- ObjectPtr aObject = aFeatureValue->object();
- if (acceptObjectShape(aObject)) {
- setObject(aObject);
- return true;
- }
- }
- }
- return false;
-}
+//bool ModuleBase_WidgetShapeSelector::setSelection(ModuleBase_ViewerPrs theValue)
+//{
+// if (theValue.object()) {
+// ObjectPtr aObject = theValue.object();
+// if (acceptObjectShape(aObject)) {
+// setObject(aObject);
+// return true;
+// }
+// }
+// return false;
+//}
//********************************************************************
void ModuleBase_WidgetShapeSelector::activate()
/// Set the given wrapped value to the current widget
/// This value should be processed in the widget according to the needs
/// \param theValue the wrapped widget value
- virtual bool setValue(ModuleBase_WidgetValue* theValue);
+ virtual bool setSelection(ModuleBase_ViewerPrs theValue);
/// The methiod called when widget is activated
+++ /dev/null
-// File: ModuleBase_WidgetValue.cpp
-// Created: 25 Apr 2014
-// Author: Natalia ERMOLAEVA
-
-#include <ModuleBase_WidgetValue.h>
-
-ModuleBase_WidgetValue::ModuleBase_WidgetValue()
-{
-}
-
-ModuleBase_WidgetValue::~ModuleBase_WidgetValue()
-{
-}
+++ /dev/null
-// File: ModuleBase_WidgetValue.h
-// Created: 25 Apr 2014
-// Author: Natalia ERMOLAEVA
-
-#ifndef ModuleBase_WidgetValue_H
-#define ModuleBase_WidgetValue_H
-
-#include <ModuleBase.h>
-
-/**\class ModuleBase_WidgetValue
- * \ingroup GUI
- * \brief Custom widget value. An abstract class to be redefined and to be set in the model widget
- */
-class MODULEBASE_EXPORT ModuleBase_WidgetValue
-{
- public:
- /// Constructor
- ModuleBase_WidgetValue();
- /// Destructor
- virtual ~ModuleBase_WidgetValue();
-};
-
-#endif
+++ /dev/null
-// File: ModuleBase_WidgetValueFeature.cpp
-// Created: 25 Apr 2014
-// Author: Natalia ERMOLAEVA
-
-#include <ModuleBase_WidgetValueFeature.h>
-
-#include <GeomAPI_Pnt2d.h>
-
-ModuleBase_WidgetValueFeature::ModuleBase_WidgetValueFeature()
-{
-}
-
-ModuleBase_WidgetValueFeature::~ModuleBase_WidgetValueFeature()
-{
-}
-
-void ModuleBase_WidgetValueFeature::setObject(const ObjectPtr& theFeature)
-{
- myResult = theFeature;
-}
-
-const ObjectPtr& ModuleBase_WidgetValueFeature::object() const
-{
- return myResult;
-}
-
-void ModuleBase_WidgetValueFeature::setPoint(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint)
-{
- myPoint = thePoint;
-}
-
-const std::shared_ptr<GeomAPI_Pnt2d>& ModuleBase_WidgetValueFeature::point() const
-{
- return myPoint;
-}
+++ /dev/null
-// File: ModuleBase_WidgetValueFeature.h
-// Created: 25 Apr 2014
-// Author: Natalia ERMOLAEVA
-
-#ifndef ModuleBase_WidgetValueFeature_H
-#define ModuleBase_WidgetValueFeature_H
-
-#include <ModuleBase.h>
-#include <ModuleBase_WidgetValue.h>
-
-#include <ModelAPI_Result.h>
-
-#include <memory>
-
-class GeomAPI_Pnt2d;
-
-/**\class ModuleBase_WidgetValueFeature
- * \ingroup GUI
- * \brief Custom widget value. The widget contains a feature and 2D point.
- */
-class ModuleBase_WidgetValueFeature : public ModuleBase_WidgetValue
-{
- public:
- /// Constructor
- MODULEBASE_EXPORT ModuleBase_WidgetValueFeature();
- /// Destructor
- MODULEBASE_EXPORT virtual ~ModuleBase_WidgetValueFeature();
-
- /// Fill the widget values by given point
- /// \param thePoint the point
- MODULEBASE_EXPORT void setObject(const ObjectPtr& theFeature);
-
- /// Returns the widget values by given point
- /// \return theFeature the current feature
- MODULEBASE_EXPORT const ObjectPtr& object() const;
-
- /// Fill the widget values by given point
- /// \param thePoint the point
- MODULEBASE_EXPORT void setPoint(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint);
-
- /// Returns the widget point
- /// \return the current point
- MODULEBASE_EXPORT const std::shared_ptr<GeomAPI_Pnt2d>& point() const;
-
- private:
- ObjectPtr myResult;
- std::shared_ptr<GeomAPI_Pnt2d> myPoint;
-};
-
-#endif
#include <XGUI_SelectionMgr.h>
#include <XGUI_Selection.h>
-#include <ModuleBase_WidgetValueFeature.h>
#include <ModuleBase_DoubleSpinBox.h>
#include <ModuleBase_Tools.h>
#include <ModuleBase_IViewWindow.h>
{
}
-bool PartSet_WidgetPoint2D::setValue(ModuleBase_WidgetValue* theValue)
+bool PartSet_WidgetPoint2D::setSelection(ModuleBase_ViewerPrs theValue)
{
+ Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
bool isDone = false;
- if (theValue) {
- ModuleBase_WidgetValueFeature* aFeatureValue =
- dynamic_cast<ModuleBase_WidgetValueFeature*>(theValue);
- if (aFeatureValue) {
- std::shared_ptr<GeomAPI_Pnt2d> aPoint = aFeatureValue->point();
- if (aPoint) {
- setPoint(aPoint->x(), aPoint->y());
- isDone = true;
- }
- }
+ TopoDS_Shape aShape = theValue.shape();
+ double aX, aY;
+ if (getPoint2d(aView, aShape, aX, aY)) {
+ setPoint(aX, aY);
+ isDone = true;
}
return isDone;
}
myWorkshop->moduleConnector()->deactivateSubShapesSelection();
}
+bool PartSet_WidgetPoint2D::getPoint2d(const Handle(V3d_View)& theView,
+ const TopoDS_Shape& theShape,
+ double& theX, double& theY) const
+{
+ if (!theShape.IsNull()) {
+ if (theShape.ShapeType() == TopAbs_VERTEX) {
+ const TopoDS_Vertex& aVertex = TopoDS::Vertex(theShape);
+ if (!aVertex.IsNull()) {
+ // A case when point is taken from existing vertex
+ gp_Pnt aPoint = BRep_Tool::Pnt(aVertex);
+ PartSet_Tools::convertTo2D(aPoint, mySketch, theView, theX, theY);
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
void PartSet_WidgetPoint2D::onMouseRelease(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
{
aSelection->selectedShapes(aShapes, aObjects);
if (aShapes.Extent() > 0) {
TopoDS_Shape aShape = aShapes.First();
- if (!aShape.IsNull()) {
- if (aShape.ShapeType() == TopAbs_VERTEX) {
- const TopoDS_Vertex& aVertex = TopoDS::Vertex(aShape);
- if (!aVertex.IsNull()) {
- // A case when point is taken from existing vertex
- gp_Pnt aPoint = BRep_Tool::Pnt(aVertex);
- double aX, aY;
- PartSet_Tools::convertTo2D(aPoint, mySketch, theWnd->v3dView(), aX, aY);
- setPoint(aX, aY);
-
- PartSet_Tools::setConstraints(mySketch, feature(), attributeID(),aX, aY);
- emit vertexSelected(aObjects.front(), aShape);
- QApplication::processEvents();
- emit focusOutWidget(this);
- return;
- }
- }
+ double aX, aY;
+ if (getPoint2d(theWnd->v3dView(), aShape, aX, aY)) {
+ setPoint(aX, aY);
+
+ PartSet_Tools::setConstraints(mySketch, feature(), attributeID(),aX, aY);
+ emit vertexSelected(aObjects.front(), aShape);
+ QApplication::processEvents();
+ emit focusOutWidget(this);
+ return;
}
}
// A case when point is taken from mouse event
#include <QObject>
#include <TopoDS_Shape.hxx>
+#include <V3d_View.hxx>
class ModelAPI_Feature;
-class ModuleBase_WidgetValue;
class ModuleBase_IWorkshop;
class ModuleBase_DoubleSpinBox;
class ModuleBase_IViewWindow;
/// Set the given wrapped value to the current widget
/// This value should be processed in the widget according to the needs
/// \param theValue the wrapped widget value
- virtual bool setValue(ModuleBase_WidgetValue* theValue);
+ virtual bool setSelection(ModuleBase_ViewerPrs theValue);
/// Saves the internal parameters to the given feature
/// \param theObject a model feature to be changed
void onMouseMove(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
private:
+ bool getPoint2d(const Handle(V3d_View)& theView, const TopoDS_Shape& theShape,
+ double& theX, double& theY) const;
+
XGUI_Workshop* myWorkshop;
QGroupBox* myGroupBox; ///< the parent group box for all intenal widgets
#include "PartSet_WidgetPoint2dDistance.h"
#include "PartSet_Tools.h"
-#include <ModuleBase_WidgetValueFeature.h>
#include <ModuleBase_DoubleSpinBox.h>
#include <ModuleBase_IViewWindow.h>
#include <ModelAPI_CompositeFeature.h>
-//class ModuleBase_WidgetValue;
class GeomAPI_Pnt2d;
class XGUI_Workshop;
class ModuleBase_IViewWindow;