theModelWidgets.append(aWgt);
return aWgt->getControl();
+ } if (theType == "sketch_constraint_shape_selector") {
+ PartSet_WidgetConstraintShapeSelector* aWgt =
+ new PartSet_WidgetConstraintShapeSelector(theParent, workshop(), theWidgetApi, theParentId);
+ aWgt->setSketcher(myCurrentSketch);
+
+ theModelWidgets.append(aWgt);
+ return aWgt->getControl();
+
}else
return 0;
}
|| theKind == SketchPlugin_ConstraintRigid::ID();
}
-ResultPtr PartSet_Tools::createFixedObjectByEdge(const ModuleBase_ViewerPrs& thePrs, CompositeFeaturePtr theSketch)
+ResultPtr PartSet_Tools::createFixedObjectByEdge(const TopoDS_Shape& theShape,
+ const ObjectPtr& theObject,
+ CompositeFeaturePtr theSketch)
{
- TopoDS_Shape aShape = thePrs.shape();
- if (aShape.ShapeType() != TopAbs_EDGE)
+ if (theShape.ShapeType() != TopAbs_EDGE)
return ResultPtr();
// Check that we already have such external edge
std::shared_ptr<GeomAPI_Edge> aInEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge());
- aInEdge->setImpl(new TopoDS_Shape(aShape));
+ aInEdge->setImpl(new TopoDS_Shape(theShape));
ResultPtr aResult = findExternalEdge(theSketch, aInEdge);
if (aResult)
return aResult;
Handle(V3d_View) aNullView;
FeaturePtr aMyFeature;
- Handle(Geom_Curve) aCurve = BRep_Tool::Curve(TopoDS::Edge(aShape), aStart, aEnd);
+ Handle(Geom_Curve) aCurve = BRep_Tool::Curve(TopoDS::Edge(theShape), aStart, aEnd);
GeomAdaptor_Curve aAdaptor(aCurve);
if (aAdaptor.GetType() == GeomAbs_Line) {
// Create line
aMyFeature = theSketch->addFeature(SketchPlugin_Line::ID());
-
- //DataPtr aData = myFeature->data();
- //std::shared_ptr<GeomDataAPI_Point2D> anEndAttr =
- // std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Line::END_ID()));
-
- //double aX, aY;
- //gp_Pnt Pnt1 = aAdaptor.Value(aStart);
- //convertTo2D(Pnt1, theSketch, aNullView, aX, aY);
- //setFeaturePoint(myFeature, aX, aY, SketchPlugin_Line::START_ID());
-
- //gp_Pnt Pnt2 = aAdaptor.Value(aEnd);
- //convertTo2D(Pnt2, theSketch, aNullView, aX, aY);
- //setFeaturePoint(myFeature, aX, aY, SketchPlugin_Line::END_ID());
} else if (aAdaptor.GetType() == GeomAbs_Circle) {
if (aAdaptor.IsClosed()) {
// Create circle
aMyFeature = theSketch->addFeature(SketchPlugin_Circle::ID());
- //gp_Circ aCirc = aAdaptor.Circle();
- //gp_Pnt aCenter = aCirc.Location();
-
- //double aX, aY;
- //convertTo2D(aCenter, theSketch, aNullView, aX, aY);
- //setFeaturePoint(myFeature, aX, aY, SketchPlugin_Circle::CENTER_ID());
- //setFeatureValue(myFeature, aCirc.Radius(), SketchPlugin_Circle::RADIUS_ID());
} else {
// Create arc
aMyFeature = theSketch->addFeature(SketchPlugin_Arc::ID());
std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
(aData->attribute(SketchPlugin_Feature::EXTERNAL_ID()));
- ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(thePrs.object());
+ ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
if (anAttr && aRes) {
std::shared_ptr<GeomAPI_Shape> anEdge(new GeomAPI_Shape);
- anEdge->setImpl(new TopoDS_Shape(aShape));
+ anEdge->setImpl(new TopoDS_Shape(theShape));
anAttr->setValue(aRes, anEdge);
/// Created line will have fixed constraint
/// \param theEdge - an edge
/// \return - result of created feature
- static ResultPtr createFixedObjectByEdge(const ModuleBase_ViewerPrs& thePrs, CompositeFeaturePtr theSketch);
+ static ResultPtr createFixedObjectByEdge(const TopoDS_Shape& theShape,
+ const ObjectPtr& theObject,
+ CompositeFeaturePtr theSketch);
/// Checks whether the list of selected presentations contains the given one
/// \param theSelected a list of presentations
#include <ModelAPI_AttributeRefAttr.h>
#include <PartSet_Tools.h>
+#include <SketchPlugin_Feature.h>
bool PartSet_WidgetShapeSelector::storeValue() const
}
return ModuleBase_WidgetShapeSelector::storeValue();
}
+
+//*********************************************
+bool PartSet_WidgetConstraintShapeSelector::storeValue() const
+{
+ FeaturePtr aFeature = ModelAPI_Feature::feature(mySelectedObject);
+ if (aFeature) {
+ std::shared_ptr<SketchPlugin_Feature> aSPFeature =
+ std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
+ if ((!aSPFeature) && (!myShape->isNull())) {
+ ObjectPtr aObj = PartSet_Tools::createFixedObjectByEdge(myShape->impl<TopoDS_Shape>(),
+ mySelectedObject, mySketch);
+ if (aObj) {
+ PartSet_WidgetConstraintShapeSelector* that = (PartSet_WidgetConstraintShapeSelector*) this;
+ that->mySelectedObject = aObj;
+ }
+ }
+ }
+ return ModuleBase_WidgetShapeSelector::storeValue();
+}
+
CompositeFeaturePtr mySketch;
};
+
+class PARTSET_EXPORT PartSet_WidgetConstraintShapeSelector: public ModuleBase_WidgetShapeSelector
+{
+Q_OBJECT
+ public:
+ PartSet_WidgetConstraintShapeSelector(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,
+ const Config_WidgetAPI* theData, const std::string& theParentId)
+ : ModuleBase_WidgetShapeSelector(theParent, theWorkshop, theData, theParentId) {}
+
+ virtual ~PartSet_WidgetConstraintShapeSelector() {}
+
+ /// Saves the internal parameters to the given feature
+ virtual bool storeValue() const;
+
+ void setSketcher(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
+ CompositeFeaturePtr sketch() const { return mySketch; }
+
+private:
+ CompositeFeaturePtr mySketch;
+};
+
#endif
\ No newline at end of file
</feature>
<feature id="SketchConstraintParallel" title="Parallel" tooltip="Create constraint defining two parallel lines" icon=":icons/parallel.png">
- <shape_selector id="ConstraintEntityA" label="First line" tooltip="Select an line in the viewer"
+ <sketch_constraint_shape_selector id="ConstraintEntityA" label="First line" tooltip="Select an line in the viewer"
shape_types="edge" use_subshapes="true"/>
- <shape_selector id="ConstraintEntityB" label="Last line" tooltip="Select an line in the viewer"
+ <sketch_constraint_shape_selector id="ConstraintEntityB" label="Last line" tooltip="Select an line in the viewer"
shape_types="edge" use_subshapes="true"/>
<sketch-2dpoint_selector id="ConstraintFlyoutValuePnt" internal="1" obligatory="0"/>
<validator id="PartSet_ParallelValidator"/>
</feature>
<feature id="SketchConstraintPerpendicular" title="Perpendicular" tooltip="Create constraint defining two perpendicular lines" icon=":icons/perpendicular.png">
- <shape_selector id="ConstraintEntityA" label="First line" tooltip="Select an line in the viewer"
+ <sketch_constraint_shape_selector id="ConstraintEntityA" label="First line" tooltip="Select an line in the viewer"
shape_types="edge" use_subshapes="true"/>
- <shape_selector id="ConstraintEntityB" label="Last line" tooltip="Select an line in the viewer"
+ <sketch_constraint_shape_selector id="ConstraintEntityB" label="Last line" tooltip="Select an line in the viewer"
shape_types="edge" use_subshapes="true"/>
<validator id="PartSet_PerpendicularValidator"/>
</feature>
return;
aContext->RemoveFilter(theFilter);
}
+
+void XGUI_Displayer::removeFilters()
+{
+ Handle(AIS_InteractiveContext) aContext = AISContext();
+ if (aContext.IsNull())
+ return;
+ aContext->RemoveFilters();
+}
void removeSelectionFilter(const Handle(SelectMgr_Filter)& theFilter);
+ void removeFilters();
+
/// Updates the viewer
void updateViewer();
connect(anOperationMgr, SIGNAL(operationAborted(ModuleBase_Operation*)),
SIGNAL(operationAborted(ModuleBase_Operation*)));
- myDocumentShapeFilter = new ModuleBase_ShapeDocumentFilter(this);
+ //myDocumentShapeFilter = new ModuleBase_ShapeDocumentFilter(this);
}
XGUI_ModuleConnector::~XGUI_ModuleConnector()
{
- myDocumentShapeFilter.Nullify();
+ //myDocumentShapeFilter.Nullify();
}
ModuleBase_ISelection* XGUI_ModuleConnector::selection() const
}
aDisp->activateObjectsOutOfContext(aModes);
//TODO: We have to open Local context because at neutral point filters don't work (bug 25340)
- aDisp->addSelectionFilter(myDocumentShapeFilter);
+ //aDisp->addSelectionFilter(myDocumentShapeFilter);
}
void XGUI_ModuleConnector::deactivateSubShapesSelection()
{
XGUI_Displayer* aDisp = myWorkshop->displayer();
// The document limitation selection has to be only during operation
- aDisp->removeSelectionFilter(myDocumentShapeFilter);
+ //aDisp->removeSelectionFilter(myDocumentShapeFilter);
aDisp->closeLocalContexts(false);
}
#include "XGUI_ViewWindow.h"
#include "XGUI_Viewer.h"
#include "XGUI_SalomeConnector.h"
+#include "XGUI_Displayer.h"
XGUI_ViewerProxy::XGUI_ViewerProxy(XGUI_Workshop* theParent)
: ModuleBase_IViewer(theParent),
//***************************************
void XGUI_ViewerProxy::addSelectionFilter(const Handle(SelectMgr_Filter)& theFilter)
{
- Handle(AIS_InteractiveContext) aContext = AISContext();
- if (!aContext.IsNull()) {
- aContext->AddFilter(theFilter);
- }
+ myWorkshop->displayer()->addSelectionFilter(theFilter);
}
//***************************************
void XGUI_ViewerProxy::removeSelectionFilter(const Handle(SelectMgr_Filter)& theFilter)
{
- Handle(AIS_InteractiveContext) aContext = AISContext();
- if (!aContext.IsNull()) {
- aContext->RemoveFilter(theFilter);
- }
+ myWorkshop->displayer()->removeSelectionFilter(theFilter);
}
//***************************************
void XGUI_ViewerProxy::clearSelectionFilters()
{
- Handle(AIS_InteractiveContext) aContext = AISContext();
- if (!aContext.IsNull()) {
- aContext->RemoveFilters();
- }
+ myWorkshop->displayer()->removeFilters();
}