1 // Copyright (C) 2018-2019 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "FeaturesPlugin_Measurement.h"
22 #include <ModelAPI_AttributeDoubleArray.h>
23 #include <ModelAPI_AttributeSelection.h>
24 #include <ModelAPI_AttributeString.h>
25 #include <ModelAPI_Data.h>
26 #include <ModelAPI_Session.h>
28 #include <GeomAPI_Angle.h>
29 #include <GeomAPI_Circ.h>
30 #include <GeomAPI_Edge.h>
31 #include <GeomAPI_Face.h>
32 #include <GeomAPI_Pnt.h>
33 #include <GeomAPI_Shape.h>
34 #include <GeomAPI_ShapeIterator.h>
35 #include <GeomAPI_Vertex.h>
37 #include <GeomAlgoAPI_ShapeTools.h>
39 #include <Config_PropManager.h>
42 #include <TopoDS_Edge.hxx>
43 #include <TopoDS_Shape.hxx>
44 #include <AIS_LengthDimension.hxx>
45 #include <AIS_RadiusDimension.hxx>
46 #include <AIS_AngleDimension.hxx>
47 #include <BRepExtrema_DistShapeShape.hxx>
52 FeaturesPlugin_Measurement::FeaturesPlugin_Measurement() : mySceenScale(1)
56 void FeaturesPlugin_Measurement::initAttributes()
58 data()->addAttribute(FeaturesPlugin_Measurement::MEASURE_KIND(),
59 ModelAPI_AttributeString::typeId());
61 // attribute for length
62 data()->addAttribute(EDGE_FOR_LENGTH_ID(), ModelAPI_AttributeSelection::typeId());
63 // attributes for distance
64 data()->addAttribute(DISTANCE_FROM_OBJECT_ID(), ModelAPI_AttributeSelection::typeId());
65 data()->addAttribute(DISTANCE_TO_OBJECT_ID(), ModelAPI_AttributeSelection::typeId());
66 // attribute for radius
67 data()->addAttribute(CIRCULAR_OBJECT_ID(), ModelAPI_AttributeSelection::typeId());
68 // attributes for angle
69 data()->addAttribute(ANGLE_FROM_EDGE_ID(), ModelAPI_AttributeSelection::typeId());
70 data()->addAttribute(ANGLE_TO_EDGE_ID(), ModelAPI_AttributeSelection::typeId());
71 // attributes for angle by 3 points
72 data()->addAttribute(ANGLE_POINT1_ID(), ModelAPI_AttributeSelection::typeId());
73 data()->addAttribute(ANGLE_POINT2_ID(), ModelAPI_AttributeSelection::typeId());
74 data()->addAttribute(ANGLE_POINT3_ID(), ModelAPI_AttributeSelection::typeId());
75 // attributes for result message and values
76 data()->addAttribute(RESULT_ID(), ModelAPI_AttributeString::typeId());
77 data()->addAttribute(RESULT_VALUES_ID(), ModelAPI_AttributeDoubleArray::typeId());
80 void FeaturesPlugin_Measurement::execute()
84 void FeaturesPlugin_Measurement::attributeChanged(const std::string& theID)
86 if (theID == MEASURE_KIND()) {
88 string(RESULT_ID())->setValue("");
89 std::dynamic_pointer_cast<ModelAPI_AttributeDoubleArray>(
90 attribute(RESULT_VALUES_ID()))->setSize(0);
92 if (theID != RESULT_ID()) {
93 std::string aKind = string(MEASURE_KIND())->value();
94 if (aKind == MEASURE_LENGTH())
96 else if (aKind == MEASURE_DISTANCE())
98 else if (aKind == MEASURE_RADIUS())
100 else if (aKind == MEASURE_ANGLE())
102 else if (aKind == MEASURE_ANGLE_POINTS())
103 computeAngleByPoints();
107 void FeaturesPlugin_Measurement::computeLength()
109 AttributeSelectionPtr aSelectedFeature = selection(EDGE_FOR_LENGTH_ID());
113 if (aSelectedFeature && aSelectedFeature->isInitialized()) {
114 aShape = aSelectedFeature->value();
115 if (!aShape && aSelectedFeature->context())
116 aShape = aSelectedFeature->context()->shape();
118 if (aShape && aShape->isEdge())
119 anEdge = GeomEdgePtr(new GeomAPI_Edge(aShape));
121 string(RESULT_ID())->setValue("");
125 std::ostringstream anOutput;
126 anOutput << "Length = " << std::setprecision(10) << anEdge->length();
127 string(RESULT_ID())->setValue(anOutput.str());
129 AttributeDoubleArrayPtr aValues =
130 std::dynamic_pointer_cast<ModelAPI_AttributeDoubleArray>(attribute(RESULT_VALUES_ID()));
132 aValues->setValue(0, anEdge->length());
135 void FeaturesPlugin_Measurement::computeDistance()
137 AttributeSelectionPtr aFirstFeature = selection(DISTANCE_FROM_OBJECT_ID());
138 GeomShapePtr aShape1;
139 if (aFirstFeature && aFirstFeature->isInitialized()) {
140 aShape1 = aFirstFeature->value();
141 if (!aShape1 && aFirstFeature->context())
142 aShape1 = aFirstFeature->context()->shape();
145 AttributeSelectionPtr aSecondFeature = selection(DISTANCE_TO_OBJECT_ID());
146 GeomShapePtr aShape2;
147 if (aSecondFeature && aSecondFeature->isInitialized()) {
148 aShape2 = aSecondFeature->value();
149 if (!aShape2 && aSecondFeature->context())
150 aShape2 = aSecondFeature->context()->shape();
153 if (!aShape1 || !aShape2) {
154 string(RESULT_ID())->setValue("");
158 double aDistance = GeomAlgoAPI_ShapeTools::minimalDistance(aShape1, aShape2);
160 std::ostringstream anOutput;
161 anOutput << "Distance = " << std::setprecision(10) << aDistance;
162 string(RESULT_ID())->setValue(anOutput.str());
164 AttributeDoubleArrayPtr aValues =
165 std::dynamic_pointer_cast<ModelAPI_AttributeDoubleArray>(attribute(RESULT_VALUES_ID()));
167 aValues->setValue(0, aDistance);
170 void FeaturesPlugin_Measurement::computeRadius()
172 AttributeSelectionPtr aSelectedFeature = selection(CIRCULAR_OBJECT_ID());
175 if (aSelectedFeature && aSelectedFeature->isInitialized()) {
176 aShape = aSelectedFeature->value();
177 if (!aShape && aSelectedFeature->context())
178 aShape = aSelectedFeature->context()->shape();
181 double aRadius = -1.0;
183 if (aShape->isEdge()) {
184 GeomEdgePtr anEdge(new GeomAPI_Edge(aShape));
185 if (anEdge->isCircle() || anEdge->isArc()) {
186 aRadius = anEdge->circle()->radius();
188 } else if (aShape->isFace()) {
189 GeomFacePtr aFace(new GeomAPI_Face(aShape));
190 aRadius = GeomAlgoAPI_ShapeTools::radius(aFace);
195 string(RESULT_ID())->setValue("");
199 std::ostringstream anOutput;
200 anOutput << "Radius = " << std::setprecision(10) << aRadius;
201 string(RESULT_ID())->setValue(anOutput.str());
203 AttributeDoubleArrayPtr aValues =
204 std::dynamic_pointer_cast<ModelAPI_AttributeDoubleArray>(attribute(RESULT_VALUES_ID()));
206 aValues->setValue(0, aRadius);
209 void FeaturesPlugin_Measurement::computeAngle()
211 AttributeSelectionPtr aFirstFeature = selection(ANGLE_FROM_EDGE_ID());
212 GeomShapePtr aShape1;
214 if (aFirstFeature && aFirstFeature->isInitialized()) {
215 aShape1 = aFirstFeature->value();
216 if (!aShape1 && aFirstFeature->context())
217 aShape1 = aFirstFeature->context()->shape();
219 if (aShape1 && aShape1->isEdge())
220 anEdge1 = GeomEdgePtr(new GeomAPI_Edge(aShape1));
222 AttributeSelectionPtr aSecondFeature = selection(ANGLE_TO_EDGE_ID());
223 GeomShapePtr aShape2;
225 if (aSecondFeature && aSecondFeature->isInitialized()) {
226 aShape2 = aSecondFeature->value();
227 if (!aShape2 && aSecondFeature->context())
228 aShape2 = aSecondFeature->context()->shape();
230 if (aShape2 && aShape2->isEdge())
231 anEdge2 = GeomEdgePtr(new GeomAPI_Edge(aShape2));
233 if (!anEdge1 || !anEdge2) {
234 string(RESULT_ID())->setValue("");
238 GeomShapePtr anInter = anEdge1->intersect(anEdge2);
240 std::ostringstream anOutput;
241 anOutput << std::setprecision(10);
242 std::list<double> aValuesList;
244 if (anInter->isVertex()) {
245 std::shared_ptr<GeomAPI_Vertex> aVertex(new GeomAPI_Vertex(anInter));
246 std::shared_ptr<GeomAPI_Angle> anAngle(
247 new GeomAPI_Angle(anEdge1, anEdge2, aVertex->point()));
248 double anAngleValue = anAngle->angleDegree();
249 anOutput << "Angle = " << std::setprecision(10) << anAngleValue << std::endl;
250 aValuesList.push_back(anAngleValue);
253 GeomAPI_ShapeIterator anIt(anInter);
254 for (int anIndex = 1; anIt.more(); anIt.next(), ++anIndex) {
255 GeomShapePtr aCurrent = anIt.current();
256 if (!aCurrent->isVertex())
258 std::shared_ptr<GeomAPI_Vertex> aVertex(new GeomAPI_Vertex(aCurrent));
259 std::shared_ptr<GeomAPI_Angle> anAngle(
260 new GeomAPI_Angle(anEdge1, anEdge2, aVertex->point()));
261 double anAngleValue = anAngle->angleDegree();
262 anOutput << "Angle" << anIndex << " = "
263 << std::setprecision(10) << anAngleValue << std::endl;
264 aValuesList.push_back(anAngleValue);
269 string(RESULT_ID())->setValue(anOutput.str());
271 AttributeDoubleArrayPtr aValues =
272 std::dynamic_pointer_cast<ModelAPI_AttributeDoubleArray>(attribute(RESULT_VALUES_ID()));
273 aValues->setSize((int)aValuesList.size());
275 for (std::list<double>::iterator anIt = aValuesList.begin(); anIt != aValuesList.end(); ++anIt)
276 aValues->setValue(anIndex++, *anIt);
279 static GeomVertexPtr selectionToVertex(const AttributeSelectionPtr& aSelection)
282 GeomVertexPtr aVertex;
283 if (aSelection && aSelection->isInitialized()) {
284 aShape = aSelection->value();
285 if (!aShape && aSelection->context())
286 aShape = aSelection->context()->shape();
288 if (aShape && aShape->isVertex())
289 aVertex = GeomVertexPtr(new GeomAPI_Vertex(aShape));
293 void FeaturesPlugin_Measurement::computeAngleByPoints()
295 GeomVertexPtr aVertex1 = selectionToVertex(selection(ANGLE_POINT1_ID()));
296 GeomVertexPtr aVertex2 = selectionToVertex(selection(ANGLE_POINT2_ID()));
297 GeomVertexPtr aVertex3 = selectionToVertex(selection(ANGLE_POINT3_ID()));
299 if (!aVertex1 || !aVertex2 || ! aVertex3) {
300 string(RESULT_ID())->setValue("");
304 std::shared_ptr<GeomAPI_Angle> anAngle(
305 new GeomAPI_Angle(aVertex1->point(), aVertex2->point(), aVertex3->point()));
306 double anAngleValue = anAngle->angleDegree();
308 std::ostringstream anOutput;
309 anOutput << "Angle = " << std::setprecision(10) << anAngleValue;
310 string(RESULT_ID())->setValue(anOutput.str());
312 AttributeDoubleArrayPtr aValues =
313 std::dynamic_pointer_cast<ModelAPI_AttributeDoubleArray>(attribute(RESULT_VALUES_ID()));
315 aValues->setValue(0, anAngleValue);
318 AISObjectPtr FeaturesPlugin_Measurement::getAISObject(AISObjectPtr thePrevious)
320 AttributeDoubleArrayPtr aValues =
321 std::dynamic_pointer_cast<ModelAPI_AttributeDoubleArray>(attribute(RESULT_VALUES_ID()));
322 if ((aValues->size() == 0) || (aValues->value(0) <= Precision::Confusion()))
323 return AISObjectPtr();
325 if (!myScreenPlane) {
326 // initialize a default plane for dimension
327 GeomPointPtr anOrigin(new GeomAPI_Pnt(0., 0., 0.));
328 GeomDirPtr aNormal(new GeomAPI_Dir(0., 0., 1.));
329 myScreenPlane = GeomPlanePtr(new GeomAPI_Pln(anOrigin, aNormal));
333 std::string aKind = string(MEASURE_KIND())->value();
334 if (aKind == MEASURE_LENGTH())
335 anAIS = lengthDimension(thePrevious);
336 else if (aKind == MEASURE_DISTANCE())
337 anAIS = distanceDimension(thePrevious);
338 else if (aKind == MEASURE_RADIUS())
339 anAIS = radiusDimension(thePrevious);
340 else if (aKind == MEASURE_ANGLE())
341 anAIS = angleDimension(thePrevious);
342 else if (aKind == MEASURE_ANGLE_POINTS())
343 anAIS = angleByPointsDimension(thePrevious);
344 setupDimension(anAIS);
348 AISObjectPtr FeaturesPlugin_Measurement::lengthDimension(AISObjectPtr thePrevious)
350 AISObjectPtr aAISObj;
352 AttributeSelectionPtr aSelectedFeature = selection(EDGE_FOR_LENGTH_ID());
356 if (aSelectedFeature && aSelectedFeature->isInitialized()) {
357 aShape = aSelectedFeature->value();
358 if (!aShape && aSelectedFeature->context())
359 aShape = aSelectedFeature->context()->shape();
361 if (aShape && aShape->isEdge())
362 anEdge = GeomEdgePtr(new GeomAPI_Edge(aShape));
364 TopoDS_Edge aTEdge = TopoDS::Edge(anEdge->impl<TopoDS_Shape>());
365 GeomPointPtr aPoint1 = anEdge->firstPoint();
366 GeomPointPtr aPoint2 = anEdge->lastPoint();
368 gp_Pnt aPnt1(aPoint1->impl<gp_Pnt>());
369 gp_Pnt aPnt2(aPoint2->impl<gp_Pnt>());
371 double aLength = aPnt1.Distance(aPnt2);
373 gp_Pln aPlane = myScreenPlane->impl<gp_Pln>(); // gce_MP.Value();
374 aPlane.SetLocation(aPnt1);
376 gp_XYZ aNormal = aPlane.Axis().Direction().XYZ();
377 gp_XYZ aVec(aPnt2.X() - aPnt1.X(), aPnt2.Y() - aPnt1.Y(), aPnt2.Z() - aPnt1.Z());
378 double aDot = aNormal.Dot(aVec);
379 if (fabs(aDot - aLength) <= Precision::Confusion()) {
380 aPlane = gp_Pln(aPnt1, aPlane.XAxis().Direction());
383 Handle(AIS_LengthDimension) aDim;
384 if (thePrevious.get()) {
385 aAISObj = thePrevious;
386 Handle(AIS_InteractiveObject) aAIS = aAISObj->impl<Handle(AIS_InteractiveObject)>();
387 aDim = Handle(AIS_LengthDimension)::DownCast(aAIS);
389 aDim = new AIS_LengthDimension(aTEdge, aPlane);
390 aAISObj = AISObjectPtr(new GeomAPI_AISObject());
391 aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aDim));
394 aDim->SetMeasuredGeometry(aTEdge, aPlane);
398 aDim = new AIS_LengthDimension(aTEdge, aPlane);
399 aAISObj = AISObjectPtr(new GeomAPI_AISObject());
400 aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aDim));
402 aDim->SetFlyout(aLength / 3.);
408 AISObjectPtr FeaturesPlugin_Measurement::distanceDimension(AISObjectPtr thePrevious)
410 AISObjectPtr aAISObj;
412 AttributeSelectionPtr aFirstFeature = selection(DISTANCE_FROM_OBJECT_ID());
413 AttributeSelectionPtr aSecondFeature = selection(DISTANCE_TO_OBJECT_ID());
414 if (aFirstFeature.get() && aSecondFeature.get()) {
415 GeomShapePtr aShape1;
416 GeomShapePtr aShape2;
417 if (aFirstFeature->isInitialized() && aSecondFeature->isInitialized()) {
418 aShape1 = aFirstFeature->value();
419 if (!aShape1 && aFirstFeature->context())
420 aShape1 = aFirstFeature->context()->shape();
421 aShape2 = aSecondFeature->value();
422 if (!aShape2 && aSecondFeature->context())
423 aShape2 = aSecondFeature->context()->shape();
426 if (aShape1 && aShape2) {
427 const TopoDS_Shape& aShp1 = aShape1->impl<TopoDS_Shape>();
428 const TopoDS_Shape& aShp2 = aShape2->impl<TopoDS_Shape>();
429 BRepExtrema_DistShapeShape aDist(aShp1, aShp2);
431 if (aDist.IsDone()) {
432 gp_Pnt aPnt1 = aDist.PointOnShape1(1);
433 gp_Pnt aPnt2 = aDist.PointOnShape2(1);
434 double aDistance = aDist.Value();
436 gp_Pln aPlane = myScreenPlane->impl<gp_Pln>();
437 aPlane.SetLocation(aPnt1);
439 gp_XYZ aNormal = aPlane.Axis().Direction().XYZ();
440 gp_XYZ aVec(aPnt2.X() - aPnt1.X(), aPnt2.Y() - aPnt1.Y(), aPnt2.Z() - aPnt1.Z());
441 double aDot = aNormal.Dot(aVec);
442 if (fabs(aDot - aDistance) <= Precision::Confusion()) {
443 aPlane = gp_Pln(aPnt1, aPlane.XAxis().Direction());
446 Handle(AIS_LengthDimension) aDim;
447 if (thePrevious.get()) {
448 aAISObj = thePrevious;
449 Handle(AIS_InteractiveObject) aAIS = aAISObj->impl<Handle(AIS_InteractiveObject)>();
450 aDim = Handle(AIS_LengthDimension)::DownCast(aAIS);
452 aDim = new AIS_LengthDimension(aPnt1, aPnt2, aPlane);
453 aAISObj = AISObjectPtr(new GeomAPI_AISObject());
454 aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aDim));
457 aDim->SetMeasuredGeometry(aPnt1, aPnt2, aPlane);
458 aDim->SetFlyout(aDistance / 3.);
462 aAISObj = AISObjectPtr(new GeomAPI_AISObject());
463 aDim = new AIS_LengthDimension(aPnt1, aPnt2, aPlane);
464 aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aDim));
466 aDim->SetFlyout(aDistance / 3.);
474 AISObjectPtr FeaturesPlugin_Measurement::radiusDimension(AISObjectPtr thePrevious)
476 AISObjectPtr aAISObj;
477 AttributeSelectionPtr aSelectedFeature = selection(CIRCULAR_OBJECT_ID());
480 if (aSelectedFeature && aSelectedFeature->isInitialized()) {
481 aShape = aSelectedFeature->value();
482 if (!aShape && aSelectedFeature->context())
483 aShape = aSelectedFeature->context()->shape();
486 TopoDS_Shape aShp = aShape->impl<TopoDS_Shape>();
487 Handle(AIS_RadiusDimension) aDim;
488 if (thePrevious.get()) {
489 aAISObj = thePrevious;
490 Handle(AIS_InteractiveObject) aAIS = aAISObj->impl<Handle(AIS_InteractiveObject)>();
491 Handle(AIS_RadiusDimension) aDim = Handle(AIS_RadiusDimension)::DownCast(aAIS);
493 aDim = new AIS_RadiusDimension(aShp);
494 aAISObj = AISObjectPtr(new GeomAPI_AISObject());
495 aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aDim));
497 aDim->SetMeasuredGeometry(aShp);
499 aAISObj = AISObjectPtr(new GeomAPI_AISObject());
500 Handle(AIS_RadiusDimension) aDim = new AIS_RadiusDimension(aShp);
501 aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aDim));
507 AISObjectPtr FeaturesPlugin_Measurement::angleDimension(AISObjectPtr thePrevious)
509 AISObjectPtr aAISObj;
510 AttributeSelectionPtr aFirstFeature = selection(ANGLE_FROM_EDGE_ID());
511 GeomShapePtr aShape1;
513 if (aFirstFeature && aFirstFeature->isInitialized()) {
514 aShape1 = aFirstFeature->value();
515 if (!aShape1 && aFirstFeature->context())
516 aShape1 = aFirstFeature->context()->shape();
518 if (aShape1 && aShape1->isEdge())
519 anEdge1 = GeomEdgePtr(new GeomAPI_Edge(aShape1));
521 AttributeSelectionPtr aSecondFeature = selection(ANGLE_TO_EDGE_ID());
522 GeomShapePtr aShape2;
524 if (aSecondFeature && aSecondFeature->isInitialized()) {
525 aShape2 = aSecondFeature->value();
526 if (!aShape2 && aSecondFeature->context())
527 aShape2 = aSecondFeature->context()->shape();
529 if (aShape2 && aShape2->isEdge())
530 anEdge2 = GeomEdgePtr(new GeomAPI_Edge(aShape2));
532 if (anEdge1.get() && anEdge2.get()) {
533 TopoDS_Edge aTEdge1 = TopoDS::Edge(anEdge1->impl<TopoDS_Shape>());
534 TopoDS_Edge aTEdge2 = TopoDS::Edge(anEdge2->impl<TopoDS_Shape>());
536 Handle(AIS_AngleDimension) aDim;
537 if (thePrevious.get()) {
538 aAISObj = thePrevious;
539 Handle(AIS_InteractiveObject) aAIS = aAISObj->impl<Handle(AIS_InteractiveObject)>();
540 aDim = Handle(AIS_AngleDimension)::DownCast(aAIS);
542 aDim = new AIS_AngleDimension(aTEdge1, aTEdge2);
543 aAISObj = AISObjectPtr(new GeomAPI_AISObject());
544 aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aDim));
546 aDim->SetMeasuredGeometry(aTEdge1, aTEdge2);
548 aAISObj = AISObjectPtr(new GeomAPI_AISObject());
549 aDim = new AIS_AngleDimension(aTEdge1, aTEdge2);
550 aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aDim));
556 AISObjectPtr FeaturesPlugin_Measurement::angleByPointsDimension(AISObjectPtr thePrevious)
558 AISObjectPtr aAISObj;
559 GeomVertexPtr aVertex1 = selectionToVertex(selection(ANGLE_POINT1_ID()));
560 GeomVertexPtr aVertex2 = selectionToVertex(selection(ANGLE_POINT2_ID()));
561 GeomVertexPtr aVertex3 = selectionToVertex(selection(ANGLE_POINT3_ID()));
563 if (aVertex1.get() && aVertex2.get() && aVertex3.get()) {
564 GeomPointPtr aPoint1 = aVertex1->point();
565 GeomPointPtr aPoint2 = aVertex2->point();
566 GeomPointPtr aPoint3 = aVertex3->point();
567 gp_Pnt aPnt1(aPoint1->impl<gp_Pnt>());
568 gp_Pnt aPnt2(aPoint2->impl<gp_Pnt>());
569 gp_Pnt aPnt3(aPoint3->impl<gp_Pnt>());
571 if (aPnt1.IsEqual(aPnt2, Precision::Confusion()) ||
572 aPnt1.IsEqual(aPnt3, Precision::Confusion()) ||
573 aPnt2.IsEqual(aPnt3, Precision::Confusion()))
576 if (thePrevious.get()) {
577 aAISObj = thePrevious;
578 Handle(AIS_InteractiveObject) aAIS = aAISObj->impl<Handle(AIS_InteractiveObject)>();
579 Handle(AIS_AngleDimension) aDim = Handle(AIS_AngleDimension)::DownCast(aAIS);
581 aDim = new AIS_AngleDimension(aPnt1, aPnt2, aPnt3);
582 aAISObj = AISObjectPtr(new GeomAPI_AISObject());
583 aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aDim));
585 aDim->SetMeasuredGeometry(aPnt1, aPnt2, aPnt3);
587 Handle(AIS_AngleDimension) aDim = new AIS_AngleDimension(aPnt1, aPnt2, aPnt3);
588 aAISObj = AISObjectPtr(new GeomAPI_AISObject());
589 aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aDim));
596 void FeaturesPlugin_Measurement::setupDimension(AISObjectPtr theDim)
599 Handle(AIS_InteractiveObject) aAIS = theDim->impl<Handle(AIS_InteractiveObject)>();
600 Handle(AIS_Dimension) aDim = Handle(AIS_Dimension)::DownCast(aAIS);
601 int aSize = Config_PropManager::integer("Visualization", "dimension_arrow_size");
602 int aTextSize = Config_PropManager::integer("Visualization", "dimension_value_size");
603 std::string aFont = Config_PropManager::string("Visualization", "dimension_font");
605 Handle(Prs3d_DimensionAspect) anAspect = aDim->DimensionAspect();
606 anAspect->MakeArrows3d(false);
607 anAspect->MakeText3d(false);
608 anAspect->MakeTextShaded(false);
609 anAspect->MakeUnitsDisplayed(false);
610 anAspect->MakeUnitsDisplayed(false);
611 anAspect->TextAspect()->SetFont(aFont.c_str());
612 anAspect->TextAspect()->SetHeight(aTextSize);
613 anAspect->ArrowAspect()->SetLength(aSize / mySceenScale);
614 anAspect->SetExtensionSize((aTextSize / mySceenScale + aSize) / 2.0);
615 aDim->SetDimensionAspect(anAspect);
617 aDim->SetZLayer(Graphic3d_ZLayerId_Top);
618 std::vector<int> aColor = Config_PropManager::color("Visualization", "sketch_dimension_color");
619 theDim->setColor(aColor[0], aColor[1], aColor[2]);