#include "SketcherPrs_PositionMgr.h"
#include <SketchPlugin_Constraint.h>
-#include <SketchPlugin_MultiRotation.h>
#include <SketchPlugin_MultiTranslation.h>
-#include <ModelAPI_AttributeInteger.h>
+#include <SketchPlugin_MultiRotation.h>
#include <ModelAPI_AttributeRefList.h>
+#include <GeomDataAPI_Point2D.h>
#include <Graphic3d_AspectLine3d.hxx>
#include <Prs3d_Root.hxx>
+#include <Prs3d_LineAspect.hxx>
+#include <Geom_CartesianPoint.hxx>
+#include <gp_Pnt.hxx>
+#include <StdPrs_Point.hxx>
bool isTranslation)
: SketcherPrs_SymbolPrs(theConstraint, thePlane), myIsTranslation(isTranslation)
{
- int aPointsNb = 0;
- if (theConstraint->getKind() == SketchPlugin_MultiTranslation::ID()) {
- aPointsNb = theConstraint->integer(SketchPlugin_MultiTranslation::NUMBER_OF_COPIES_ID())->value();
- } else if (theConstraint->getKind() == SketchPlugin_MultiRotation::ID()) {
- aPointsNb = theConstraint->integer(SketchPlugin_MultiRotation::NUMBER_OF_COPIES_ID())->value();
- }
- aPointsNb == 0 ? aPointsNb = 2 : aPointsNb++; // by default we have 2 points for symbols
- myPntArray = new Graphic3d_ArrayOfPoints(aPointsNb);
}
bool SketcherPrs_Transformation::updatePoints(double theStep) const
{
std::shared_ptr<ModelAPI_Data> aData = myConstraint->data();
+ // Get transformated objects list
std::shared_ptr<ModelAPI_AttributeRefList> anAttrB = aData->reflist(SketchPlugin_Constraint::ENTITY_B());
if (anAttrB.get() == NULL)
return false;
int aNbB = anAttrB->size();
if (aNbB == 0)
+ {
+#ifdef DEBUG_SENSITIVE_TO_BE_CORRECTED
+ //if (!myPntArray.IsNull())
+ // mySPoints.Clear();
+#endif
return false;
+ }
SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
+ myPntArray = new Graphic3d_ArrayOfPoints(aNbB);
int i;
ObjectPtr aObj;
gp_Pnt aP1;
+ // Compute points of symbols
for (i = 0; i < aNbB; i++) {
aObj = anAttrB->object(i);
- if (!aObj.get()) // TODO:empty_result
- // this check should be removed here after the result flush is corrected
- // the problem is, that feature::execute() flushes redisplay by each result creation
- // but it is possible(e.g. in the sketch circle, that there should be more than one result.
- // Here, crash happens, because the second result is not created yet
+ if (SketcherPrs_Tools::getShape(aObj).get() == NULL)
continue;
aP1 = aMgr->getPosition(aObj, this, theStep);
myPntArray->SetVertice(i + 1, aP1);
Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs);
- Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2);
- aGroup->SetPrimitivesAspect(aLineAspect);
+ //Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2);
+ //aGroup->SetPrimitivesAspect(aLineAspect);
+
+ // drawListOfShapes uses myDrawer for attributes definition
+ Handle(Prs3d_LineAspect) aLnAspect = new Prs3d_LineAspect(theColor, Aspect_TOL_SOLID, 1);
+ myDrawer->SetLineAspect(aLnAspect);
drawListOfShapes(anAttrB, thePrs);
+ if (myConstraint->getKind() == SketchPlugin_MultiTranslation::ID()) {
+ // If it is translation
+ AttributePoint2DPtr aStart = GeomDataAPI_Point2D::getPoint2D(aData,
+ SketchPlugin_MultiTranslation::START_POINT_ID());
+ AttributePoint2DPtr aEnd = GeomDataAPI_Point2D::getPoint2D(aData,
+ SketchPlugin_MultiTranslation::END_POINT_ID());
+
+ if (aStart.get() && aEnd.get() && aStart->isInitialized() && aEnd->isInitialized()) {
+ // Add start point
+ std::shared_ptr<GeomAPI_Pnt> aPnt = myPlane->to3D(aStart->x(), aStart->y());
+ Handle(Geom_CartesianPoint) aPoint = new Geom_CartesianPoint(aPnt->impl<gp_Pnt>());
+ StdPrs_Point::Add(thePrs, aPoint, myDrawer);
+
+ // Add end point
+ aPnt = myPlane->to3D(aEnd->x(), aEnd->y());
+ aPoint = new Geom_CartesianPoint(aPnt->impl<gp_Pnt>());
+ StdPrs_Point::Add(thePrs, aPoint, myDrawer);
+ }
+ } else if (myConstraint->getKind() == SketchPlugin_MultiRotation::ID()) {
+ // if it is rotation
+ AttributePoint2DPtr aCenter = GeomDataAPI_Point2D::getPoint2D(aData, SketchPlugin_MultiRotation::CENTER_ID());
+ if (aCenter.get() && aCenter->isInitialized()) {
+ // Show center of rotation
+ std::shared_ptr<GeomAPI_Pnt> aPnt = myPlane->to3D(aCenter->x(), aCenter->y());
+ Handle(Geom_CartesianPoint) aPoint = new Geom_CartesianPoint(aPnt->impl<gp_Pnt>());
+ StdPrs_Point::Add(thePrs, aPoint, myDrawer);
+ }
+ }
}