compositeFeature()->addFeature(SketchPlugin_ConstraintAngle::ID());
fillAttribute(SketcherPrs_Tools::ANGLE_DIRECT,
aFeature->integer(SketchPlugin_ConstraintAngle::TYPE_ID()));
+ fillAttribute(SketcherPrs_Tools::LOCATION_AUTOMATIC,
+ aFeature->integer(SketchPlugin_ConstraintAngle::LOCATION_TYPE_ID()));
// fill the value before llines to avoid calculation of angle value by the Angle feature
fillAttribute(theValue, aFeature->real(SketchPlugin_ConstraintAngle::ANGLE_VALUE_ID()));
fillAttribute(theLine1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
compositeFeature()->addFeature(SketchPlugin_ConstraintAngle::ID());
fillAttribute(SketcherPrs_Tools::ANGLE_COMPLEMENTARY,
aFeature->integer(SketchPlugin_ConstraintAngle::TYPE_ID()));
+ fillAttribute(SketcherPrs_Tools::LOCATION_AUTOMATIC,
+ aFeature->integer(SketchPlugin_ConstraintAngle::LOCATION_TYPE_ID()));
fillAttribute(theValue, aFeature->real(SketchPlugin_ConstraintAngle::ANGLE_VALUE_ID()));
fillAttribute(theLine1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
fillAttribute(theLine2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
compositeFeature()->addFeature(SketchPlugin_ConstraintAngle::ID());
fillAttribute(SketcherPrs_Tools::ANGLE_BACKWARD,
aFeature->integer(SketchPlugin_ConstraintAngle::TYPE_ID()));
+ fillAttribute(SketcherPrs_Tools::LOCATION_AUTOMATIC,
+ aFeature->integer(SketchPlugin_ConstraintAngle::LOCATION_TYPE_ID()));
fillAttribute(theValue, aFeature->real(SketchPlugin_ConstraintAngle::ANGLE_VALUE_ID()));
fillAttribute(theLine1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
fillAttribute(theLine2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
{
std::shared_ptr<ModelAPI_Feature> aFeature =
compositeFeature()->addFeature(SketchPlugin_ConstraintDistance::ID());
+ fillAttribute(SketcherPrs_Tools::LOCATION_AUTOMATIC,
+ aFeature->integer(SketchPlugin_ConstraintDistance::LOCATION_TYPE_ID()));
fillAttribute(thePoint, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
fillAttribute(thePointOrLine, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE()));
{
std::shared_ptr<ModelAPI_Feature> aFeature =
compositeFeature()->addFeature(SketchPlugin_ConstraintDistanceHorizontal::ID());
+ fillAttribute(SketcherPrs_Tools::LOCATION_AUTOMATIC,
+ aFeature->integer(SketchPlugin_ConstraintDistanceHorizontal::LOCATION_TYPE_ID()));
fillAttribute(thePoint1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
fillAttribute(thePoint2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE()));
{
std::shared_ptr<ModelAPI_Feature> aFeature =
compositeFeature()->addFeature(SketchPlugin_ConstraintDistanceVertical::ID());
+ fillAttribute(SketcherPrs_Tools::LOCATION_AUTOMATIC,
+ aFeature->integer(SketchPlugin_ConstraintDistanceVertical::LOCATION_TYPE_ID()));
fillAttribute(thePoint1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
fillAttribute(thePoint2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE()));
{
std::shared_ptr<ModelAPI_Feature> aFeature =
compositeFeature()->addFeature(SketchPlugin_ConstraintLength::ID());
+ fillAttribute(SketcherPrs_Tools::LOCATION_AUTOMATIC,
+ aFeature->integer(SketchPlugin_ConstraintLength::LOCATION_TYPE_ID()));
fillAttribute(theLine, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE()));
aFeature->execute();
{
std::shared_ptr<ModelAPI_Feature> aFeature =
compositeFeature()->addFeature(SketchPlugin_ConstraintRadius::ID());
+ fillAttribute(SketcherPrs_Tools::LOCATION_AUTOMATIC,
+ aFeature->integer(SketchPlugin_ConstraintRadius::LOCATION_TYPE_ID()));
fillAttribute(theCircleOrArc, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE()));
aFeature->execute();
ModelAPI_AttributeBoolean::typeId());
data()->addAttribute(SketchPlugin_ConstraintAngle::ANGLE_REVERSED_SECOND_LINE_ID(),
ModelAPI_AttributeBoolean::typeId());
+
+ data()->addAttribute(SketchPlugin_ConstraintAngle::LOCATION_TYPE_ID(),
+ ModelAPI_AttributeInteger::typeId());
}
void SketchPlugin_ConstraintAngle::colorConfigInfo(std::string& theSection, std::string& theName,
return MY_ANGLE_REVERSED_ID;
}
+ /// attribute name of dimension location type
+ inline static const std::string& LOCATION_TYPE_ID()
+ {
+ static const std::string MY_LOCATION_TYPE_ID("LocationType");
+ return MY_LOCATION_TYPE_ID;
+ }
+
+
/// \brief Creates a new part document if needed
SKETCHPLUGIN_EXPORT virtual void execute();
#include <GeomDataAPI_Point2D.h>
#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_AttributeInteger.h>
#include <ModelAPI_Data.h>
#include <Config_PropManager.h>
data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::typeId());
data()->addAttribute(SIGNED(), ModelAPI_AttributeBoolean::typeId());
+
+ data()->addAttribute(SketchPlugin_ConstraintDistance::LOCATION_TYPE_ID(),
+ ModelAPI_AttributeInteger::typeId());
}
void SketchPlugin_ConstraintDistance::colorConfigInfo(std::string& theSection, std::string& theName,
return MY_SIGNED;
}
+ /// attribute name of dimension location type
+ inline static const std::string& LOCATION_TYPE_ID()
+ {
+ static const std::string MY_LOCATION_TYPE_ID("LocationType");
+ return MY_LOCATION_TYPE_ID;
+ }
+
/// \brief Creates a new part document if needed
SKETCHPLUGIN_EXPORT virtual void execute();
#include <GeomDataAPI_Point2D.h>
#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_AttributeInteger.h>
const double tolerance = 1e-7;
data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::typeId());
data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::typeId());
+
+ data()->addAttribute(SketchPlugin_ConstraintDistanceHorizontal::LOCATION_TYPE_ID(),
+ ModelAPI_AttributeInteger::typeId());
}
//*************************************************************************************
return MY_KIND;
}
+ /// attribute name of dimension location type
+ inline static const std::string& LOCATION_TYPE_ID()
+ {
+ static const std::string MY_LOCATION_TYPE_ID("LocationType");
+ return MY_LOCATION_TYPE_ID;
+ }
+
+
/// \brief Creates a new part document if needed
SKETCHPLUGIN_EXPORT virtual void execute();
#include <GeomDataAPI_Point2D.h>
#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_AttributeInteger.h>
const double tolerance = 1e-7;
data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::typeId());
data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::typeId());
+
+ data()->addAttribute(SketchPlugin_ConstraintDistanceVertical::LOCATION_TYPE_ID(),
+ ModelAPI_AttributeInteger::typeId());
}
//*************************************************************************************
return MY_KIND;
}
+ /// attribute name of dimension location type
+ inline static const std::string& LOCATION_TYPE_ID()
+ {
+ static const std::string MY_LOCATION_TYPE_ID("LocationType");
+ return MY_LOCATION_TYPE_ID;
+ }
+
/// \brief Creates a new part document if needed
SKETCHPLUGIN_EXPORT virtual void execute();
#include <SketcherPrs_Factory.h>
#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_AttributeInteger.h>
#include <ModelAPI_Data.h>
#include <GeomAPI_Pnt2d.h>
data()->addAttribute(SketchPlugin_Constraint::VALUE(), ModelAPI_AttributeDouble::typeId());
data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::typeId());
+
+ data()->addAttribute(SketchPlugin_ConstraintRadius::LOCATION_TYPE_ID(),
+ ModelAPI_AttributeInteger::typeId());
}
void SketchPlugin_ConstraintRadius::colorConfigInfo(std::string& theSection, std::string& theName,
return MY_KIND;
}
+ /// attribute name of dimension location type
+ inline static const std::string& LOCATION_TYPE_ID()
+ {
+ static const std::string MY_LOCATION_TYPE_ID("LocationType");
+ return MY_LOCATION_TYPE_ID;
+ }
+
/// \brief Creates a new part document if needed
SKETCHPLUGIN_EXPORT virtual void execute();
#include <SketchPlugin_Ellipse.h>
#include <SketchPlugin_MacroEllipse.h>
+#include <SketcherPrs_Tools.h>
+
#include <Events_Loop.h>
#include <GeomDataAPI_Dir.h>
#include <Config_PropManager.h>
#include <memory>
+#include <sstream>
#ifdef _DEBUG
#include <iostream>
Config_PropManager::registerProp("Visualization", "xy_plane_color", "XY plane color",
Config_Prop::Color, XY_PLANE_COLOR);
#endif
+
+ Config_PropManager::registerProp(SKETCH_TAB_NAME, "dimension_font", "Dimension font", Config_Prop::String,
+ "Arial");
+ std::ostringstream aStream;
+ aStream << SketcherPrs_Tools::getDefaultTextHeight();
+ Config_PropManager::registerProp(SKETCH_TAB_NAME, "dimension_value_size", "Dimension value size", Config_Prop::Integer,
+ aStream.str());
+ aStream.str("");
+ aStream.clear();
+ aStream << SketcherPrs_Tools::getDefaultArrowSize();
+ Config_PropManager::registerProp(SKETCH_TAB_NAME, "dimension_arrow_size", "Dimension arrow size", Config_Prop::Integer,
+ aStream.str());
}
FeaturePtr SketchPlugin_Plugin::createFeature(std::string theFeatureID)
<validator id="GeomValidators_Positive"/>
</doublevalue_editor>
+ <module_choice id="LocationType"
+ widget_type="radiobuttons"
+ buttons_dir="horizontal"
+ label="Location type"
+ tooltip="Type of location"
+ string_list="Left Automatic Right"
+ icons_list="icons/Sketch/location_left.png icons/Sketch/location_automatic.png icons/Sketch/location_right.png"
+ default="1"
+ />
+
<boolvalue id="SignedDistance" label="Keep orientation" default="true" tooltip="Keep distance orientation" obligatory="0"/>
<validator id="PartSet_DistanceSelection"/>
</feature>
<doublevalue_editor label="Value" tooltip="Distance" id="ConstraintValue" default="computed"/>
+ <module_choice id="LocationType"
+ widget_type="radiobuttons"
+ buttons_dir="horizontal"
+ label="Location type"
+ tooltip="Type of location"
+ string_list="Left Automatic Right"
+ icons_list="icons/Sketch/location_left.png icons/Sketch/location_automatic.png icons/Sketch/location_right.png"
+ default="1"
+ />
+
<validator id="PartSet_DistanceSelection"/>
</feature>
<doublevalue_editor label="Value" tooltip="Distance" id="ConstraintValue" default="computed"/>
+ <module_choice id="LocationType"
+ widget_type="radiobuttons"
+ buttons_dir="horizontal"
+ label="Location type"
+ tooltip="Type of location"
+ string_list="Left Automatic Right"
+ icons_list="icons/Sketch/location_left.png icons/Sketch/location_automatic.png icons/Sketch/location_right.png"
+ default="1"
+ />
+
<validator id="PartSet_DistanceSelection"/>
</feature>
icons_list="icons/Sketch/angle_direct.png icons/Sketch/angle_complementary.png icons/Sketch/angle_backward.png"
default="0"
/>
+
+ <module_choice id="LocationType"
+ widget_type="radiobuttons"
+ buttons_dir="horizontal"
+ label="Location type"
+ tooltip="Type of location"
+ string_list="Left Automatic Right"
+ icons_list="icons/Sketch/location_left.png icons/Sketch/location_automatic.png icons/Sketch/location_right.png"
+ default="1"
+ />
+
</feature>
<!-- SketchConstraintRadius -->
<doublevalue_editor label="Value" tooltip="Radius" id="ConstraintValue" default="computed">
<validator id="GeomValidators_Positive"/>
</doublevalue_editor>
+
+ <module_choice id="LocationType"
+ widget_type="radiobuttons"
+ buttons_dir="horizontal"
+ label="Location type"
+ tooltip="Type of location"
+ string_list="Left Automatic Right"
+ icons_list="icons/Sketch/location_left.png icons/Sketch/location_automatic.png icons/Sketch/location_right.png"
+ default="1"
+ />
+
<validator id="PartSet_RadiusSelection"/>
</feature>
#include <TopExp.hxx>
#include <BRep_Tool.hxx>
+/// Update variable aspect parameters (depending on viewer scale)
+/// \param theDimAspect an aspect to be changed
+/// \param theDimValue an arrow value
+/// \param theTextSize an arrow value
+extern void updateArrows(Handle_Prs3d_DimensionAspect theDimAspect,
+ double theDimValue, double theTextSize, SketcherPrs_Tools::LocationType theLocationType);
+
#define PI 3.1415926535897932
//#ifndef WNT
// Update text visualization: parameter value or parameter text
myStyleListener->updateDimensions(this, myValue);
- myAspect->SetExtensionSize(myAspect->ArrowAspect()->Length());
- myAspect->SetArrowTailSize(myAspect->ArrowAspect()->Length());
+ double aTextSize = 0.0;
+ GetValueString(aTextSize);
+ AttributeIntegerPtr aLocationTypeAttr = std::dynamic_pointer_cast<ModelAPI_AttributeInteger>
+ (myConstraint->data()->attribute(SketchPlugin_ConstraintAngle::LOCATION_TYPE_ID()));
+ updateArrows(myAspect, GetValue(), aTextSize,
+ (SketcherPrs_Tools::LocationType)(aLocationTypeAttr->value()));
AIS_AngleDimension::Compute(thePresentationManager, thePresentation, theMode);
#include <AIS_DisplaySpecialSymbol.hxx>
-//#ifdef OCCT_28850_FIXED
+#define OCCT_28850_FIXED
/// Creates an aspect to be shown in length/radius dimension presentations
/// \return an instance of aspect
theDimAspect->SetTextHorizontalPosition(
theLocationType == SketcherPrs_Tools::LOCATION_LEFT ? Prs3d_DTHP_Left : Prs3d_DTHP_Right);
theDimAspect->SetArrowOrientation(Prs3d_DAO_External);
+
+ double anArrowLength = theDimAspect->ArrowAspect()->Length();
+ // This is not realy correct way to get viewer scale.
+ double aViewerScale = (double) SketcherPrs_Tools::getDefaultArrowSize() / anArrowLength;
+ theDimAspect->SetExtensionSize(
+ (theTextSize / aViewerScale + SketcherPrs_Tools::getArrowSize()) / 2.0);
}
theDimAspect->SetArrowTailSize(theDimAspect->ArrowAspect()->Length());
#ifdef OCCT_28850_FIXED
if (theConstraint->getKind() == SketchPlugin_ConstraintDistanceHorizontal::ID())
- SetDirection(true, mySketcherPlane->dirX()->impl<gp_Dir>());
+ SetDirection(mySketcherPlane->dirX()->impl<gp_Dir>(), true);
else if (theConstraint->getKind() == SketchPlugin_ConstraintDistanceVertical::ID())
- SetDirection(true, mySketcherPlane->dirY()->impl<gp_Dir>());
+ SetDirection(mySketcherPlane->dirY()->impl<gp_Dir>(), true);
#endif
}
double aTextSize = 0.0;
GetValueString(aTextSize);
- SketcherPrs_Tools::LocationType aLocationType = SketcherPrs_Tools::LOCATION_AUTOMATIC;
std::string aLocationAttribute;
- if (myConstraint->getKind() == SketchPlugin_ConstraintLength::ID())
+ std::string aConstraintKind = myConstraint->getKind();
+ if (aConstraintKind == SketchPlugin_ConstraintLength::ID())
aLocationAttribute = SketchPlugin_ConstraintLength::LOCATION_TYPE_ID();
- if (!aLocationAttribute.empty())
- {
- std::shared_ptr<ModelAPI_AttributeInteger> aTypeAttr = std::dynamic_pointer_cast<
- ModelAPI_AttributeInteger>(myConstraint->data()->attribute(aLocationAttribute));
- aLocationType = (SketcherPrs_Tools::LocationType)(aTypeAttr->value());
- }
- updateArrows(DimensionAspect(), GetValue(), aTextSize, aLocationType);
+ else if (aConstraintKind == SketchPlugin_ConstraintDistance::ID())
+ aLocationAttribute = SketchPlugin_ConstraintDistance::LOCATION_TYPE_ID();
+ else if (aConstraintKind == SketchPlugin_ConstraintDistanceHorizontal::ID())
+ aLocationAttribute = SketchPlugin_ConstraintDistanceHorizontal::LOCATION_TYPE_ID();
+ else if (aConstraintKind == SketchPlugin_ConstraintDistanceVertical::ID())
+ aLocationAttribute = SketchPlugin_ConstraintDistanceVertical::LOCATION_TYPE_ID();
+
+ std::shared_ptr<ModelAPI_AttributeInteger> aLocationTypeAttr = std::dynamic_pointer_cast<
+ ModelAPI_AttributeInteger>(myConstraint->data()->attribute(aLocationAttribute));
+ updateArrows(DimensionAspect(), GetValue(), aTextSize,
+ (SketcherPrs_Tools::LocationType)(aLocationTypeAttr->value()));
// Update text visualization: parameter value or parameter text
myStyleListener->updateDimensions(this, myValue);
#include <GeomAPI_Circ.h>
#include <GeomAPI_XYZ.h>
#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_AttributeInteger.h>
#include <gp_Circ.hxx>
// Update variable aspect parameters (depending on viewer scale)
double aTextSize = 0.0;
GetValueString(aTextSize);
- updateArrows(DimensionAspect(), GetValue(), aTextSize, SketcherPrs_Tools::LOCATION_AUTOMATIC);
-
+ AttributeIntegerPtr aLocationTypeAttr = std::dynamic_pointer_cast<ModelAPI_AttributeInteger>
+ (myConstraint->data()->attribute(SketchPlugin_ConstraintRadius::LOCATION_TYPE_ID()));
+ updateArrows(DimensionAspect(), GetValue(), aTextSize,
+ (SketcherPrs_Tools::LocationType)(aLocationTypeAttr->value()));
AIS_RadiusDimension::Compute(thePresentationManager, thePresentation, theMode);