1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-04 18:06:22 +03:00

0029109: Visualization, AIS_Trihedron - add option hiding arrows tips

Prs3d_DatumAspect::DrawDatumPart() now handles new flag ToDrawArrows().

vtrihedron - added new option -arrowTip.
Fixed misprint in command description -arrowscolor -> -arrowcolor.
This commit is contained in:
Zia ul Azam 2017-09-13 17:12:57 +02:00 committed by bugmaster
parent f998596a10
commit fae1ae1182
6 changed files with 96 additions and 31 deletions

View File

@ -103,6 +103,8 @@ void AIS_Trihedron::setOwnDatumAspect()
if (myDrawer->Link().IsNull())
return;
myDrawer->DatumAspect()->SetDrawArrows (myDrawer->Link()->DatumAspect()->ToDrawArrows());
myDrawer->DatumAspect()->SetDrawLabels (myDrawer->Link()->DatumAspect()->ToDrawLabels());
*myDrawer->DatumAspect()->TextAspect()->Aspect() =
*myDrawer->Link()->DatumAspect()->TextAspect()->Aspect();
*myDrawer->DatumAspect()->PointAspect()->Aspect() =
@ -493,14 +495,14 @@ void AIS_Trihedron::computePresentation (const Handle(PrsMgr_PresentationManager
anAxisGroup->AddPrimitiveArray (arrayOfPrimitives (aPart));
// draw arrow
Handle(Graphic3d_Group) anArrowGroup = Prs3d_Root::NewGroup (thePrs);
anArrowGroup->SetPrimitivesAspect (anAspect->ArrowAspect()->Aspect());
Prs3d_DatumParts anArrowPart = anAspect->ArrowPartForAxis (aPart);
if (!anAspect->DrawDatumPart (anArrowPart))
{
continue;
}
Handle(Graphic3d_Group) anArrowGroup = Prs3d_Root::NewGroup (thePrs);
anArrowGroup->SetGroupPrimitivesAspect (anAspect->ArrowAspect()->Aspect());
anArrowGroup->AddPrimitiveArray (arrayOfPrimitives (anArrowPart));
}
}
@ -714,6 +716,25 @@ void AIS_Trihedron::UnsetColor()
}
}
//=======================================================================
//function : ToDrawArrows
//purpose :
//=======================================================================
Standard_Boolean AIS_Trihedron::ToDrawArrows() const
{
return myDrawer->DatumAspect()->ToDrawArrows();
}
//=======================================================================
//function : SetDrawArrows
//purpose :
//=======================================================================
void AIS_Trihedron::SetDrawArrows (const Standard_Boolean theToDraw)
{
setOwnDatumAspect();
myDrawer->DatumAspect()->SetDrawArrows (theToDraw);
}
//=======================================================================
//function : createSensitiveEntity
//purpose :

View File

@ -152,6 +152,12 @@ public:
//! Standard_DEPRECATED("This method is deprecated - SetColor() should be called instead")
Standard_EXPORT void SetAxisColor (const Quantity_Color& theColor);
//! Returns true if arrows are to be drawn
Standard_EXPORT Standard_Boolean ToDrawArrows() const;
//! Sets whether to draw the arrows in visualization
Standard_EXPORT void SetDrawArrows (const Standard_Boolean theToDraw);
//! Sets priority of selection for owner of the given type
void SetSelectionPriority (Prs3d_DatumParts thePart,
Standard_Integer thePriority)

View File

