mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-07 18:30:55 +03:00
0025403: Wrong storage of model units in AIS_AngleDimension: corrected AIS_Drawer model units setters; added parameters to vdimensin and vdimparam commands.
This commit is contained in:
parent
09f5e48e01
commit
1c9d151726
@ -27,7 +27,11 @@ AIS_Drawer::AIS_Drawer()
|
|||||||
myhasOwnHLRDeviationCoefficient (Standard_False),
|
myhasOwnHLRDeviationCoefficient (Standard_False),
|
||||||
myhasOwnDeviationAngle (Standard_False),
|
myhasOwnDeviationAngle (Standard_False),
|
||||||
myhasOwnHLRDeviationAngle (Standard_False),
|
myhasOwnHLRDeviationAngle (Standard_False),
|
||||||
myHasOwnFaceBoundaryDraw (Standard_False)
|
myHasOwnFaceBoundaryDraw (Standard_False),
|
||||||
|
myHasOwnDimLengthModelUnits (Standard_False),
|
||||||
|
myHasOwnDimLengthDisplayUnits (Standard_False),
|
||||||
|
myHasOwnDimAngleModelUnits (Standard_False),
|
||||||
|
myHasOwnDimAngleDisplayUnits (Standard_False)
|
||||||
{
|
{
|
||||||
SetMaximalParameterValue (500000.0);
|
SetMaximalParameterValue (500000.0);
|
||||||
myLink->SetMaximalParameterValue (500000.0);
|
myLink->SetMaximalParameterValue (500000.0);
|
||||||
@ -265,7 +269,7 @@ const TCollection_AsciiString& AIS_Drawer::DimLengthModelUnits() const
|
|||||||
void AIS_Drawer::SetDimLengthModelUnits (const TCollection_AsciiString& theUnits)
|
void AIS_Drawer::SetDimLengthModelUnits (const TCollection_AsciiString& theUnits)
|
||||||
{
|
{
|
||||||
myHasOwnDimLengthModelUnits = Standard_True;
|
myHasOwnDimLengthModelUnits = Standard_True;
|
||||||
Prs3d_Drawer::SetDimLengthDisplayUnits (theUnits);
|
Prs3d_Drawer::SetDimLengthModelUnits (theUnits);
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
@ -275,7 +279,7 @@ void AIS_Drawer::SetDimLengthModelUnits (const TCollection_AsciiString& theUnits
|
|||||||
void AIS_Drawer::SetDimAngleModelUnits (const TCollection_AsciiString& theUnits)
|
void AIS_Drawer::SetDimAngleModelUnits (const TCollection_AsciiString& theUnits)
|
||||||
{
|
{
|
||||||
myHasOwnDimAngleModelUnits = Standard_True;
|
myHasOwnDimAngleModelUnits = Standard_True;
|
||||||
Prs3d_Drawer::SetDimAngleDisplayUnits (theUnits);
|
Prs3d_Drawer::SetDimAngleModelUnits (theUnits);
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
|
@ -176,23 +176,29 @@ static Standard_Boolean Get3DPointAtMousePosition (const gp_Pnt& theFirstPoint,
|
|||||||
// -arrowangle ArrowAngle(degrees)
|
// -arrowangle ArrowAngle(degrees)
|
||||||
// -plane xoy|yoz|zox
|
// -plane xoy|yoz|zox
|
||||||
// -flyout FloatValue -extension FloatValue
|
// -flyout FloatValue -extension FloatValue
|
||||||
|
// -value CustomNumberValue
|
||||||
|
// -dispunits DisplayUnitsString
|
||||||
|
// -modelunits ModelUnitsString
|
||||||
|
// -showunits
|
||||||
|
// -hideunits
|
||||||
//
|
//
|
||||||
// Warning! flyout is not an aspect value, it is for dimension parameter
|
// Warning! flyout is not an aspect value, it is for dimension parameter
|
||||||
// likewise text position, but text position override other paramaters
|
// likewise text position, but text position override other paramaters.
|
||||||
// For this use 'vmovedim'.
|
// For text position changing use 'vmovedim'.
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
static int ParseDimensionParams (Standard_Integer theArgNum,
|
static int ParseDimensionParams (Standard_Integer theArgNum,
|
||||||
const char** theArgVec,
|
const char** theArgVec,
|
||||||
Standard_Integer theStartIndex,
|
Standard_Integer theStartIndex,
|
||||||
const Handle(Prs3d_DimensionAspect)& theAspect,
|
const Handle(Prs3d_DimensionAspect)& theAspect,
|
||||||
Standard_Boolean& theIsCustomPlane,
|
Standard_Boolean& theIsCustomPlane, gp_Pln& thePlane,
|
||||||
gp_Pln& thePlane,
|
NCollection_DataMap<TCollection_AsciiString, Standard_Real>& theRealParams,
|
||||||
Standard_Boolean& theIsCustomFlyout,
|
NCollection_DataMap<TCollection_AsciiString, TCollection_AsciiString>& theStringParams,
|
||||||
Standard_Real& theFlyoutSize,
|
|
||||||
NCollection_List<Handle(AIS_InteractiveObject)>* theShapeList = NULL)
|
NCollection_List<Handle(AIS_InteractiveObject)>* theShapeList = NULL)
|
||||||
{
|
{
|
||||||
|
theRealParams.Clear();
|
||||||
|
theStringParams.Clear();
|
||||||
|
|
||||||
theIsCustomPlane = Standard_False;
|
theIsCustomPlane = Standard_False;
|
||||||
theIsCustomFlyout = Standard_False;
|
|
||||||
|
|
||||||
// Begin from the second parameter: the first one is dimension name
|
// Begin from the second parameter: the first one is dimension name
|
||||||
for (Standard_Integer anIt = theStartIndex; anIt < theArgNum; ++anIt)
|
for (Standard_Integer anIt = theStartIndex; anIt < theArgNum; ++anIt)
|
||||||
@ -205,6 +211,18 @@ static int ParseDimensionParams (Standard_Integer theArgNum,
|
|||||||
continue;
|
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.
|
// Before all non-boolean flags parsing check if a flag have at least one value.
|
||||||
if (anIt + 1 >= theArgNum)
|
if (anIt + 1 >= theArgNum)
|
||||||
{
|
{
|
||||||
@ -330,6 +348,20 @@ static int ParseDimensionParams (Standard_Integer theArgNum,
|
|||||||
}
|
}
|
||||||
theAspect->ArrowAspect()->SetAngle (Draw::Atof (aValue.ToCString()));
|
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"))
|
else if (aParam.IsEqual ("-plane"))
|
||||||
{
|
{
|
||||||
TCollection_AsciiString aValue (theArgVec[++anIt]);
|
TCollection_AsciiString aValue (theArgVec[++anIt]);
|
||||||
@ -364,22 +396,30 @@ static int ParseDimensionParams (Standard_Integer theArgNum,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
theIsCustomFlyout = Standard_True;
|
theRealParams.Bind ("flyout", Draw::Atof (aParam.ToCString()));
|
||||||
theFlyoutSize = Draw::Atoi (aParam.ToCString());
|
|
||||||
}
|
}
|
||||||
else if (aParam.IsEqual ("-color"))
|
else if (aParam.IsEqual ("-value"))
|
||||||
{
|
|
||||||
theAspect->SetCommonColor (Quantity_Color (ViewerTest::GetColorFromName (theArgVec[++anIt])));
|
|
||||||
}
|
|
||||||
else if (aParam.IsEqual ("-extension"))
|
|
||||||
{
|
{
|
||||||
TCollection_AsciiString aParam (theArgVec[++anIt]);
|
TCollection_AsciiString aParam (theArgVec[++anIt]);
|
||||||
if (!aParam.IsRealValue())
|
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;
|
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
|
else
|
||||||
{
|
{
|
||||||
@ -391,6 +431,35 @@ static int ParseDimensionParams (Standard_Integer theArgNum,
|
|||||||
return 0;
|
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
|
//function : VDimBuilder
|
||||||
//purpose : Command for building dimension presentations: angle,
|
//purpose : Command for building dimension presentations: angle,
|
||||||
@ -413,8 +482,9 @@ static int VDimBuilder (Draw_Interpretor& /*theDi*/,
|
|||||||
Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect;
|
Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect;
|
||||||
Standard_Boolean isPlaneCustom = Standard_False;
|
Standard_Boolean isPlaneCustom = Standard_False;
|
||||||
gp_Pln aWorkingPlane;
|
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]);
|
TCollection_AsciiString aDimType(theArgs[2]);
|
||||||
aDimType.LowerCase();
|
aDimType.LowerCase();
|
||||||
@ -442,9 +512,12 @@ static int VDimBuilder (Draw_Interpretor& /*theDi*/,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ParseDimensionParams (theArgsNb, theArgs, 3,
|
if (ParseDimensionParams (theArgsNb, theArgs, 3,
|
||||||
anAspect,isPlaneCustom,aWorkingPlane,
|
anAspect,isPlaneCustom,aWorkingPlane,
|
||||||
isCustomFlyout,aCustomFlyout, &aShapes);
|
aRealParams, aStringParams, &aShapes))
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
// Build dimension
|
// Build dimension
|
||||||
Handle(AIS_Dimension) aDim;
|
Handle(AIS_Dimension) aDim;
|
||||||
@ -621,10 +694,7 @@ static int VDimBuilder (Draw_Interpretor& /*theDi*/,
|
|||||||
|
|
||||||
aDim->SetDimensionAspect (anAspect);
|
aDim->SetDimensionAspect (anAspect);
|
||||||
|
|
||||||
if (isCustomFlyout)
|
SetDimensionParams (aDim, aRealParams, aStringParams);
|
||||||
{
|
|
||||||
aDim->SetFlyout (aCustomFlyout);
|
|
||||||
}
|
|
||||||
|
|
||||||
VDisplayAISObject (aName,aDim);
|
VDisplayAISObject (aName,aDim);
|
||||||
|
|
||||||
@ -2444,11 +2514,12 @@ static int VDimParam (Draw_Interpretor& theDi, Standard_Integer theArgNum, const
|
|||||||
|
|
||||||
TCollection_AsciiString aName (theArgVec[1]);
|
TCollection_AsciiString aName (theArgVec[1]);
|
||||||
gp_Pln aWorkingPlane;
|
gp_Pln aWorkingPlane;
|
||||||
Standard_Real aCustomFlyout = 0.0;
|
|
||||||
Standard_Boolean isCustomPlane = Standard_False;
|
Standard_Boolean isCustomPlane = Standard_False;
|
||||||
Standard_Boolean isCustomFlyout = Standard_False;
|
|
||||||
Standard_Boolean toUpdate = Standard_True;
|
Standard_Boolean toUpdate = Standard_True;
|
||||||
|
|
||||||
|
NCollection_DataMap<TCollection_AsciiString, Standard_Real> aRealParams;
|
||||||
|
NCollection_DataMap<TCollection_AsciiString, TCollection_AsciiString> aStringParams;
|
||||||
|
|
||||||
if (!GetMapOfAIS().IsBound2 (aName))
|
if (!GetMapOfAIS().IsBound2 (aName))
|
||||||
{
|
{
|
||||||
theDi << theArgVec[0] << "error: no object with this name.\n";
|
theDi << theArgVec[0] << "error: no object with this name.\n";
|
||||||
@ -2465,19 +2536,19 @@ static int VDimParam (Draw_Interpretor& theDi, Standard_Integer theArgNum, const
|
|||||||
Handle(AIS_Dimension) aDim = Handle(AIS_Dimension)::DownCast (anObject);
|
Handle(AIS_Dimension) aDim = Handle(AIS_Dimension)::DownCast (anObject);
|
||||||
Handle(Prs3d_DimensionAspect) anAspect = aDim->DimensionAspect();
|
Handle(Prs3d_DimensionAspect) anAspect = aDim->DimensionAspect();
|
||||||
|
|
||||||
ParseDimensionParams (theArgNum, theArgVec, 2, anAspect,
|
if (ParseDimensionParams (theArgNum, theArgVec, 2, anAspect,
|
||||||
isCustomPlane, aWorkingPlane,
|
isCustomPlane, aWorkingPlane,
|
||||||
isCustomFlyout, aCustomFlyout);
|
aRealParams, aStringParams))
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (isCustomPlane)
|
if (isCustomPlane)
|
||||||
{
|
{
|
||||||
aDim->SetCustomPlane (aWorkingPlane);
|
aDim->SetCustomPlane (aWorkingPlane);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isCustomFlyout)
|
SetDimensionParams (aDim, aRealParams, aStringParams);
|
||||||
{
|
|
||||||
aDim->SetFlyout (aCustomFlyout);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!aDim->IsValid())
|
if (!aDim->IsValid())
|
||||||
{
|
{
|
||||||
@ -2678,7 +2749,12 @@ void ViewerTest::RelationCommands(Draw_Interpretor& theCommands)
|
|||||||
"[-arrowangle ArrowAngle(degrees)]\n"
|
"[-arrowangle ArrowAngle(degrees)]\n"
|
||||||
"[-plane xoy|yoz|zox]\n"
|
"[-plane xoy|yoz|zox]\n"
|
||||||
"[-flyout FloatValue -extension FloatValue]\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);
|
__FILE__,VDimBuilder,group);
|
||||||
|
|
||||||
theCommands.Add("vdimparam",
|
theCommands.Add("vdimparam",
|
||||||
@ -2689,7 +2765,12 @@ void ViewerTest::RelationCommands(Draw_Interpretor& theCommands)
|
|||||||
"[-arrowangle ArrowAngle(degrees)]\n"
|
"[-arrowangle ArrowAngle(degrees)]\n"
|
||||||
"[-plane xoy|yoz|zox]\n"
|
"[-plane xoy|yoz|zox]\n"
|
||||||
"[-flyout FloatValue -extension FloatValue]\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);
|
__FILE__,VDimParam,group);
|
||||||
|
|
||||||
theCommands.Add("vangledim",
|
theCommands.Add("vangledim",
|
||||||
|
18
tests/bugs/vis/bug25403
Normal file
18
tests/bugs/vis/bug25403
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
puts "============"
|
||||||
|
puts "CR25403"
|
||||||
|
puts "============"
|
||||||
|
puts ""
|
||||||
|
#######################################################################
|
||||||
|
# Wrong storage of model units in AIS_AngleDimension
|
||||||
|
#######################################################################
|
||||||
|
pload VISUALIZATION
|
||||||
|
|
||||||
|
vinit
|
||||||
|
vpoint angleP1 0 0 0
|
||||||
|
vpoint angleP2 50 50 50
|
||||||
|
vpoint angleP3 50 50 100
|
||||||
|
vdimension dim1 -angle -value 300 -modelunits deg -shapes angleP1 angleP2 angleP3
|
||||||
|
vdimension dim2 -length -value 10 -modelunits mm -showunits -plane yoz -shapes angleP1 angleP3
|
||||||
|
vfit
|
||||||
|
|
||||||
|
set only_screen 1
|
Loading…
x
Reference in New Issue
Block a user