<feature id="SketchConstraintRigid" title="Fixed" tooltip="Fix an object" icon=":icons/fixed.png">
<shape_selector id="ConstraintEntityA" label="Object" tooltip="Select an object"
shape_types="edge vertex">
- <validator id="SketchPlugin_ResultPoint"/>
+ <validator id="SketchPlugin_ResultPoint"/>
<validator id="SketchPlugin_ResultLine"/>
<validator id="SketchPlugin_ResultArc"/>
</shape_selector>
{
prepareAspect();
- std::shared_ptr<GeomAPI_Shape> aLine1 = SketcherPrs_Tools::getLine(myConstraint, SketchPlugin_Constraint::ENTITY_A());
+ ObjectPtr aObj1 = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_A());
+ ObjectPtr aObj2 = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_B());
+
+ std::shared_ptr<GeomAPI_Shape> aLine1 = SketcherPrs_Tools::getLine(aObj1);
if (aLine1.get() == NULL)
return;
- std::shared_ptr<GeomAPI_Shape> aLine2 = SketcherPrs_Tools::getLine(myConstraint, SketchPlugin_Constraint::ENTITY_B());
+ std::shared_ptr<GeomAPI_Shape> aLine2 = SketcherPrs_Tools::getLine(aObj2);
if (aLine2.get() == NULL)
return;
-
+
SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
- gp_Pnt aP1 = aMgr->getPosition(aLine1, this);
- gp_Pnt aP2 = aMgr->getPosition(aLine2, this);
+ gp_Pnt aP1 = aMgr->getPosition(aObj1, this);
+ gp_Pnt aP2 = aMgr->getPosition(aObj2, this);
Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePresentation);
aGroup->SetPrimitivesAspect(myAspect);
{
myPntArray = new Graphic3d_ArrayOfPoints(2);
myPntArray->AddVertex(0., 0., 0.);
- myPntArray->AddVertex(0. ,0., 0.);
+ myPntArray->AddVertex(0., 0., 0.);
}
void SketcherPrs_Perpendicular::Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
{
prepareAspect();
- std::shared_ptr<GeomAPI_Shape> aLine1 = SketcherPrs_Tools::getLine(myConstraint, SketchPlugin_Constraint::ENTITY_A());
+ ObjectPtr aObj1 = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_A());
+ ObjectPtr aObj2 = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_B());
+
+ std::shared_ptr<GeomAPI_Shape> aLine1 = SketcherPrs_Tools::getLine(aObj1);
if (aLine1.get() == NULL)
return;
- std::shared_ptr<GeomAPI_Shape> aLine2 = SketcherPrs_Tools::getLine(myConstraint, SketchPlugin_Constraint::ENTITY_B());
+ std::shared_ptr<GeomAPI_Shape> aLine2 = SketcherPrs_Tools::getLine(aObj2);
if (aLine2.get() == NULL)
return;
SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
- gp_Pnt aP1 = aMgr->getPosition(aLine1, this);
- gp_Pnt aP2 = aMgr->getPosition(aLine2, this);
+ gp_Pnt aP1 = aMgr->getPosition(aObj1, this);
+ gp_Pnt aP2 = aMgr->getPosition(aObj2, this);
Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePresentation);
aGroup->SetPrimitivesAspect(myAspect);
// Author: Vitaly SMETANNIKOV
#include "SketcherPrs_PositionMgr.h"
+#include "SketcherPrs_Tools.h"
#include <GeomAPI_Edge.h>
}
-int SketcherPrs_PositionMgr::getPositionIndex(std::shared_ptr<GeomAPI_Shape> theLine,
+int SketcherPrs_PositionMgr::getPositionIndex(ObjectPtr theLine,
Handle(SketcherPrs_SymbolPrs) thePrs)
{
if (myShapes.count(theLine) == 1) {
}
}
-gp_Pnt SketcherPrs_PositionMgr::getPosition(std::shared_ptr<GeomAPI_Shape> theLine,
+gp_Pnt SketcherPrs_PositionMgr::getPosition(ObjectPtr theLine,
Handle(SketcherPrs_SymbolPrs) thePrs)
{
+ std::shared_ptr<GeomAPI_Shape> aShape = SketcherPrs_Tools::getLine(theLine);
std::shared_ptr<GeomAPI_Edge> aEdge =
- std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(theLine));
+ std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(aShape));
std::shared_ptr<GeomAPI_Pnt> aPnt1 = aEdge->firstPoint();
std::shared_ptr<GeomAPI_Pnt> aPnt2 = aEdge->lastPoint();
void SketcherPrs_PositionMgr::deleteConstraint(Handle(SketcherPrs_SymbolPrs) thePrs)
{
- std::map<std::shared_ptr<GeomAPI_Shape>, PositionsMap>::iterator aIt;
+ std::map<ObjectPtr, PositionsMap>::iterator aIt;
for (aIt = myShapes.begin(); aIt != myShapes.end(); ++aIt) {
PositionsMap& aPosMap = aIt->second;
if (aPosMap.count(thePrs.Access()) > 0)
#include <GeomAPI_Shape.h>
#include <gp_Pnt.hxx>
+#include <ModelAPI_Object.h>
#include <map>
/// Returns position of symbol for the given presentation
/// \param theLine constrained object
/// \param thePrs a presentation of constraint
- gp_Pnt getPosition(std::shared_ptr<GeomAPI_Shape> theLine, Handle(SketcherPrs_SymbolPrs) thePrs);
+ gp_Pnt getPosition(ObjectPtr theLine, Handle(SketcherPrs_SymbolPrs) thePrs);
/// Deletes constraint object from internal structures. Has to be called on constraint delete.
/// \param thePrs a constraint presentation
/// Returns position index of the given constraint
/// \param theLine constrained object
/// \param thePrs a presentation of constraint
- int getPositionIndex(std::shared_ptr<GeomAPI_Shape> theLine, Handle(SketcherPrs_SymbolPrs) thePrs);
+ int getPositionIndex(ObjectPtr theLine, Handle(SketcherPrs_SymbolPrs) thePrs);
private:
typedef std::map<void*, int> PositionsMap;
PositionsMap myIndexes;
/// The map contains position index
- std::map<std::shared_ptr<GeomAPI_Shape>, PositionsMap> myShapes;
+ std::map<ObjectPtr, PositionsMap> myShapes;
};
#endif
\ No newline at end of file
{
prepareAspect();
- std::shared_ptr<GeomAPI_Shape> aLine1 = SketcherPrs_Tools::getLine(myConstraint, SketchPlugin_Constraint::ENTITY_A());
+ ObjectPtr aObj1 = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_A());
+ std::shared_ptr<GeomAPI_Shape> aLine1 = SketcherPrs_Tools::getLine(aObj1);
if (aLine1.get() == NULL)
return;
SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
- gp_Pnt aP1 = aMgr->getPosition(aLine1, this);
+ gp_Pnt aP1 = aMgr->getPosition(aObj1, this);
Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePresentation);
aGroup->SetPrimitivesAspect(myAspect);
void SketcherPrs_SymbolPrs::addLine(const Handle(Graphic3d_Group)& theGroup, std::string theAttrName) const
{
- std::shared_ptr<GeomAPI_Shape> aLine = SketcherPrs_Tools::getLine(myConstraint, theAttrName);
+ ObjectPtr aObj = SketcherPrs_Tools::getResult(myConstraint, theAttrName);
+ std::shared_ptr<GeomAPI_Shape> aLine = SketcherPrs_Tools::getLine(aObj);
if (aLine.get() == NULL)
return;
std::shared_ptr<GeomAPI_Edge> aEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(aLine));
namespace SketcherPrs_Tools {
-
-std::shared_ptr<GeomAPI_Shape> getLine(SketchPlugin_Constraint* theFeature,
- const std::string& theAttrName)
+ObjectPtr getResult(SketchPlugin_Constraint* theFeature, const std::string& theAttrName)
{
std::shared_ptr<ModelAPI_Data> aData = theFeature->data();
std::shared_ptr<ModelAPI_AttributeRefAttr> anAttr =
std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(theAttrName));
- ObjectPtr aObject = anAttr->object();
- ResultConstructionPtr aRes = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aObject);
+ return anAttr->object();
+}
+
+
+std::shared_ptr<GeomAPI_Shape> getLine(ObjectPtr theObject)
+{
+ ResultConstructionPtr aRes = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(theObject);
if (aRes.get() != NULL) {
return aRes->shape();
}
#include "SketcherPrs.h"
#include <GeomAPI_Shape.h>
#include <GeomAPI_Pnt2d.h>
+#include <ModelAPI_Object.h>
#include <string>
class SketchPlugin_Constraint;
namespace SketcherPrs_Tools {
- std::shared_ptr<GeomAPI_Shape> getLine(SketchPlugin_Constraint* theFeature,
- const std::string& theAttrName);
+ ObjectPtr getResult(SketchPlugin_Constraint* theFeature,
+ const std::string& theAttrName);
+
+ std::shared_ptr<GeomAPI_Shape> getLine(ObjectPtr theObject);
std::shared_ptr<GeomAPI_Pnt2d> getPoint(SketchPlugin_Constraint* theFeature,
const std::string& theAttrName);