**Example:**
~~~~~
-Vinitvinit
+vinit
vpoint p1 0 0 0
vpoint p2 50 0 0
vsegment segment p1 p2
[-label left|right|hcenter|hfit top|bottom|vcenter|vfit]
[-arrow external|internal|fit] [{-arrowlength|-arlen} RealArrowLength]
[{-arrowangle|-arangle} ArrowAngle(degrees)] [-plane xoy|yoz|zox]
- [-flyout FloatValue -extension FloatValue] [-value CustomNumberValue]
- [-dispunits DisplayUnitsString] [-modelunits ModelUnitsString]
- [-showunits | -hideunits]
+ [-flyout FloatValue -extension FloatValue]
+ [-autovalue] [-value CustomRealValue] [-textvalue CustomTextValue]
+ [-dispunits DisplayUnitsString]
+ [-modelunits ModelUnitsString] [-showunits | -hideunits]
~~~~~
Builds angle, length, radius or diameter dimension interactive object **name**.
**Example:**
~~~~~
+vinit
vpoint p1 0 0 0
vpoint p2 50 50 0
vdimension dim1 -length -plane xoy -shapes p1 p2
[{-arrowangle|-arangle} ArrowAngle(degrees)]
[-plane xoy|yoz|zox]
[-flyout FloatValue -extension FloatValue]
- [-value CustomNumberValue]
+ [-autovalue]
+ [-value CustomRealValue]
+ [-textvalue CustomTextValue]
[-dispunits DisplayUnitsString]
[-modelunits ModelUnitsString]
[-showunits | -hideunits]
**Example:**
~~~~~
+vinit
vpoint p1 0 0 0
vpoint p2 50 50 0
vdimension dim1 -length -plane xoy -shapes p1 p2
vdimparam dim1 -flyout -15 -arrowlength 4 -showunits -value 10
+vfit
+vdimparam dim1 -textvalue "w_1"
+vdimparam dim1 -autovalue
~~~~~
@subsubsection occt_draw_4_4_22 vmovedim
**Example:**
~~~~~
+vinit
vpoint p1 0 0 0
vpoint p2 50 50 0
vdimension dim1 -length -plane xoy -shapes p1 p2
AIS_Dimension::AIS_Dimension (const AIS_KindOfDimension theType)
: AIS_InteractiveObject (),
mySelToleranceForText2d(0.0),
+ myValueType (ValueType_Computed),
myCustomValue (0.0),
- myIsValueCustom (Standard_False),
+ myCustomStringValue (),
myIsTextPositionFixed (Standard_False),
mySpecialSymbol (' '),
myDisplaySpecialSymbol (AIS_DSS_No),
//=======================================================================
void AIS_Dimension::SetCustomValue (const Standard_Real theValue)
{
- if (myIsValueCustom && myCustomValue == theValue)
+ if (myValueType == ValueType_CustomReal && myCustomValue == theValue)
{
return;
}
- myIsValueCustom = Standard_True;
-
+ myValueType = ValueType_CustomReal;
myCustomValue = theValue;
SetToUpdate();
}
+//=======================================================================
+//function : SetCustomValue
+//purpose :
+//=======================================================================
+void AIS_Dimension::SetCustomValue (const TCollection_ExtendedString& theValue)
+{
+ if (myValueType == ValueType_CustomText && myCustomStringValue == theValue)
+ {
+ return;
+ }
+
+ myValueType = ValueType_CustomText;
+ myCustomStringValue = theValue;
+
+ SetToUpdate();
+}
+
+//=======================================================================
+//function : GetCustomValue
+//purpose :
+//=======================================================================
+const TCollection_ExtendedString& AIS_Dimension::GetCustomValue () const
+{
+ return myCustomStringValue;
+}
+
//=======================================================================
//function : GetPlane
//purpose :
//=======================================================================
TCollection_ExtendedString AIS_Dimension::GetValueString (Standard_Real& theWidth) const
{
- // format value string using "sprintf"
- TCollection_AsciiString aFormatStr = myDrawer->DimensionAspect()->ValueStringFormat();
+ TCollection_ExtendedString aValueStr;
+ if (myValueType == ValueType_CustomText)
+ {
+ aValueStr = myCustomStringValue;
+ }
+ else
+ {
+ // format value string using "sprintf"
+ TCollection_AsciiString aFormatStr = myDrawer->DimensionAspect()->ValueStringFormat();
- char aFmtBuffer[256];
- sprintf (aFmtBuffer, aFormatStr.ToCString(), ValueToDisplayUnits());
- TCollection_ExtendedString aValueStr = TCollection_ExtendedString (aFmtBuffer);
+ char aFmtBuffer[256];
+ sprintf (aFmtBuffer, aFormatStr.ToCString(), ValueToDisplayUnits());
+ aValueStr = TCollection_ExtendedString (aFmtBuffer);
+ }
// add units to values string
if (myDrawer->DimensionAspect()->IsUnitsDisplayed())
LabelPosition_VMask = LabelPosition_Above | LabelPosition_Below | LabelPosition_VCenter
};
+ enum ValueType
+ {
+ ValueType_Computed,
+ ValueType_CustomReal,
+ ValueType_CustomText
+ };
+
public:
//! Specifies supported presentation compute modes.
//! during display of the presentation.
Standard_Real GetValue() const
{
- return myIsValueCustom ? myCustomValue : ComputeValue();
+ return myValueType == ValueType_CustomReal ? myCustomValue : ComputeValue();
+ }
+
+ //! Sets computed dimension value. Resets custom value mode if it was set.
+ void SetComputedValue ()
+ {
+ myValueType = ValueType_Computed;
}
//! Sets user-defined dimension value.
//! @param theValue [in] the user-defined value to display.
Standard_EXPORT void SetCustomValue (const Standard_Real theValue);
+ //! Sets user-defined dimension value.
+ //! Unit conversion during the display is not applyed.
+ //! @param theValue [in] the user-defined value to display.
+ Standard_EXPORT void SetCustomValue (const TCollection_ExtendedString& theValue);
+
+ //! Gets user-defined dimension value.
+ //! @return dimension value string.
+ Standard_EXPORT const TCollection_ExtendedString& GetCustomValue () const;
+
//! Get the dimension plane in which the 2D dimension presentation is computed.
//! By default, if plane is not defined by user, it is computed automatically
//! after dimension geometry is computed.
protected: //! @name Value properties
+ ValueType myValueType; //! type of value (computed or user-defined)
Standard_Real myCustomValue; //!< Value of the dimension (computed or user-defined).
- Standard_Boolean myIsValueCustom; //!< Is user-defined value.
+
+ TCollection_ExtendedString myCustomStringValue; //!< Value of the dimension (computed or user-defined).
protected: //! @name Fixed text position properties
// -arrowangle ArrowAngle(degrees)
// -plane xoy|yoz|zox
// -flyout FloatValue -extension FloatValue
-// -value CustomNumberValue
+// -autovalue
+// -value CustomRealValue
+// -textvalue CustomTextValue
// -dispunits DisplayUnitsString
// -modelunits ModelUnitsString
// -showunits
}
// Boolean flags
+ if (aParam.IsEqual ("-autovalue"))
+ {
+ theRealParams.Bind ("autovalue", 1);
+ continue;
+ }
+
if (aParam.IsEqual ("-showunits"))
{
theAspect->MakeUnitsDisplayed (Standard_True);
theRealParams.Bind ("value", Draw::Atof (aLocalParam.ToCString()));
}
+ else if (aParam.IsEqual ("-textvalue"))
+ {
+ TCollection_AsciiString aLocalParam(theArgVec[++anIt]);
+
+ theStringParams.Bind ("textvalue", aLocalParam);
+ }
else if (aParam.IsEqual ("-modelunits"))
{
TCollection_AsciiString aLocalParam(theArgVec[++anIt]);
theDim->SetFlyout (theRealParams.Find ("flyout"));
}
+ if (theRealParams.IsBound ("autovalue"))
+ {
+ theDim->SetComputedValue();
+ }
+
if (theRealParams.IsBound ("value"))
{
theDim->SetCustomValue (theRealParams.Find ("value"));
}
+ if (theStringParams.IsBound ("textvalue"))
+ {
+ theDim->SetCustomValue (theStringParams.Find ("textvalue"));
+ }
+
if (theStringParams.IsBound ("modelunits"))
{
theDim->SetModelUnits (theStringParams.Find ("modelunits"));
"[{-arrowangle|-arangle} ArrowAngle(degrees)]\n"
"[-plane xoy|yoz|zox]\n"
"[-flyout FloatValue -extension FloatValue]\n"
- "[-value CustomNumberValue]\n"
+ "[-autovalue]\n"
+ "[-value CustomRealValue]\n"
+ "[-textvalue CustomTextValue]\n"
"[-dispunits DisplayUnitsString]\n"
"[-modelunits ModelUnitsString]\n"
"[-showunits | -hideunits]\n"
"[-plane xoy|yoz|zox]\n"
"[-flyout FloatValue -extension FloatValue]\n"
"[-value CustomNumberValue]\n"
+ "[-textvalue CustomTextValue]\n"
"[-dispunits DisplayUnitsString]\n"
"[-modelunits ModelUnitsString]\n"
"[-showunits | -hideunits]\n"
--- /dev/null
+puts "========"
+puts "Visualization, AIS_Dimension - add possibility to set custom text value"
+puts "========"
+
+# Test case creates three lenght dimensions where value is set as real,
+# as text and is reset to auto value state.
+
+pload MODELING VISUALIZATION
+
+vinit
+vpoint p1 0 0 0
+vpoint p2 50 50 0
+
+vdimension dim1 -length -plane xoy -shapes p1 p2
+vdimparam dim1 -flyout -15 -arrowlength 4 -showunits -value 10
+
+
+vpoint p3 100 100 0
+vpoint p4 150 150 0
+
+vdimension dim2 -length -plane xoy -shapes p3 p4
+vdimparam dim2 -flyout -15 -arrowlength 4 -hideunits -textvalue "w_1"
+vfit
+
+
+vpoint p5 200 200 0
+vpoint p6 250 250 0
+
+vdimension dim3 -length -plane xoy -shapes p5 p6
+vdimparam dim3 -flyout -15 -arrowlength 4 -showunits -textvalue "w_1"
+vdimparam dim3 -autovalue
+
+vfit
+vdump $imagedir/${casename}.png