-// Copyright (C) 2018-20xx CEA/DEN, EDF R&D
+// Copyright (C) 2018-2020 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "FeaturesPlugin_Measurement.h"
AttributeDoubleArrayPtr aValues =
std::dynamic_pointer_cast<ModelAPI_AttributeDoubleArray>(attribute(RESULT_VALUES_ID()));
if ((aValues->size() == 0) || (aValues->value(0) <= Precision::Confusion()))
- return thePrevious;
+ return AISObjectPtr();
+
+ if (!myScreenPlane) {
+ // initialize a default plane for dimension
+ GeomPointPtr anOrigin(new GeomAPI_Pnt(0., 0., 0.));
+ GeomDirPtr aNormal(new GeomAPI_Dir(0., 0., 1.));
+ myScreenPlane = GeomPlanePtr(new GeomAPI_Pln(anOrigin, aNormal));
+ }
AISObjectPtr anAIS;
std::string aKind = string(MEASURE_KIND())->value();
AISObjectPtr FeaturesPlugin_Measurement::lengthDimension(AISObjectPtr thePrevious)
{
AISObjectPtr aAISObj;
- if (!myScreenPlane.get())
- return aAISObj;
AttributeSelectionPtr aSelectedFeature = selection(EDGE_FOR_LENGTH_ID());
aDim = Handle(AIS_LengthDimension)::DownCast(aAIS);
if (aDim.IsNull()) {
aDim = new AIS_LengthDimension(aTEdge, aPlane);
+ aAISObj = AISObjectPtr(new GeomAPI_AISObject());
aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aDim));
}
else {
AISObjectPtr FeaturesPlugin_Measurement::distanceDimension(AISObjectPtr thePrevious)
{
AISObjectPtr aAISObj;
- if (!myScreenPlane.get())
- return aAISObj;
AttributeSelectionPtr aFirstFeature = selection(DISTANCE_FROM_OBJECT_ID());
AttributeSelectionPtr aSecondFeature = selection(DISTANCE_TO_OBJECT_ID());
aDim = Handle(AIS_LengthDimension)::DownCast(aAIS);
if (aDim.IsNull()) {
aDim = new AIS_LengthDimension(aPnt1, aPnt2, aPlane);
+ aAISObj = AISObjectPtr(new GeomAPI_AISObject());
aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aDim));
}
else {
Handle(AIS_RadiusDimension) aDim = Handle(AIS_RadiusDimension)::DownCast(aAIS);
if (aDim.IsNull()) {
aDim = new AIS_RadiusDimension(aShp);
+ aAISObj = AISObjectPtr(new GeomAPI_AISObject());
aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aDim));
} else
aDim->SetMeasuredGeometry(aShp);
aDim = Handle(AIS_AngleDimension)::DownCast(aAIS);
if (aDim.IsNull()) {
aDim = new AIS_AngleDimension(aTEdge1, aTEdge2);
+ aAISObj = AISObjectPtr(new GeomAPI_AISObject());
aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aDim));
} else
aDim->SetMeasuredGeometry(aTEdge1, aTEdge2);
Handle(AIS_AngleDimension) aDim = Handle(AIS_AngleDimension)::DownCast(aAIS);
if (aDim.IsNull()) {
aDim = new AIS_AngleDimension(aPnt1, aPnt2, aPnt3);
+ aAISObj = AISObjectPtr(new GeomAPI_AISObject());
aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aDim));
} else
aDim->SetMeasuredGeometry(aPnt1, aPnt2, aPnt3);
anAspect->SetExtensionSize((aTextSize / mySceenScale + aSize) / 2.0);
aDim->SetDimensionAspect(anAspect);
- aDim->SetZLayer(1);
+ aDim->SetZLayer(Graphic3d_ZLayerId_Top);
std::vector<int> aColor = Config_PropManager::color("Visualization", "sketch_dimension_color");
theDim->setColor(aColor[0], aColor[1], aColor[2]);
}