mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-04 18:06:22 +03:00
0006897: Impossible to change edge line type in 3D View
Added command vsetedgetype; added test case bugs/vis/bug6897 to test edge type management. vunsetedgetype DRAW command was added and test case was updated. added -force option to set edge type commands to force redisplay. Otherwise primitive aspects are updated without object redisplaying.
This commit is contained in:
parent
0e93d9e5b8
commit
5ad539d2e0
@ -5019,6 +5019,191 @@ static int VFont (Draw_Interpretor& theDI,
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : VSetEdgeType
|
||||
//purpose : Edges type management
|
||||
//=======================================================================
|
||||
|
||||
static int VSetEdgeType (Draw_Interpretor& theDI,
|
||||
Standard_Integer theArgNum,
|
||||
const char** theArgs)
|
||||
{
|
||||
if (theArgNum < 4 || theArgNum > 9)
|
||||
{
|
||||
theDI << theArgs[0] << " error: wrong number of parameters. Type 'help "
|
||||
<< theArgs[0] << "' for more information.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Standard_Boolean isForceRedisplay = Standard_False;
|
||||
|
||||
// Get shape name
|
||||
TCollection_AsciiString aName(theArgs[1]);
|
||||
if (!GetMapOfAIS().IsBound2 (aName))
|
||||
{
|
||||
theDI << theArgs[0] << " error: wrong object name.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Handle(AIS_InteractiveObject) anObject =
|
||||
Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(aName));
|
||||
|
||||
// Enable trianle edge mode
|
||||
anObject->Attributes()->ShadingAspect()->Aspect()->SetEdgeOn();
|
||||
|
||||
// Parse parameters
|
||||
for (Standard_Integer anIt = 2; anIt < theArgNum; ++anIt)
|
||||
{
|
||||
TCollection_AsciiString aParam ((theArgs[anIt]));
|
||||
if (aParam.Value (1) == '-' && !aParam.IsRealValue())
|
||||
{
|
||||
if (aParam.IsEqual ("-type"))
|
||||
{
|
||||
if (theArgNum <= anIt + 1)
|
||||
{
|
||||
theDI << theArgs[0] << " error: wrong number of values for parameter '"
|
||||
<< aParam.ToCString() << "'.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
TCollection_AsciiString aType = theArgs[++anIt];
|
||||
aType.UpperCase();
|
||||
|
||||
if (aType.IsEqual ("SOLID"))
|
||||
{
|
||||
anObject->Attributes()->ShadingAspect()->Aspect()->SetEdgeLineType(Aspect_TOL_SOLID);
|
||||
}
|
||||
else if (aType.IsEqual ("DASH"))
|
||||
{
|
||||
anObject->Attributes()->ShadingAspect()->Aspect()->SetEdgeLineType(Aspect_TOL_DASH);
|
||||
}
|
||||
else if (aType.IsEqual ("DOT"))
|
||||
{
|
||||
anObject->Attributes()->ShadingAspect()->Aspect()->SetEdgeLineType(Aspect_TOL_DOT);
|
||||
}
|
||||
else if (aType.IsEqual ("DOTDASH"))
|
||||
{
|
||||
anObject->Attributes()->ShadingAspect()->Aspect()->SetEdgeLineType(Aspect_TOL_DOTDASH);
|
||||
}
|
||||
else
|
||||
{
|
||||
theDI << theArgs[0] << " error: wrong line type: '" << aType.ToCString() << "'.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
else if (aParam.IsEqual ("-color"))
|
||||
{
|
||||
if (theArgNum <= anIt + 3)
|
||||
{
|
||||
theDI << theArgs[0] << " error: wrong number of values for parameter '"
|
||||
<< aParam.ToCString() << "'.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Quantity_Parameter aR = Draw::Atof(theArgs[++anIt]);
|
||||
Quantity_Parameter aG = Draw::Atof(theArgs[++anIt]);
|
||||
Quantity_Parameter aB = Draw::Atof(theArgs[++anIt]);
|
||||
Quantity_Color aColor = Quantity_Color (aR > 1 ? aR / 255.0 : aR,
|
||||
aG > 1 ? aG / 255.0 : aG,
|
||||
aB > 1 ? aB / 255.0 : aB,
|
||||
Quantity_TOC_RGB);
|
||||
|
||||
anObject->Attributes()->ShadingAspect()->Aspect()->SetEdgeColor (aColor);
|
||||
}
|
||||
else if (aParam.IsEqual ("-force"))
|
||||
{
|
||||
isForceRedisplay = Standard_True;
|
||||
}
|
||||
else
|
||||
{
|
||||
theDI << theArgs[0] << " error: unknown parameter '"
|
||||
<< aParam.ToCString() << "'.\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update shape presentation as aspect parameters were changed
|
||||
if (isForceRedisplay)
|
||||
{
|
||||
ViewerTest::GetAISContext()->Redisplay (anObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
anObject->SetAspect (anObject->Attributes()->ShadingAspect());
|
||||
}
|
||||
|
||||
//Update view
|
||||
ViewerTest::CurrentView()->Redraw();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : VUnsetEdgeType
|
||||
//purpose : Unsets edges visibility in shading mode
|
||||
//=======================================================================
|
||||
|
||||
static int VUnsetEdgeType (Draw_Interpretor& theDI,
|
||||
Standard_Integer theArgNum,
|
||||
const char** theArgs)
|
||||
{
|
||||
if (theArgNum != 2 && theArgNum != 3)
|
||||
{
|
||||
theDI << theArgs[0] << " error: wrong number of parameters. Type 'help "
|
||||
<< theArgs[0] << "' for more information.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Standard_Boolean isForceRedisplay = Standard_False;
|
||||
|
||||
// Get shape name
|
||||
TCollection_AsciiString aName (theArgs[1]);
|
||||
if (!GetMapOfAIS().IsBound2 (aName))
|
||||
{
|
||||
theDI << theArgs[0] << " error: wrong object name.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Handle(AIS_InteractiveObject) anObject =
|
||||
Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2(aName));
|
||||
|
||||
// Enable trianle edge mode
|
||||
anObject->Attributes()->ShadingAspect()->Aspect()->SetEdgeOff();
|
||||
|
||||
// Parse parameters
|
||||
if (theArgNum == 3)
|
||||
{
|
||||
TCollection_AsciiString aParam ((theArgs[2]));
|
||||
if (aParam.IsEqual ("-force"))
|
||||
{
|
||||
isForceRedisplay = Standard_True;
|
||||
}
|
||||
else
|
||||
{
|
||||
theDI << theArgs[0] << " error: unknown parameter '"
|
||||
<< aParam.ToCString() << "'.\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Update shape presentation as aspect parameters were changed
|
||||
if (isForceRedisplay)
|
||||
{
|
||||
ViewerTest::GetAISContext()->Redisplay (anObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
anObject->SetAspect (anObject->Attributes()->ShadingAspect());
|
||||
}
|
||||
|
||||
//Update view
|
||||
ViewerTest::CurrentView()->Redraw();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ObjectsCommands
|
||||
//purpose :
|
||||
@ -5176,4 +5361,16 @@ void ViewerTest::ObjectCommands(Draw_Interpretor& theCommands)
|
||||
"vfont [add pathToFont [fontName] [regular,bold,italic,bolditalic=undefined]]"
|
||||
"\n\t\t: [find fontName [regular,bold,italic,bolditalic=undefined]]",
|
||||
__FILE__, VFont, group);
|
||||
|
||||
theCommands.Add ("vsetedgetype",
|
||||
"vsetedgetype usage:\n"
|
||||
"vsetedgetype ShapeName [-force] [-type {solid, dash, dot}] [-color R G B] "
|
||||
"\n\t\t: Sets edges type and color for input shape",
|
||||
__FILE__, VSetEdgeType, group);
|
||||
|
||||
theCommands.Add ("vunsetedgetype",
|
||||
"vunsetedgetype usage:\n"
|
||||
"vunsetedgetype ShapeName [-force]"
|
||||
"\n\t\t: Unsets edges type and color for input shape",
|
||||
__FILE__, VUnsetEdgeType, group);
|
||||
}
|
||||
|
30
tests/bugs/vis/bug6897_1
Normal file
30
tests/bugs/vis/bug6897_1
Normal file
@ -0,0 +1,30 @@
|
||||
puts "============"
|
||||
puts "CR6987"
|
||||
puts "============"
|
||||
puts ""
|
||||
#######################################################################
|
||||
# Impossible to change edge line type in 3D View
|
||||
#######################################################################
|
||||
|
||||
pload VISUALIZATION
|
||||
|
||||
set anImage1 $imagedir/${casename}_1.png
|
||||
set anImage2 $imagedir/${casename}_2.png
|
||||
set anImage3 $imagedir/${casename}_3.png
|
||||
|
||||
vinit
|
||||
box b 1 1 1
|
||||
vdisplay b
|
||||
vfit
|
||||
vsetdispmode b 1
|
||||
vsetedgetype b -type DASH -color 10 255 10
|
||||
vdump $anImage1
|
||||
|
||||
vsetinteriorstyle b EMPTY
|
||||
vdump $anImage2
|
||||
|
||||
vsetinteriorstyle b SOLID
|
||||
vunsetedgetype b
|
||||
vdump $anImage3
|
||||
|
||||
|
24
tests/bugs/vis/bug6897_2
Normal file
24
tests/bugs/vis/bug6897_2
Normal file
@ -0,0 +1,24 @@
|
||||
puts "============"
|
||||
puts "CR6987"
|
||||
puts "============"
|
||||
puts ""
|
||||
##########################################################################
|
||||
# Impossible to change edge line type in 3D View
|
||||
# Tests forced redisplay of object after aspect parameter's been changed
|
||||
##########################################################################
|
||||
|
||||
pload VISUALIZATION
|
||||
|
||||
set anImage1 $imagedir/${casename}_1.png
|
||||
set anImage2 $imagedir/${casename}_2.png
|
||||
|
||||
vinit
|
||||
box b 1 1 1
|
||||
vdisplay b
|
||||
vfit
|
||||
vsetdispmode b 1
|
||||
vsetedgetype b -type DASH -color 10 255 10 -force
|
||||
vdump $anImage1
|
||||
|
||||
vunsetedgetype b -force
|
||||
vdump $anImage2
|
Loading…
x
Reference in New Issue
Block a user