// -arrowangle ArrowAngle(degrees)
// -plane xoy|yoz|zox
// -flyout FloatValue -extension FloatValue
+// -value CustomNumberValue
+// -dispunits DisplayUnitsString
+// -modelunits ModelUnitsString
+// -showunits
+// -hideunits
//
// Warning! flyout is not an aspect value, it is for dimension parameter
-// likewise text position, but text position override other paramaters
-// For this use 'vmovedim'.
+// likewise text position, but text position override other paramaters.
+// For text position changing use 'vmovedim'.
//=======================================================================
static int ParseDimensionParams (Standard_Integer theArgNum,
const char** theArgVec,
Standard_Integer theStartIndex,
const Handle(Prs3d_DimensionAspect)& theAspect,
- Standard_Boolean& theIsCustomPlane,
- gp_Pln& thePlane,
- Standard_Boolean& theIsCustomFlyout,
- Standard_Real& theFlyoutSize,
+ Standard_Boolean& theIsCustomPlane, gp_Pln& thePlane,
+ NCollection_DataMap<TCollection_AsciiString, Standard_Real>& theRealParams,
+ NCollection_DataMap<TCollection_AsciiString, TCollection_AsciiString>& theStringParams,
NCollection_List<Handle(AIS_InteractiveObject)>* theShapeList = NULL)
{
+ theRealParams.Clear();
+ theStringParams.Clear();
+
theIsCustomPlane = Standard_False;
- theIsCustomFlyout = Standard_False;
- // Begin from the second parameter: the first on eis dimension name
+ // Begin from the second parameter: the first one is dimension name
for (Standard_Integer anIt = theStartIndex; anIt < theArgNum; ++anIt)
{
TCollection_AsciiString aParam (theArgVec[anIt]);
continue;
}
+ // Boolean flags
+ if (aParam.IsEqual ("-showunits"))
+ {
+ theAspect->MakeUnitsDisplayed (Standard_True);
+ continue;
+ }
+ else if (aParam.IsEqual ("-hideunits"))
+ {
+ theAspect->MakeUnitsDisplayed (Standard_False);
+ continue;
+ }
+
// Before all non-boolean flags parsing check if a flag have at least one value.
if (anIt + 1 >= theArgNum)
{
}
theAspect->ArrowAspect()->SetAngle (Draw::Atof (aValue.ToCString()));
}
+ else if (aParam.IsEqual ("-color"))
+ {
+ theAspect->SetCommonColor (Quantity_Color (ViewerTest::GetColorFromName (theArgVec[++anIt])));
+ }
+ else if (aParam.IsEqual ("-extension"))
+ {
+ TCollection_AsciiString aParam (theArgVec[++anIt]);
+ if (!aParam.IsRealValue())
+ {
+ std::cerr << "Error: extension size for dimension should be real value.\n";
+ return 1;
+ }
+ theAspect->SetExtensionSize (Draw::Atof (aParam.ToCString()));
+ }
else if (aParam.IsEqual ("-plane"))
{
TCollection_AsciiString aValue (theArgVec[++anIt]);
return 1;
}
- theIsCustomFlyout = Standard_True;
- theFlyoutSize = Draw::Atoi (aParam.ToCString());
- }
- else if (aParam.IsEqual ("-color"))
- {
- theAspect->SetCommonColor (Quantity_Color (ViewerTest::GetColorFromName (theArgVec[++anIt])));
+ theRealParams.Bind ("flyout", Draw::Atof (aParam.ToCString()));
}
- else if (aParam.IsEqual ("-extension"))
+ else if (aParam.IsEqual ("-value"))
{
TCollection_AsciiString aParam (theArgVec[++anIt]);
if (!aParam.IsRealValue())
{
- std::cerr << "Error: extension size for dimension should be real value.\n";
+ std::cerr << "Error: dimension value for dimension should be real value.\n";
return 1;
}
- theAspect->SetExtensionSize (Draw::Atof (aParam.ToCString()));
+
+ theRealParams.Bind ("value", Draw::Atof (aParam.ToCString()));
+ }
+ else if (aParam.IsEqual ("-modelunits"))
+ {
+ TCollection_AsciiString aParam (theArgVec[++anIt]);
+
+ theStringParams.Bind ("modelunits", aParam);
+ }
+ else if (aParam.IsEqual ("-dispunits"))
+ {
+ TCollection_AsciiString aParam (theArgVec[++anIt]);
+
+ theStringParams.Bind ("dispunits", aParam);
}
else
{
return 0;
}
+//=======================================================================
+//function : SetDimensionParams
+//purpose : Sets parameters for dimension
+//=======================================================================
+static void SetDimensionParams (const Handle(AIS_Dimension)& theDim,
+ const NCollection_DataMap<TCollection_AsciiString, Standard_Real>& theRealParams,
+ const NCollection_DataMap<TCollection_AsciiString, TCollection_AsciiString>& theStringParams)
+{
+ if (theRealParams.IsBound ("flyout"))
+ {
+ theDim->SetFlyout (theRealParams.Find ("flyout"));
+ }
+
+ if (theRealParams.IsBound ("value"))
+ {
+ theDim->SetCustomValue (theRealParams.Find ("value"));
+ }
+
+ if (theStringParams.IsBound ("modelunits"))
+ {
+ theDim->SetModelUnits (theStringParams.Find ("modelunits"));
+ }
+
+ if (theStringParams.IsBound ("dispunits"))
+ {
+ theDim->SetDisplayUnits (theStringParams.Find ("dispunits"));
+ }
+}
+
//=======================================================================
//function : VDimBuilder
//purpose : Command for building dimension presentations: angle,
Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect;
Standard_Boolean isPlaneCustom = Standard_False;
gp_Pln aWorkingPlane;
- Standard_Boolean isCustomFlyout = Standard_False;
- Standard_Real aCustomFlyout = 0.0;
+
+ NCollection_DataMap<TCollection_AsciiString, Standard_Real> aRealParams;
+ NCollection_DataMap<TCollection_AsciiString, TCollection_AsciiString> aStringParams;
TCollection_AsciiString aDimType(theArgs[2]);
aDimType.LowerCase();
}
- ParseDimensionParams (theArgsNb, theArgs, 3,
- anAspect,isPlaneCustom,aWorkingPlane,
- isCustomFlyout,aCustomFlyout, &aShapes);
+ if (ParseDimensionParams (theArgsNb, theArgs, 3,
+ anAspect,isPlaneCustom,aWorkingPlane,
+ aRealParams, aStringParams, &aShapes))
+ {
+ return 1;
+ }
// Build dimension
Handle(AIS_Dimension) aDim;
aDim->SetDimensionAspect (anAspect);
- if (isCustomFlyout)
- {
- aDim->SetFlyout (aCustomFlyout);
- }
+ SetDimensionParams (aDim, aRealParams, aStringParams);
VDisplayAISObject (aName,aDim);
TCollection_AsciiString aName (theArgVec[1]);
gp_Pln aWorkingPlane;
- Standard_Real aCustomFlyout = 0.0;
Standard_Boolean isCustomPlane = Standard_False;
- Standard_Boolean isCustomFlyout = Standard_False;
Standard_Boolean toUpdate = Standard_True;
+ NCollection_DataMap<TCollection_AsciiString, Standard_Real> aRealParams;
+ NCollection_DataMap<TCollection_AsciiString, TCollection_AsciiString> aStringParams;
+
if (!GetMapOfAIS().IsBound2 (aName))
{
theDi << theArgVec[0] << "error: no object with this name.\n";
Handle(AIS_Dimension) aDim = Handle(AIS_Dimension)::DownCast (anObject);
Handle(Prs3d_DimensionAspect) anAspect = aDim->DimensionAspect();
- ParseDimensionParams (theArgNum, theArgVec, 2, anAspect,
- isCustomPlane, aWorkingPlane,
- isCustomFlyout, aCustomFlyout);
+ if (ParseDimensionParams (theArgNum, theArgVec, 2, anAspect,
+ isCustomPlane, aWorkingPlane,
+ aRealParams, aStringParams))
+ {
+ return 1;
+ }
if (isCustomPlane)
{
aDim->SetCustomPlane (aWorkingPlane);
}
- if (isCustomFlyout)
- {
- aDim->SetFlyout (aCustomFlyout);
- }
+ SetDimensionParams (aDim, aRealParams, aStringParams);
if (!aDim->IsValid())
{
"[-arrowangle ArrowAngle(degrees)]\n"
"[-plane xoy|yoz|zox]\n"
"[-flyout FloatValue -extension FloatValue]\n"
- " -Builds angle, length, radius and diameter dimensions.\n",
+ "[-value CustomNumberValue]\n"
+ "[-dispunits DisplayUnitsString]\n"
+ "[-modelunits ModelUnitsString]\n"
+ "[-showunits | -hideunits]\n"
+ " -Builds angle, length, radius and diameter dimensions.\n"
+ " -See also: vdimparam, vmovedim.\n",
__FILE__,VDimBuilder,group);
theCommands.Add("vdimparam",
"[-arrowangle ArrowAngle(degrees)]\n"
"[-plane xoy|yoz|zox]\n"
"[-flyout FloatValue -extension FloatValue]\n"
- " -Sets parameters for angle, length, radius and diameter dimensions.\n",
+ "[-value CustomNumberValue]\n"
+ "[-dispunits DisplayUnitsString]\n"
+ "[-modelunits ModelUnitsString]\n"
+ "[-showunits | -hideunits]\n"
+ " -Sets parameters for angle, length, radius and diameter dimensions.\n"
+ " -See also: vmovedim, vdimension.\n",
__FILE__,VDimParam,group);
theCommands.Add("vangledim",