mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-04 18:06:22 +03:00
0030535: Draw Harness - add size argument to vgrid command
vgrid command has been revised and extended with new argument -size.
This commit is contained in:
parent
f522ce50b2
commit
799318357c
@ -5238,102 +5238,257 @@ static int VGrid (Draw_Interpretor& /*theDI*/,
|
||||
Standard_Integer theArgNb,
|
||||
const char** theArgVec)
|
||||
{
|
||||
// get the active view
|
||||
Handle(V3d_View) aView = ViewerTest::CurrentView();
|
||||
Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext();
|
||||
if (aView.IsNull() || aViewer.IsNull())
|
||||
{
|
||||
std::cerr << "No active view. Please call vinit.\n";
|
||||
std::cerr << "Error: no active view\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Aspect_GridType aType = aViewer->GridType();
|
||||
Aspect_GridDrawMode aMode = aViewer->GridDrawMode();
|
||||
Graphic3d_Vec2d aNewOriginXY, aNewStepXY, aNewSizeXY;
|
||||
Standard_Real aNewRotAngle = 0.0, aNewZOffset = 0.0;
|
||||
bool hasOrigin = false, hasStep = false, hasRotAngle = false, hasSize = false, hasZOffset = false;
|
||||
ViewerTest_AutoUpdater anUpdateTool (ViewerTest::GetAISContext(), aView);
|
||||
Standard_Integer anIter = 1;
|
||||
for (; anIter < theArgNb; ++anIter)
|
||||
for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
|
||||
{
|
||||
const char* aValue = theArgVec[anIter];
|
||||
if (anUpdateTool.parseRedrawMode (aValue))
|
||||
TCollection_AsciiString anArg (theArgVec[anArgIter]);
|
||||
anArg.LowerCase();
|
||||
if (anUpdateTool.parseRedrawMode (theArgVec[anArgIter]))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (*aValue == 'r')
|
||||
else if (anArgIter + 1 < theArgNb
|
||||
&& anArg == "-type")
|
||||
{
|
||||
TCollection_AsciiString anArgNext (theArgVec[++anArgIter]);
|
||||
anArgNext.LowerCase();
|
||||
if (anArgNext == "r"
|
||||
|| anArgNext == "rect"
|
||||
|| anArgNext == "rectangular")
|
||||
{
|
||||
aType = Aspect_GT_Rectangular;
|
||||
}
|
||||
else if (anArgNext == "c"
|
||||
|| anArgNext == "circ"
|
||||
|| anArgNext == "circular")
|
||||
{
|
||||
aType = Aspect_GT_Circular;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Syntax error at '" << anArgNext << "'\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if (anArgIter + 1 < theArgNb
|
||||
&& anArg == "-mode")
|
||||
{
|
||||
TCollection_AsciiString anArgNext (theArgVec[++anArgIter]);
|
||||
anArgNext.LowerCase();
|
||||
if (anArgNext == "l"
|
||||
|| anArgNext == "line"
|
||||
|| anArgNext == "lines")
|
||||
{
|
||||
aMode = Aspect_GDM_Lines;
|
||||
}
|
||||
else if (anArgNext == "p"
|
||||
|| anArgNext == "point"
|
||||
|| anArgNext == "points")
|
||||
{
|
||||
aMode = Aspect_GDM_Points;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Syntax error at '" << anArgNext << "'\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if (anArgIter + 2 < theArgNb
|
||||
&& (anArg == "-origin"
|
||||
|| anArg == "-orig"))
|
||||
{
|
||||
hasOrigin = true;
|
||||
aNewOriginXY.SetValues (Draw::Atof (theArgVec[anArgIter + 1]),
|
||||
Draw::Atof (theArgVec[anArgIter + 2]));
|
||||
anArgIter += 2;
|
||||
}
|
||||
else if (anArgIter + 2 < theArgNb
|
||||
&& anArg == "-step")
|
||||
{
|
||||
hasStep = true;
|
||||
aNewStepXY.SetValues (Draw::Atof (theArgVec[anArgIter + 1]),
|
||||
Draw::Atof (theArgVec[anArgIter + 2]));
|
||||
if (aNewStepXY.x() <= 0.0
|
||||
|| aNewStepXY.y() <= 0.0)
|
||||
{
|
||||
std::cout << "Syntax error: wrong step '" << theArgVec[anArgIter + 1] << " " << theArgVec[anArgIter + 2] << "'\n";
|
||||
return 1;
|
||||
}
|
||||
anArgIter += 2;
|
||||
}
|
||||
else if (anArgIter + 1 < theArgNb
|
||||
&& (anArg == "-angle"
|
||||
|| anArg == "-rotangle"
|
||||
|| anArg == "-rotationangle"))
|
||||
{
|
||||
hasRotAngle = true;
|
||||
aNewRotAngle = Draw::Atof (theArgVec[++anArgIter]);
|
||||
}
|
||||
else if (anArgIter + 1 < theArgNb
|
||||
&& (anArg == "-zoffset"
|
||||
|| anArg == "-dz"))
|
||||
{
|
||||
hasZOffset = true;
|
||||
aNewZOffset = Draw::Atof (theArgVec[++anArgIter]);
|
||||
}
|
||||
else if (anArgIter + 1 < theArgNb
|
||||
&& anArg == "-radius")
|
||||
{
|
||||
hasSize = true;
|
||||
++anArgIter;
|
||||
aNewSizeXY.SetValues (Draw::Atof (theArgVec[anArgIter]), 0.0);
|
||||
if (aNewStepXY.x() <= 0.0)
|
||||
{
|
||||
std::cout << "Syntax error: wrong size '" << theArgVec[anArgIter] << "'\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if (anArgIter + 2 < theArgNb
|
||||
&& anArg == "-size")
|
||||
{
|
||||
hasSize = true;
|
||||
aNewSizeXY.SetValues (Draw::Atof (theArgVec[anArgIter + 1]),
|
||||
Draw::Atof (theArgVec[anArgIter + 2]));
|
||||
if (aNewStepXY.x() <= 0.0
|
||||
|| aNewStepXY.y() <= 0.0)
|
||||
{
|
||||
std::cout << "Syntax error: wrong size '" << theArgVec[anArgIter + 1] << " " << theArgVec[anArgIter + 2] << "'\n";
|
||||
return 1;
|
||||
}
|
||||
anArgIter += 2;
|
||||
}
|
||||
else if (anArg == "r"
|
||||
|| anArg == "rect"
|
||||
|| anArg == "rectangular")
|
||||
{
|
||||
aType = Aspect_GT_Rectangular;
|
||||
}
|
||||
else if (*aValue == 'c')
|
||||
else if (anArg == "c"
|
||||
|| anArg == "circ"
|
||||
|| anArg == "circular")
|
||||
{
|
||||
aType = Aspect_GT_Circular;
|
||||
}
|
||||
else if (*aValue == 'l')
|
||||
else if (anArg == "l"
|
||||
|| anArg == "line"
|
||||
|| anArg == "lines")
|
||||
{
|
||||
aMode = Aspect_GDM_Lines;
|
||||
}
|
||||
else if (*aValue == 'p')
|
||||
else if (anArg == "p"
|
||||
|| anArg == "point"
|
||||
|| anArg == "points")
|
||||
{
|
||||
aMode = Aspect_GDM_Points;
|
||||
}
|
||||
else if (strcmp (aValue, "off" ) == 0)
|
||||
else if (anArgIter + 1 >= theArgNb
|
||||
&& anArg == "off")
|
||||
{
|
||||
aViewer->DeactivateGrid();
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
std::cout << "Syntax error at '" << anArg << "'\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
Standard_Integer aTail = (theArgNb - anIter);
|
||||
if (aTail == 0)
|
||||
{
|
||||
aViewer->ActivateGrid (aType, aMode);
|
||||
return 0;
|
||||
}
|
||||
else if (aTail != 2 && aTail != 5)
|
||||
{
|
||||
std::cerr << "Incorrect arguments number! Usage:\n"
|
||||
<< "vgrid [off] [Mode={r|c}] [Type={l|p}] [OriginX OriginY [StepX/StepRadius StepY/DivNb RotAngle]]\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Standard_Real anOriginX, anOriginY, aRotAngle;
|
||||
if (aType == Aspect_GT_Rectangular)
|
||||
{
|
||||
Standard_Real aRStepX, aRStepY;
|
||||
aViewer->RectangularGridValues (anOriginX, anOriginY, aRStepX, aRStepY, aRotAngle);
|
||||
|
||||
anOriginX = Draw::Atof (theArgVec[anIter++]);
|
||||
anOriginY = Draw::Atof (theArgVec[anIter++]);
|
||||
if (aTail == 5)
|
||||
Graphic3d_Vec2d anOrigXY, aStepXY;
|
||||
Standard_Real aRotAngle = 0.0;
|
||||
aViewer->RectangularGridValues (anOrigXY.x(), anOrigXY.y(), aStepXY.x(), aStepXY.y(), aRotAngle);
|
||||
if (hasOrigin)
|
||||
{
|
||||
aRStepX = Draw::Atof (theArgVec[anIter++]);
|
||||
aRStepY = Draw::Atof (theArgVec[anIter++]);
|
||||
aRotAngle = Draw::Atof (theArgVec[anIter++]);
|
||||
anOrigXY = aNewOriginXY;
|
||||
}
|
||||
if (hasStep)
|
||||
{
|
||||
aStepXY = aNewStepXY;
|
||||
}
|
||||
if (hasRotAngle)
|
||||
{
|
||||
aRotAngle = aNewRotAngle;
|
||||
}
|
||||
aViewer->SetRectangularGridValues (anOrigXY.x(), anOrigXY.y(), aStepXY.x(), aStepXY.y(), aRotAngle);
|
||||
if (hasSize || hasZOffset)
|
||||
{
|
||||
Graphic3d_Vec3d aSize;
|
||||
aViewer->RectangularGridGraphicValues (aSize.x(), aSize.y(), aSize.z());
|
||||
if (hasSize)
|
||||
{
|
||||
aSize.x() = aNewSizeXY.x();
|
||||
aSize.y() = aNewSizeXY.y();
|
||||
}
|
||||
if (hasZOffset)
|
||||
{
|
||||
aSize.z() = aNewZOffset;
|
||||
}
|
||||
aViewer->SetRectangularGridGraphicValues (aSize.x(), aSize.y(), aSize.z());
|
||||
}
|
||||
aViewer->SetRectangularGridValues (anOriginX, anOriginY, aRStepX, aRStepY, aRotAngle);
|
||||
aViewer->ActivateGrid (aType, aMode);
|
||||
}
|
||||
else if (aType == Aspect_GT_Circular)
|
||||
{
|
||||
Graphic3d_Vec2d anOrigXY;
|
||||
Standard_Real aRadiusStep;
|
||||
Standard_Integer aDivisionNumber;
|
||||
aViewer->CircularGridValues (anOriginX, anOriginY, aRadiusStep, aDivisionNumber, aRotAngle);
|
||||
|
||||
anOriginX = Draw::Atof (theArgVec[anIter++]);
|
||||
anOriginY = Draw::Atof (theArgVec[anIter++]);
|
||||
if (aTail == 5)
|
||||
Standard_Real aRotAngle = 0.0;
|
||||
aViewer->CircularGridValues (anOrigXY.x(), anOrigXY.y(), aRadiusStep, aDivisionNumber, aRotAngle);
|
||||
if (hasOrigin)
|
||||
{
|
||||
aRadiusStep = Draw::Atof (theArgVec[anIter++]);
|
||||
aDivisionNumber = Draw::Atoi (theArgVec[anIter++]);
|
||||
aRotAngle = Draw::Atof (theArgVec[anIter++]);
|
||||
anOrigXY = aNewOriginXY;
|
||||
}
|
||||
if (hasStep)
|
||||
{
|
||||
aRadiusStep = aNewStepXY[0];
|
||||
aDivisionNumber = (int )aNewStepXY[1];
|
||||
if (aDivisionNumber < 1)
|
||||
{
|
||||
std::cout << "Syntax error: invalid division number '" << aNewStepXY[1] << "'\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if (hasRotAngle)
|
||||
{
|
||||
aRotAngle = aNewRotAngle;
|
||||
}
|
||||
|
||||
aViewer->SetCircularGridValues (anOriginX, anOriginY, aRadiusStep, aDivisionNumber, aRotAngle);
|
||||
aViewer->ActivateGrid (aType, aMode);
|
||||
aViewer->SetCircularGridValues (anOrigXY.x(), anOrigXY.y(), aRadiusStep, aDivisionNumber, aRotAngle);
|
||||
if (hasSize || hasZOffset)
|
||||
{
|
||||
Standard_Real aRadius = 0.0, aZOffset = 0.0;
|
||||
aViewer->CircularGridGraphicValues (aRadius, aZOffset);
|
||||
if (hasSize)
|
||||
{
|
||||
aRadius = aNewSizeXY.x();
|
||||
if (aNewSizeXY.y() != 0.0)
|
||||
{
|
||||
std::cout << "Syntax error: circular size should be specified as radius\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if (hasZOffset)
|
||||
{
|
||||
aZOffset = aNewZOffset;
|
||||
}
|
||||
aViewer->SetCircularGridGraphicValues (aRadius, aZOffset);
|
||||
}
|
||||
}
|
||||
|
||||
aViewer->ActivateGrid (aType, aMode);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -12572,10 +12727,10 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
|
||||
theCommands.Add("vlayerline",
|
||||
"vlayerline : vlayerline x1 y1 x2 y2 [linewidth=0.5] [linetype=0] [transparency=1.0]",
|
||||
__FILE__,VLayerLine,group);
|
||||
theCommands.Add ("vgrid",
|
||||
"vgrid [off] [Mode={r|c}] [Type={l|p}] [OriginX OriginY [StepX/StepRadius StepY/DivNb RotAngle]]"
|
||||
" : Mode - rectangular or circular"
|
||||
" : Type - lines or points",
|
||||
theCommands.Add("vgrid",
|
||||
"vgrid [off] [-type {rect|circ}] [-mode {line|point}] [-origin X Y] [-rotAngle Angle] [-zoffset DZ]"
|
||||
"\n\t\t: [-step X Y] [-size DX DY]"
|
||||
"\n\t\t: [-step StepRadius NbDivisions] [-radius Radius]",
|
||||
__FILE__, VGrid, group);
|
||||
theCommands.Add ("vpriviledgedplane",
|
||||
"vpriviledgedplane [Ox Oy Oz Nx Ny Nz [Xx Xy Xz]]"
|
||||
|
@ -16,7 +16,7 @@ set cylinder_r 5
|
||||
set cylinder_h 10
|
||||
set cylinder_xyz {100 0 0}
|
||||
|
||||
vgrid c p -10 0 5 5 45
|
||||
vgrid -type circular -mode points -origin -10 0 -step 5 5 -rotAngle 45
|
||||
pcylinder c $cylinder_r $cylinder_h
|
||||
ttranslate c {*}$cylinder_xyz
|
||||
vdisplay c
|
||||
@ -67,7 +67,7 @@ checkreal "vconvert 0.5 100 0.5 window, view 1, Xp" [lindex $vconvert_05_100_05_
|
||||
checkreal "vconvert 0.5 100 0.5 window, view 1, Yp" [lindex $vconvert_05_100_05_win 3] 199.0 1.0 0.0
|
||||
|
||||
# 2.2 Quick test of coordinate conversion commands
|
||||
vgrid r 10 10 1 1 45
|
||||
vgrid -type rectangular -origin 10 10 -step 1 1 -rotAngle 45
|
||||
|
||||
set view_scale 49.504950495049506
|
||||
set view_proj {0 0 1}
|
||||
|
@ -17,7 +17,7 @@ set view_zmin -300.0
|
||||
set view_zmax 300.0
|
||||
vviewparams -scale $view_scale -eye {*}$view_eye -at {*}$view_at -proj {*}$view_proj -up {*}$view_up
|
||||
vzrange $view_zmin $view_zmax
|
||||
vgrid r l -10 10 1 1 0
|
||||
vgrid -type rectangular -mode lines -origin -10 10 -step 1 1
|
||||
|
||||
set vconvert_res [vconvert 5.0 5.0 0.0 grid]
|
||||
|
||||
|
@ -13,7 +13,7 @@ vinit
|
||||
box b 1 1 1
|
||||
vdisplay b
|
||||
vfit
|
||||
vgrid r l 0 0 1 1 0
|
||||
vgrid -type rectangular -mode lines -origin 0 0 -step 1 1
|
||||
vtop
|
||||
|
||||
set bug_info [string trim [vreadpixel 86 355 name]]
|
||||
|
@ -7,7 +7,7 @@ puts ""
|
||||
#######################################################################
|
||||
|
||||
vinit View1 w=400 h=400
|
||||
vgrid r l 0 0 5 5 0
|
||||
vgrid -type rectangular -mode lines -origin 0 0 -step 5 5
|
||||
|
||||
# 1. Check convert to grid for axonometric projection. Grid is at origin.
|
||||
vaxo
|
||||
|
@ -9,7 +9,7 @@ pload VISUALIZATION
|
||||
vclear
|
||||
vinit View1
|
||||
vraytrace 0
|
||||
vgrid r
|
||||
vgrid -type rectangular
|
||||
vraytrace 1
|
||||
checkcolor 198 197 0.5 0.5 0.5
|
||||
vclose
|
||||
@ -18,6 +18,6 @@ vclose
|
||||
vclear
|
||||
vinit View1
|
||||
vraytrace 0
|
||||
vgrid c
|
||||
vgrid -type circular
|
||||
vraytrace 1
|
||||
checkcolor 198 197 0.5 0.5 0.5
|
||||
|
Loading…
x
Reference in New Issue
Block a user