@ -22,9 +22,10 @@ IMPLEMENT_STANDARD_RTTIEXT(Prs3d_DatumAspect, Prs3d_BasicAspect)
// =======================================================================
Prs3d_DatumAspect::Prs3d_DatumAspect()
: myAxes (Prs3d_DA_XYZAxis),
myToDrawLabels (Standard_True)
myToDrawLabels (Standard_True),
myToDrawArrows (Standard_True)
{
Standard_Real aDefaultLength = 100.0; // default axis lenght, the same as in context
Standard_Real aDefaultLength = 100.0; // default axis length, the same as in context
Quantity_Color aDefaultColor(Quantity_NOC_LIGHTSTEELBLUE4); // default axis color
myAttributes.Bind (Prs3d_DA_XAxisLength, aDefaultLength);
@ -118,12 +119,12 @@ bool Prs3d_DatumAspect::DrawDatumPart (Prs3d_DatumParts thePart) const
switch (thePart)
{
case Prs3d_DP_Origin: return true;
case Prs3d_DP_XAxis:
case Prs3d_DP_XArrow: return (myAxes & Prs3d_DA_XAxis) != 0;
case Prs3d_DP_YAxis:
case Prs3d_DP_YArrow: return (myAxes & Prs3d_DA_YAxis) != 0;
case Prs3d_DP_ZAxis:
case Prs3d_DP_ZArrow: return (myAxes & Prs3d_DA_ZAxis) != 0;
case Prs3d_DP_XAxis: return (myAxes & Prs3d_DA_XAxis) != 0;
case Prs3d_DP_XArrow: return (myAxes & Prs3d_DA_XAxis) != 0 && myToDrawArrows;
case Prs3d_DP_YAxis: return (myAxes & Prs3d_DA_YAxis) != 0;
case Prs3d_DP_YArrow: return (myAxes & Prs3d_DA_YAxis) != 0 && myToDrawArrows;
case Prs3d_DP_ZAxis: return (myAxes & Prs3d_DA_ZAxis) != 0;
case Prs3d_DP_ZArrow: return (myAxes & Prs3d_DA_ZAxis) != 0 && myToDrawArrows;
case Prs3d_DP_XOYAxis: return DrawDatumPart (Prs3d_DP_XAxis)
&& DrawDatumPart (Prs3d_DP_YAxis);
case Prs3d_DP_YOZAxis: return DrawDatumPart (Prs3d_DP_YAxis)

View File

@ -128,11 +128,18 @@ public:
Standard_DEPRECATED("This method is deprecated - AxisLength() should be called instead")
Standard_Real ThirdAxisLength() const { return myAttributes.Find (Prs3d_DA_ZAxisLength); }
//! @return true if axes labels are drawn; TRUE by default.
Standard_Boolean ToDrawLabels() const { return myToDrawLabels; }
//! Sets option to draw or not to draw text labels for axes
void SetDrawLabels (Standard_Boolean theToDraw) { myToDrawLabels = theToDraw; }
void SetToDrawLabels (Standard_Boolean theToDraw) { myToDrawLabels = theToDraw; }
//! @return true if axes labels are drawn
Standard_Boolean ToDrawLabels() const { return myToDrawLabels; }
//! @return true if axes arrows are drawn; TRUE by default.
Standard_Boolean ToDrawArrows() const { return myToDrawArrows; }
//! Sets option to draw or not arrows for axes
void SetDrawArrows (Standard_Boolean theToDraw) { myToDrawArrows = theToDraw; }
//! Returns type of arrow for a type of axis
Standard_EXPORT Prs3d_DatumParts ArrowPartForAxis (Prs3d_DatumParts thePart) const;
@ -140,6 +147,7 @@ public:
private:
Prs3d_DatumAxes myAxes;
Standard_Boolean myToDrawLabels;
Standard_Boolean myToDrawArrows;
NCollection_DataMap<Prs3d_DatumAttribute, Standard_Real> myAttributes;
NCollection_DataMap<Prs3d_DatumParts, Handle(Prs3d_ShadingAspect)> myShadedAspects;

View File

@ -349,17 +349,42 @@ namespace
if (aMapOfArgs.Find ("hidelabels", aValues))
{
if (aValues->Size() == 0)
Standard_Boolean toHideLabels = Standard_True;
if (aValues->Size() == 1)
{
ViewerTest::ParseOnOff (aValues->First().ToCString(), toHideLabels);
}
else if (aValues->Size() != 0)
{
std::cout << "Syntax error: -hidelabels expects parameter 'on' or 'off' after.\n";
return Standard_False;
}
Standard_Boolean toHideLabels = Standard_True;
ViewerTest::ParseOnOff (aValues->Value (1).ToCString(), toHideLabels);
if (!theTrihedron->Attributes()->HasOwnDatumAspect())
theTrihedron->Attributes()->SetDatumAspect(new Prs3d_DatumAspect());
theTrihedron->Attributes()->DatumAspect()->SetToDrawLabels (!toHideLabels);
{
theTrihedron->Attributes()->SetDatumAspect (new Prs3d_DatumAspect());
}
theTrihedron->Attributes()->DatumAspect()->SetDrawLabels (!toHideLabels);
}
if (aMapOfArgs.Find ("hidearrows", aValues))
{
Standard_Boolean toHideArrows = Standard_True;
if (aValues->Size() == 1)
{
ViewerTest::ParseOnOff (aValues->First().ToCString(), toHideArrows);
}
else if (aValues->Size() != 0)
{
std::cout << "Syntax error: -hidearrows expects parameter 'on' or 'off' after.\n";
return Standard_False;
}
if (!theTrihedron->Attributes()->HasOwnDatumAspect())
{
theTrihedron->Attributes()->SetDatumAspect (new Prs3d_DatumAspect());
}
theTrihedron->Attributes()->DatumAspect()->SetDrawArrows (!toHideArrows);
}
if (aMapOfArgs.Find ("color", aValues))
@ -6460,8 +6485,9 @@ void ViewerTest::ObjectCommands(Draw_Interpretor& theCommands)
"\n\t\t: [-dispMode {wireframe|shading} ]"
"\n\t\t: [-origin x y z ]"
"\n\t\t: [-zaxis u v w -xaxis u v w ]"
"\n\t\t: [-drawaxes {X|Y|Z|XY|YZ|XZ|XYZ}]"
"\n\t\t: [-hidelabels {on|off}]"
"\n\t\t: [-drawAxes {X|Y|Z|XY|YZ|XZ|XYZ}]"
"\n\t\t: [-hideLabels {on|off}]"
"\n\t\t: [-hideArrows {on|off}]"
"\n\t\t: [-label {XAxis|YAxis|ZAxis} value]"
"\n\t\t: [-attribute {XAxisLength|YAxisLength|ZAxisLength"
"\n\t\t: |TubeRadiusPercent|ConeRadiusPercent"
@ -6469,8 +6495,8 @@ void ViewerTest::ObjectCommands(Draw_Interpretor& theCommands)
"\n\t\t: |ShadingNumberOfFacettes} value]"
"\n\t\t: [-color {Origin|XAxis|YAxis|ZAxis|XOYAxis|YOZAxis"
"\n\t\t: |XOZAxis|Whole} {r g b | colorName}]"
"\n\t\t: [-textcolor {r g b | colorName}]"
"\n\t\t: [-arrowscolor {r g b | colorName}]"
"\n\t\t: [-textColor {r g b | colorName}]"
"\n\t\t: [-arrowColor {r g b | colorName}]"
"\n\t\t: [-priority {Origin|XAxis|YAxis|ZAxis|XArrow"
"\n\t\t: |YArrow|ZArrow|XOYAxis|YOZAxis"
"\n\t\t: |XOZAxis|Whole} value]"
@ -6485,14 +6511,15 @@ void ViewerTest::ObjectCommands(Draw_Interpretor& theCommands)
"\n\t\t: -zaxis/-xaxis allows to set trihedron X and Z"
"\n\t\t: directions. The directions should"
"\n\t\t: be orthogonal. Y direction is calculated."
"\n\t\t: -drawaxes allows to set what axes are drawn in the"
"\n\t\t: -drawAxes allows to set what axes are drawn in the"
"\n\t\t: trihedron, default state is XYZ"
"\n\t\t: -hidelabels allows to hide or show trihedron labels"
"\n\t\t: -hideLabels allows to show/hide trihedron labels"
"\n\t\t: -hideArrows allows to show/hide trihedron arrows"
"\n\t\t: -labels allows to change default X/Y/Z titles of axes"
"\n\t\t: -attribute sets parameters of trihedron"
"\n\t\t: -color sets color properties of parts of trihedron"
"\n\t\t: -textcolor sets color properties of trihedron labels"
"\n\t\t: -arrowscolor sets color properties of trihedron arrows"
"\n\t\t: -textColor sets color properties of trihedron labels"
"\n\t\t: -arrowColor sets color properties of trihedron arrows"
"\n\t\t: -priority allows to change default selection priority"
"\n\t\t: of trihedron components",
__FILE__,VTrihedron,group);

View File

@ -16,7 +16,7 @@ vselmode t1 1 1
vselmode t1 2 1
vselmode t1 3 1
vtrihedron t1 -dispmode shading
vtrihedron t1 -dispMode shading
vtrihedron t1 -origin -200 -200 -300
vtrihedron t1 -attribute XAxisLength|YAxisLength|ZAxisLength 80
vtrihedron t1 -xaxis 40 60 120 -zaxis -120 0 40
@ -27,8 +27,8 @@ vtrihedron t1 -color XAxis Quantity_NOC_RED
vtrihedron t1 -color YAxis Quantity_NOC_GREEN
vtrihedron t1 -color ZAxis|Origin Quantity_NOC_BLUE1
vtrihedron t1 -textcolor 1.0 1.0 1.0
vtrihedron t1 -arrowcolor 0.0 0.0 1.0
vtrihedron t1 -textColor 1.0 1.0 1.0
vtrihedron t1 -arrowColor 0.0 0.0 1.0
vtrihedron t2 -origin 0 0 -300
vtrihedron t2 -color Whole Quantity_NOC_PEACHPUFF
@ -36,8 +36,10 @@ vselmode t2 1 1
vselmode t2 2 1
vselmode t2 3 1
vtrihedron t3 -dispmode shading -origin 200 200 -300 -color Whole 1.0 0.0 0.0
vtrihedron t3 -drawaxes XY -hidelabels on
vtrihedron t3 -dispMode shading -origin 200 200 -300 -color Whole 1.0 0.0 0.0
vtrihedron t3 -drawAxes XY -hideLabels on
vtrihedron t4 -origin -200 -200 300 -hideArrows
vfit