mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +03:00
0030690: Draw Harness - provide XDisplay command for displaying XDE document
XDisplay - added new command displaying XDE document in ViewerTest map of object: > XDisplay Doc [label1 [label2 [...]]] [-explore {on|off}] [-docPrefix {on|off}] [-names {on|off}] > [-noupdate] [-dispMode Mode] [-highMode Mode] vstate - added NULL checks. vdisplay now prints error on attempt to specify unsupported display mode. verase, vremove now raise Tcl exception on attempt to hide non-existing object. verase, vremove, vdir now accept name masks like "verase b*". vremove and vdir output is now consistent to verase command (space-separated list of removed objects).
This commit is contained in:
parent
49dfdb7a97
commit
ab1f458034
@ -1061,14 +1061,55 @@ static Standard_Integer VClearSensi (Draw_Interpretor& ,
|
|||||||
//purpose : To list the displayed object with their attributes
|
//purpose : To list the displayed object with their attributes
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
static int VDir (Draw_Interpretor& theDI,
|
static int VDir (Draw_Interpretor& theDI,
|
||||||
Standard_Integer ,
|
Standard_Integer theNbArgs,
|
||||||
const char** )
|
const char** theArgVec)
|
||||||
{
|
{
|
||||||
for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
|
TCollection_AsciiString aMatch;
|
||||||
anIter.More(); anIter.Next())
|
Standard_Boolean toFormat = Standard_False;
|
||||||
|
for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
|
||||||
{
|
{
|
||||||
theDI << "\t" << anIter.Key2() << "\n";
|
TCollection_AsciiString anArgCase (theArgVec[anArgIter]);
|
||||||
|
anArgCase.LowerCase();
|
||||||
|
if (anArgCase == "-list"
|
||||||
|
|| anArgCase == "-format")
|
||||||
|
{
|
||||||
|
toFormat = Standard_True;
|
||||||
|
}
|
||||||
|
else if (aMatch.IsEmpty())
|
||||||
|
{
|
||||||
|
aMatch = theArgVec[anArgIter];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cout << "Syntax error at '" << theArgVec[anArgIter] << "'\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TCollection_AsciiString aRes;
|
||||||
|
for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS()); anIter.More(); anIter.Next())
|
||||||
|
{
|
||||||
|
if (!aMatch.IsEmpty())
|
||||||
|
{
|
||||||
|
const TCollection_AsciiString aCheck = TCollection_AsciiString ("string match '") + aMatch + "' '" + anIter.Key2() + "'";
|
||||||
|
if (theDI.Eval (aCheck.ToCString()) == 0
|
||||||
|
&& *theDI.Result() != '1')
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (toFormat)
|
||||||
|
{
|
||||||
|
aRes += TCollection_AsciiString("\t") + anIter.Key2() + "\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
aRes += anIter.Key2() + " ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
theDI.Reset();
|
||||||
|
theDI << aRes;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3537,6 +3578,7 @@ int VRemove (Draw_Interpretor& theDI,
|
|||||||
Standard_Boolean isContextOnly = Standard_False;
|
Standard_Boolean isContextOnly = Standard_False;
|
||||||
Standard_Boolean toRemoveAll = Standard_False;
|
Standard_Boolean toRemoveAll = Standard_False;
|
||||||
Standard_Boolean toPrintInfo = Standard_True;
|
Standard_Boolean toPrintInfo = Standard_True;
|
||||||
|
Standard_Boolean toFailOnError = Standard_True;
|
||||||
|
|
||||||
Standard_Integer anArgIter = 1;
|
Standard_Integer anArgIter = 1;
|
||||||
for (; anArgIter < theArgNb; ++anArgIter)
|
for (; anArgIter < theArgNb; ++anArgIter)
|
||||||
@ -3555,6 +3597,11 @@ int VRemove (Draw_Interpretor& theDI,
|
|||||||
{
|
{
|
||||||
toPrintInfo = Standard_False;
|
toPrintInfo = Standard_False;
|
||||||
}
|
}
|
||||||
|
else if (anArg == "-noerror"
|
||||||
|
|| anArg == "-nofail")
|
||||||
|
{
|
||||||
|
toFailOnError = Standard_False;
|
||||||
|
}
|
||||||
else if (anUpdateTool.parseRedrawMode (anArg))
|
else if (anUpdateTool.parseRedrawMode (anArg))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@ -3584,23 +3631,48 @@ int VRemove (Draw_Interpretor& theDI,
|
|||||||
{
|
{
|
||||||
for (; anArgIter < theArgNb; ++anArgIter)
|
for (; anArgIter < theArgNb; ++anArgIter)
|
||||||
{
|
{
|
||||||
TCollection_AsciiString aName = theArgVec[anArgIter];
|
const TCollection_AsciiString aName (theArgVec[anArgIter]);
|
||||||
|
if (aName.Search ("*") != -1)
|
||||||
|
{
|
||||||
|
for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName aPrsIter (GetMapOfAIS()); aPrsIter.More(); aPrsIter.Next())
|
||||||
|
{
|
||||||
|
if (aPrsIter.Key1()->GetContext() != aCtx)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const TCollection_AsciiString aCheck = TCollection_AsciiString ("string match '") + aName + "' '" + aPrsIter.Key2() + "'";
|
||||||
|
if (theDI.Eval (aCheck.ToCString()) == 0
|
||||||
|
&& *theDI.Result() == '1')
|
||||||
|
{
|
||||||
|
anIONameList.Append (aPrsIter.Key2());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
theDI.Reset();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
Handle(AIS_InteractiveObject) anIO;
|
Handle(AIS_InteractiveObject) anIO;
|
||||||
if (!GetMapOfAIS().Find2 (aName, anIO))
|
if (!GetMapOfAIS().Find2 (aName, anIO))
|
||||||
{
|
{
|
||||||
theDI << aName << " was not bound to some object.\n";
|
if (toFailOnError)
|
||||||
continue;
|
{
|
||||||
|
std::cout << "Syntax error: '" << aName << "' was not bound to some object.\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else if (anIO->GetContext() != aCtx)
|
||||||
if (anIO->GetContext() != aCtx)
|
|
||||||
{
|
{
|
||||||
theDI << aName << " was not displayed in current context.\n";
|
if (toFailOnError)
|
||||||
theDI << "Please activate view with this object displayed and try again.\n";
|
{
|
||||||
continue;
|
std::cout << "Syntax error: '" << aName << "' was not displayed in current context.\n"
|
||||||
|
<< "Please activate view with this object displayed and try again.\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
anIONameList.Append (aName);
|
||||||
}
|
}
|
||||||
|
|
||||||
anIONameList.Append (aName);
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (aCtx->NbSelected() > 0)
|
else if (aCtx->NbSelected() > 0)
|
||||||
@ -3626,7 +3698,7 @@ int VRemove (Draw_Interpretor& theDI,
|
|||||||
aCtx->Remove (anIO, Standard_False);
|
aCtx->Remove (anIO, Standard_False);
|
||||||
if (toPrintInfo)
|
if (toPrintInfo)
|
||||||
{
|
{
|
||||||
theDI << anIter.Value() << " was removed\n";
|
theDI << anIter.Value() << " ";
|
||||||
}
|
}
|
||||||
if (!isContextOnly)
|
if (!isContextOnly)
|
||||||
{
|
{
|
||||||
@ -3658,6 +3730,7 @@ int VErase (Draw_Interpretor& theDI,
|
|||||||
|
|
||||||
Standard_Integer anArgIter = 1;
|
Standard_Integer anArgIter = 1;
|
||||||
Standard_Boolean toEraseInView = Standard_False;
|
Standard_Boolean toEraseInView = Standard_False;
|
||||||
|
Standard_Boolean toFailOnError = Standard_True;
|
||||||
TColStd_SequenceOfAsciiString aNamesOfEraseIO;
|
TColStd_SequenceOfAsciiString aNamesOfEraseIO;
|
||||||
for (; anArgIter < theArgNb; ++anArgIter)
|
for (; anArgIter < theArgNb; ++anArgIter)
|
||||||
{
|
{
|
||||||
@ -3672,6 +3745,11 @@ int VErase (Draw_Interpretor& theDI,
|
|||||||
{
|
{
|
||||||
toEraseInView = Standard_True;
|
toEraseInView = Standard_True;
|
||||||
}
|
}
|
||||||
|
else if (anArgCase == "-noerror"
|
||||||
|
|| anArgCase == "-nofail")
|
||||||
|
{
|
||||||
|
toFailOnError = Standard_False;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
aNamesOfEraseIO.Append (theArgVec[anArgIter]);
|
aNamesOfEraseIO.Append (theArgVec[anArgIter]);
|
||||||
@ -3687,28 +3765,53 @@ int VErase (Draw_Interpretor& theDI,
|
|||||||
if (!aNamesOfEraseIO.IsEmpty())
|
if (!aNamesOfEraseIO.IsEmpty())
|
||||||
{
|
{
|
||||||
// Erase named objects
|
// Erase named objects
|
||||||
for (Standard_Integer anIter = 1; anIter <= aNamesOfEraseIO.Length(); ++anIter)
|
NCollection_IndexedDataMap<Handle(AIS_InteractiveObject), TCollection_AsciiString> aPrsList;
|
||||||
|
for (TColStd_SequenceOfAsciiString::Iterator anIter (aNamesOfEraseIO); anIter.More(); anIter.Next())
|
||||||
{
|
{
|
||||||
TCollection_AsciiString aName = aNamesOfEraseIO.Value (anIter);
|
const TCollection_AsciiString& aName = anIter.Value();
|
||||||
Handle(AIS_InteractiveObject) anIO;
|
if (aName.Search ("*") != -1)
|
||||||
if (!GetMapOfAIS().Find2 (aName, anIO))
|
|
||||||
{
|
{
|
||||||
continue;
|
for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName aPrsIter (GetMapOfAIS()); aPrsIter.More(); aPrsIter.Next())
|
||||||
}
|
|
||||||
|
|
||||||
theDI << aName << " ";
|
|
||||||
if (!anIO.IsNull())
|
|
||||||
{
|
|
||||||
if (toEraseInView)
|
|
||||||
{
|
{
|
||||||
aCtx->SetViewAffinity (anIO, aView, Standard_False);
|
const TCollection_AsciiString aCheck = TCollection_AsciiString ("string match '") + aName + "' '" + aPrsIter.Key2() + "'";
|
||||||
|
if (theDI.Eval (aCheck.ToCString()) == 0
|
||||||
|
&& *theDI.Result() == '1')
|
||||||
|
{
|
||||||
|
aPrsList.Add (aPrsIter.Key1(), aPrsIter.Key2());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
theDI.Reset();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Handle(AIS_InteractiveObject) anIO;
|
||||||
|
if (!GetMapOfAIS().Find2 (aName, anIO))
|
||||||
|
{
|
||||||
|
if (toFailOnError)
|
||||||
|
{
|
||||||
|
std::cout << "Syntax error: '" << aName << "' is not found\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
aCtx->Erase (anIO, Standard_False);
|
aPrsList.Add (anIO, aName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (NCollection_IndexedDataMap<Handle(AIS_InteractiveObject), TCollection_AsciiString>::Iterator anIter (aPrsList); anIter.More(); anIter.Next())
|
||||||
|
{
|
||||||
|
theDI << anIter.Value() << " ";
|
||||||
|
if (toEraseInView)
|
||||||
|
{
|
||||||
|
aCtx->SetViewAffinity (anIter.Key(), aView, Standard_False);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
aCtx->Erase (anIter.Key(), Standard_False);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (!toEraseAll && aCtx->NbSelected() > 0)
|
else if (!toEraseAll && aCtx->NbSelected() > 0)
|
||||||
{
|
{
|
||||||
@ -4684,6 +4787,12 @@ static int VDisplay2 (Draw_Interpretor& theDI,
|
|||||||
std::cerr << theArgVec[0] << "Error: wrong number of arguments.\n";
|
std::cerr << theArgVec[0] << "Error: wrong number of arguments.\n";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
if (theArgNb == 2
|
||||||
|
&& TCollection_AsciiString (theArgVec[1]) == "*")
|
||||||
|
{
|
||||||
|
// alias
|
||||||
|
return VDisplayAll (theDI, 1, theArgVec);
|
||||||
|
}
|
||||||
|
|
||||||
Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
|
Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
|
||||||
if (aCtx.IsNull())
|
if (aCtx.IsNull())
|
||||||
@ -4763,7 +4872,8 @@ static int VDisplay2 (Draw_Interpretor& theDI,
|
|||||||
|
|
||||||
anObjDispMode = Draw::Atoi (theArgVec [anArgIter]);
|
anObjDispMode = Draw::Atoi (theArgVec [anArgIter]);
|
||||||
}
|
}
|
||||||
else if (aNameCase == "-highmode"
|
else if (aNameCase == "-himode"
|
||||||
|
|| aNameCase == "-highmode"
|
||||||
|| aNameCase == "-highlightmode")
|
|| aNameCase == "-highlightmode")
|
||||||
{
|
{
|
||||||
if (++anArgIter >= theArgNb)
|
if (++anArgIter >= theArgNb)
|
||||||
@ -4940,10 +5050,28 @@ static int VDisplay2 (Draw_Interpretor& theDI,
|
|||||||
}
|
}
|
||||||
if (anObjDispMode != -2)
|
if (anObjDispMode != -2)
|
||||||
{
|
{
|
||||||
aShape->SetDisplayMode (anObjDispMode);
|
if (anObjDispMode == -1)
|
||||||
|
{
|
||||||
|
aShape->UnsetDisplayMode();
|
||||||
|
}
|
||||||
|
if (!aShape->AcceptDisplayMode (anObjDispMode))
|
||||||
|
{
|
||||||
|
std::cout << "Syntax error: " << aShape->DynamicType()->Name() << " rejects " << anObjDispMode << " display mode\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
aShape->SetDisplayMode (anObjDispMode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (anObjHighMode != -2)
|
if (anObjHighMode != -2)
|
||||||
{
|
{
|
||||||
|
if (anObjHighMode != -1
|
||||||
|
&& !aShape->AcceptDisplayMode (anObjHighMode))
|
||||||
|
{
|
||||||
|
std::cout << "Syntax error: " << aShape->DynamicType()->Name() << " rejects " << anObjHighMode << " display mode\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
aShape->SetHilightMode (anObjHighMode);
|
aShape->SetHilightMode (anObjHighMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5343,7 +5471,9 @@ static Standard_Integer VState (Draw_Interpretor& theDI,
|
|||||||
const Handle(SelectBasics_SensitiveEntity)& anEntity = aSelector->PickedEntity (aPickIter);
|
const Handle(SelectBasics_SensitiveEntity)& anEntity = aSelector->PickedEntity (aPickIter);
|
||||||
Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (anEntity->OwnerId());
|
Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (anEntity->OwnerId());
|
||||||
Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
|
Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
|
||||||
TCollection_AsciiString aName = GetMapOfAIS().Find1 (anObj);
|
|
||||||
|
TCollection_AsciiString aName;
|
||||||
|
GetMapOfAIS().Find1 (anObj, aName);
|
||||||
aName.LeftJustify (20, ' ');
|
aName.LeftJustify (20, ' ');
|
||||||
char anInfoStr[512];
|
char anInfoStr[512];
|
||||||
Sprintf (anInfoStr,
|
Sprintf (anInfoStr,
|
||||||
@ -5423,7 +5553,8 @@ static Standard_Integer VState (Draw_Interpretor& theDI,
|
|||||||
// handle whole object selection
|
// handle whole object selection
|
||||||
if (anOwner == anObj->GlobalSelOwner())
|
if (anOwner == anObj->GlobalSelOwner())
|
||||||
{
|
{
|
||||||
TCollection_AsciiString aName = GetMapOfAIS().Find1 (anObj);
|
TCollection_AsciiString aName;
|
||||||
|
GetMapOfAIS().Find1 (anObj, aName);
|
||||||
aName.LeftJustify (20, ' ');
|
aName.LeftJustify (20, ' ');
|
||||||
theDI << aName << " ";
|
theDI << aName << " ";
|
||||||
objInfo (aDetected, anObj, theDI);
|
objInfo (aDetected, anObj, theDI);
|
||||||
@ -6354,15 +6485,16 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands)
|
|||||||
__FILE__, VUpdate, group);
|
__FILE__, VUpdate, group);
|
||||||
|
|
||||||
theCommands.Add("verase",
|
theCommands.Add("verase",
|
||||||
"verase [-noupdate|-update] [-local] [name1] ... [name n]"
|
"verase [-noupdate|-update] [-local] [name1] ... [name n] [-noerror]"
|
||||||
"\n\t\t: Erases selected or named objects."
|
"\n\t\t: Erases selected or named objects."
|
||||||
"\n\t\t: If there are no selected or named objects the whole viewer is erased."
|
"\n\t\t: If there are no selected or named objects the whole viewer is erased."
|
||||||
"\n\t\t: Option -local enables erasing of selected or named objects without"
|
"\n\t\t: Option -local enables erasing of selected or named objects without"
|
||||||
"\n\t\t: closing local selection context.",
|
"\n\t\t: closing local selection context."
|
||||||
|
"\n\t\t: Option -noerror prevents exception on non-existing objects.",
|
||||||
__FILE__, VErase, group);
|
__FILE__, VErase, group);
|
||||||
|
|
||||||
theCommands.Add("vremove",
|
theCommands.Add("vremove",
|
||||||
"vremove [-noupdate|-update] [-context] [-all] [-noinfo] [name1] ... [name n]"
|
"vremove [-noupdate|-update] [-context] [-all] [-noinfo] [name1] ... [name n] [-noerror]"
|
||||||
"or vremove [-context] -all to remove all objects"
|
"or vremove [-context] -all to remove all objects"
|
||||||
"\n\t\t: Removes selected or named objects."
|
"\n\t\t: Removes selected or named objects."
|
||||||
"\n\t\t If -context is in arguments, the objects are not deleted"
|
"\n\t\t If -context is in arguments, the objects are not deleted"
|
||||||
@ -6371,7 +6503,8 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands)
|
|||||||
"\n\t\t: closing local selection context. Empty local selection context will be"
|
"\n\t\t: closing local selection context. Empty local selection context will be"
|
||||||
"\n\t\t: closed."
|
"\n\t\t: closed."
|
||||||
"\n\t\t: Option -noupdate suppresses viewer redraw call."
|
"\n\t\t: Option -noupdate suppresses viewer redraw call."
|
||||||
"\n\t\t: Option -noinfo suppresses displaying the list of removed objects.",
|
"\n\t\t: Option -noinfo suppresses displaying the list of removed objects."
|
||||||
|
"\n\t\t: Option -noerror prevents exception on non-existing objects.",
|
||||||
__FILE__, VRemove, group);
|
__FILE__, VRemove, group);
|
||||||
|
|
||||||
theCommands.Add("vdonly",
|
theCommands.Add("vdonly",
|
||||||
@ -6416,7 +6549,10 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands)
|
|||||||
__FILE__,VDispMode,group);
|
__FILE__,VDispMode,group);
|
||||||
|
|
||||||
theCommands.Add("vdir",
|
theCommands.Add("vdir",
|
||||||
"Lists all objects displayed in 3D viewer",
|
"vdir [mask] [-list]"
|
||||||
|
"\n\t\t: Lists all objects displayed in 3D viewer"
|
||||||
|
"\n\t\t: mask - name filter like prefix*"
|
||||||
|
"\n\t\t: -list - format list with new-line per name; OFF by default",
|
||||||
__FILE__,VDir,group);
|
__FILE__,VDir,group);
|
||||||
|
|
||||||
#ifdef HAVE_FREEIMAGE
|
#ifdef HAVE_FREEIMAGE
|
||||||
|
@ -46,6 +46,7 @@
|
|||||||
#include <TDataStd_TreeNode.hxx>
|
#include <TDataStd_TreeNode.hxx>
|
||||||
#include <TDataStd_UAttribute.hxx>
|
#include <TDataStd_UAttribute.hxx>
|
||||||
#include <TDF_AttributeIterator.hxx>
|
#include <TDF_AttributeIterator.hxx>
|
||||||
|
#include <TDF_ChildIterator.hxx>
|
||||||
#include <TDF_Data.hxx>
|
#include <TDF_Data.hxx>
|
||||||
#include <TDF_LabelSequence.hxx>
|
#include <TDF_LabelSequence.hxx>
|
||||||
#include <TDF_Reference.hxx>
|
#include <TDF_Reference.hxx>
|
||||||
@ -62,6 +63,7 @@
|
|||||||
#include <V3d_View.hxx>
|
#include <V3d_View.hxx>
|
||||||
#include <V3d_Viewer.hxx>
|
#include <V3d_Viewer.hxx>
|
||||||
#include <ViewerTest.hxx>
|
#include <ViewerTest.hxx>
|
||||||
|
#include <ViewerTest_AutoUpdater.hxx>
|
||||||
#include <XCAFDoc.hxx>
|
#include <XCAFDoc.hxx>
|
||||||
#include <XCAFDoc_Area.hxx>
|
#include <XCAFDoc_Area.hxx>
|
||||||
#include <XCAFDoc_Centroid.hxx>
|
#include <XCAFDoc_Centroid.hxx>
|
||||||
@ -78,6 +80,7 @@
|
|||||||
#include <XCAFDoc_ShapeTool.hxx>
|
#include <XCAFDoc_ShapeTool.hxx>
|
||||||
#include <XCAFDoc_Volume.hxx>
|
#include <XCAFDoc_Volume.hxx>
|
||||||
#include <XCAFPrs.hxx>
|
#include <XCAFPrs.hxx>
|
||||||
|
#include <XCAFPrs_AISObject.hxx>
|
||||||
#include <XCAFPrs_Driver.hxx>
|
#include <XCAFPrs_Driver.hxx>
|
||||||
#include <XDEDRAW.hxx>
|
#include <XDEDRAW.hxx>
|
||||||
#include <XDEDRAW_Colors.hxx>
|
#include <XDEDRAW_Colors.hxx>
|
||||||
@ -578,6 +581,288 @@ static Standard_Integer show (Draw_Interpretor& di, Standard_Integer argc, const
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! XDisplay command implementation.
|
||||||
|
class XDEDRAW_XDisplayTool
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//! XDisplay command interface.
|
||||||
|
static Standard_Integer XDisplay (Draw_Interpretor& theDI,
|
||||||
|
Standard_Integer theNbArgs,
|
||||||
|
const char** theArgVec)
|
||||||
|
{
|
||||||
|
XDEDRAW_XDisplayTool aTool;
|
||||||
|
return aTool.xdisplay (theDI, theNbArgs, theArgVec);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
//! Constructor.
|
||||||
|
XDEDRAW_XDisplayTool()
|
||||||
|
: myDispMode(-2),
|
||||||
|
myHiMode (-2),
|
||||||
|
myToPrefixDocName (Standard_True),
|
||||||
|
myToGetNames (Standard_True),
|
||||||
|
myToExplore (Standard_False) {}
|
||||||
|
|
||||||
|
//! Display single label.
|
||||||
|
Standard_Integer displayLabel (Draw_Interpretor& theDI,
|
||||||
|
const TDF_Label& theLabel,
|
||||||
|
const TCollection_AsciiString& theNamePrefix,
|
||||||
|
const TopLoc_Location& theLoc)
|
||||||
|
{
|
||||||
|
TCollection_AsciiString aName;
|
||||||
|
if (myToGetNames)
|
||||||
|
{
|
||||||
|
Handle(TDataStd_Name) aNodeName;
|
||||||
|
if (theLabel.FindAttribute (TDataStd_Name::GetID(), aNodeName))
|
||||||
|
{
|
||||||
|
aName = aNodeName->Get();
|
||||||
|
}
|
||||||
|
if (aName.IsEmpty())
|
||||||
|
{
|
||||||
|
TDF_Label aRefLabel;
|
||||||
|
if (XCAFDoc_ShapeTool::GetReferredShape (theLabel, aRefLabel)
|
||||||
|
&& aRefLabel.FindAttribute (TDataStd_Name::GetID(), aNodeName))
|
||||||
|
{
|
||||||
|
aName = aNodeName->Get();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (aName.IsEmpty())
|
||||||
|
{
|
||||||
|
TDF_Tool::Entry (theLabel, aName);
|
||||||
|
}
|
||||||
|
for (Standard_Integer aNameIndex = 1;; ++aNameIndex)
|
||||||
|
{
|
||||||
|
if (myNameMap.Add (aName))
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
aName = aNodeName->Get() + "_" + aNameIndex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TDF_Tool::Entry (theLabel, aName);
|
||||||
|
}
|
||||||
|
aName = theNamePrefix + aName;
|
||||||
|
|
||||||
|
if (myToExplore)
|
||||||
|
{
|
||||||
|
TDF_Label aRefLabel = theLabel;
|
||||||
|
XCAFDoc_ShapeTool::GetReferredShape (theLabel, aRefLabel);
|
||||||
|
if (XCAFDoc_ShapeTool::IsAssembly (aRefLabel))
|
||||||
|
{
|
||||||
|
aName += "/";
|
||||||
|
const TopLoc_Location aLoc = theLoc * XCAFDoc_ShapeTool::GetLocation (theLabel);
|
||||||
|
for (TDF_ChildIterator aChildIter (aRefLabel); aChildIter.More(); aChildIter.Next())
|
||||||
|
{
|
||||||
|
if (displayLabel (theDI, aChildIter.Value(), aName, aLoc) == 1)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Handle(XCAFPrs_AISObject) aPrs = new XCAFPrs_AISObject (theLabel);
|
||||||
|
if (!theLoc.IsIdentity())
|
||||||
|
{
|
||||||
|
aPrs->SetLocalTransformation (theLoc);
|
||||||
|
}
|
||||||
|
if (myDispMode != -2)
|
||||||
|
{
|
||||||
|
if (myDispMode == -1)
|
||||||
|
{
|
||||||
|
aPrs->UnsetDisplayMode();
|
||||||
|
}
|
||||||
|
if (!aPrs->AcceptDisplayMode (myDispMode))
|
||||||
|
{
|
||||||
|
std::cout << "Syntax error: " << aPrs->DynamicType()->Name() << " rejects " << myDispMode << " display mode\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
aPrs->SetDisplayMode (myDispMode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (myHiMode != -2)
|
||||||
|
{
|
||||||
|
if (myHiMode != -1
|
||||||
|
&& !aPrs->AcceptDisplayMode (myHiMode))
|
||||||
|
{
|
||||||
|
std::cout << "Syntax error: " << aPrs->DynamicType()->Name() << " rejects " << myHiMode << " display mode\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
aPrs->SetHilightMode (myHiMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
ViewerTest::Display (aName, aPrs, false);
|
||||||
|
theDI << aName << " ";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! XDisplay command implementation.
|
||||||
|
Standard_Integer xdisplay (Draw_Interpretor& theDI,
|
||||||
|
Standard_Integer theNbArgs,
|
||||||
|
const char** theArgVec)
|
||||||
|
{
|
||||||
|
Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
|
||||||
|
if (aContext.IsNull())
|
||||||
|
{
|
||||||
|
std::cout << "Error: no active view!\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ViewerTest_AutoUpdater anAutoUpdater (aContext, ViewerTest::CurrentView());
|
||||||
|
for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
|
||||||
|
{
|
||||||
|
TCollection_AsciiString anArgCase (theArgVec[anArgIter]);
|
||||||
|
anArgCase.LowerCase();
|
||||||
|
if (anAutoUpdater.parseRedrawMode (anArgCase))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if (anArgIter + 1 < theNbArgs
|
||||||
|
&& myDispMode == -2
|
||||||
|
&& (anArgCase == "-dispmode"
|
||||||
|
|| anArgCase == "-displaymode")
|
||||||
|
&& TCollection_AsciiString (theArgVec[anArgIter + 1]).IsIntegerValue())
|
||||||
|
{
|
||||||
|
myDispMode = TCollection_AsciiString (theArgVec[++anArgIter]).IntegerValue();
|
||||||
|
}
|
||||||
|
else if (anArgIter + 1 < theNbArgs
|
||||||
|
&& myHiMode == -2
|
||||||
|
&& (anArgCase == "-himode"
|
||||||
|
|| anArgCase == "-highmode"
|
||||||
|
|| anArgCase == "-highlightmode")
|
||||||
|
&& TCollection_AsciiString (theArgVec[anArgIter + 1]).IsIntegerValue())
|
||||||
|
{
|
||||||
|
myHiMode = TCollection_AsciiString (theArgVec[++anArgIter]).IntegerValue();
|
||||||
|
}
|
||||||
|
else if (anArgCase == "-docprefix"
|
||||||
|
|| anArgCase == "-nodocprefix")
|
||||||
|
{
|
||||||
|
myToPrefixDocName = Standard_True;
|
||||||
|
if (anArgIter + 1 < theNbArgs
|
||||||
|
&& ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], myToPrefixDocName))
|
||||||
|
{
|
||||||
|
++anArgIter;
|
||||||
|
}
|
||||||
|
if (anArgCase.StartsWith ("-no"))
|
||||||
|
{
|
||||||
|
myToPrefixDocName = !myToPrefixDocName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (anArgCase == "-names"
|
||||||
|
|| anArgCase == "-nonames")
|
||||||
|
{
|
||||||
|
myToGetNames = Standard_True;
|
||||||
|
if (anArgIter + 1 < theNbArgs
|
||||||
|
&& ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], myToGetNames))
|
||||||
|
{
|
||||||
|
++anArgIter;
|
||||||
|
}
|
||||||
|
if (anArgCase.StartsWith ("-no"))
|
||||||
|
{
|
||||||
|
myToGetNames = !myToGetNames;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (anArgCase == "-explore"
|
||||||
|
|| anArgCase == "-noexplore")
|
||||||
|
{
|
||||||
|
myToExplore = Standard_True;
|
||||||
|
if (anArgIter + 1 < theNbArgs
|
||||||
|
&& ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], myToExplore))
|
||||||
|
{
|
||||||
|
++anArgIter;
|
||||||
|
}
|
||||||
|
if (anArgCase.StartsWith ("-no"))
|
||||||
|
{
|
||||||
|
myToExplore = !myToExplore;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (myDoc.IsNull()
|
||||||
|
&& DDocStd::GetDocument (theArgVec[anArgIter], myDoc, Standard_False))
|
||||||
|
{
|
||||||
|
myDocName = theArgVec[anArgIter];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
TCollection_AsciiString aValue (theArgVec[anArgIter]);
|
||||||
|
const Standard_Integer aFirstSplit = aValue.Search (":");
|
||||||
|
if (!IsDigit (aValue.Value (1))
|
||||||
|
&& aFirstSplit >= 2
|
||||||
|
&& aFirstSplit < aValue.Length())
|
||||||
|
{
|
||||||
|
TCollection_AsciiString aDocName = aValue.SubString (1, aFirstSplit - 1);
|
||||||
|
Standard_CString aDocNameStr = aDocName.ToCString();
|
||||||
|
Handle(TDocStd_Document) aDoc;
|
||||||
|
if (DDocStd::GetDocument (aDocNameStr, aDoc, Standard_False))
|
||||||
|
{
|
||||||
|
aValue = aValue.SubString (aFirstSplit + 1, aValue.Length());
|
||||||
|
if (!myDoc.IsNull()
|
||||||
|
&& myDoc != aDoc)
|
||||||
|
{
|
||||||
|
std::cout << "Syntax error at '" << theArgVec[anArgIter] << "'\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
myDoc = aDoc;
|
||||||
|
myDocName = aDocName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (myDoc.IsNull())
|
||||||
|
{
|
||||||
|
std::cout << "Syntax error at '" << theArgVec[anArgIter] << "'\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
TDF_Label aLabel;
|
||||||
|
TDF_Tool::Label (myDoc->GetData(), aValue.ToCString(), aLabel);
|
||||||
|
if (aLabel.IsNull()
|
||||||
|
|| !XCAFDoc_ShapeTool::IsShape (aLabel))
|
||||||
|
{
|
||||||
|
std::cout << "Syntax error: " << aValue << " is not a valid shape label\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
myLabels.Append (aLabel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (myDoc.IsNull())
|
||||||
|
{
|
||||||
|
std::cout << "Syntax error: not enough arguments\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (myLabels.IsEmpty())
|
||||||
|
{
|
||||||
|
XCAFDoc_DocumentTool::ShapeTool (myDoc->Main())->GetFreeShapes (myLabels);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (TDF_LabelSequence::Iterator aLabIter (myLabels); aLabIter.More(); aLabIter.Next())
|
||||||
|
{
|
||||||
|
const TDF_Label& aLabel = aLabIter.Value();
|
||||||
|
if (displayLabel (theDI, aLabel, myToPrefixDocName ? myDocName + ":" : "", TopLoc_Location()) == 1)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
NCollection_Map<TCollection_AsciiString, TCollection_AsciiString>
|
||||||
|
myNameMap; //!< names map to handle collisions
|
||||||
|
Handle(TDocStd_Document) myDoc; //!< document
|
||||||
|
TCollection_AsciiString myDocName; //!< document name
|
||||||
|
TDF_LabelSequence myLabels; //!< labels to display
|
||||||
|
Standard_Integer myDispMode; //!< shape display mode
|
||||||
|
Standard_Integer myHiMode; //!< shape highlight mode
|
||||||
|
Standard_Boolean myToPrefixDocName; //!< flag to prefix objects with document name
|
||||||
|
Standard_Boolean myToGetNames; //!< flag to use label names or tags
|
||||||
|
Standard_Boolean myToExplore; //!< flag to explore assembles
|
||||||
|
};
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : xwd
|
//function : xwd
|
||||||
@ -1171,6 +1456,17 @@ void XDEDRAW::Init(Draw_Interpretor& di)
|
|||||||
di.Add ("XShow","Doc [label1 lavbel2 ...] \t: Display document (or some labels) in a graphical window",
|
di.Add ("XShow","Doc [label1 lavbel2 ...] \t: Display document (or some labels) in a graphical window",
|
||||||
__FILE__, show, g);
|
__FILE__, show, g);
|
||||||
|
|
||||||
|
di.Add ("XDisplay",
|
||||||
|
"XDisplay Doc [label1 [label2 [...]]] [-explore {on|off}] [-docPrefix {on|off}] [-names {on|off}]"
|
||||||
|
"\n\t\t: [-noupdate] [-dispMode Mode] [-highMode Mode]"
|
||||||
|
"\n\t\t: Displays document (parts) in 3D Viewer."
|
||||||
|
"\n\t\t: -dispMode Presentation display mode."
|
||||||
|
"\n\t\t: -highMode Presentation highlight mode."
|
||||||
|
"\n\t\t: -docPrefix Prepend document name to object names; TRUE by default."
|
||||||
|
"\n\t\t: -names Use object names instead of label tag; TRUE by default."
|
||||||
|
"\n\t\t: -explore Explode labels to leaves; FALSE by default.",
|
||||||
|
__FILE__, XDEDRAW_XDisplayTool::XDisplay, g);
|
||||||
|
|
||||||
di.Add ("XWdump","Doc filename.{gif|xwd|bmp} \t: Dump contents of viewer window to XWD, GIF or BMP file",
|
di.Add ("XWdump","Doc filename.{gif|xwd|bmp} \t: Dump contents of viewer window to XWD, GIF or BMP file",
|
||||||
__FILE__, xwd, g);
|
__FILE__, xwd, g);
|
||||||
|
|
||||||
|
@ -52,7 +52,6 @@ vfit
|
|||||||
set aPln1Z 40
|
set aPln1Z 40
|
||||||
set aPln2Y 15
|
set aPln2Y 15
|
||||||
|
|
||||||
vremove -noupdate p1 p2 p3 pp1 pp2
|
|
||||||
vpoint p1 0 0 1
|
vpoint p1 0 0 1
|
||||||
vpoint p2 1 0 1
|
vpoint p2 1 0 1
|
||||||
vpoint p3 0 1 1
|
vpoint p3 0 1 1
|
||||||
|
@ -20,7 +20,7 @@ vselmode b 2 1
|
|||||||
vselect 87 170
|
vselect 87 170
|
||||||
vselect 165 170 $shift
|
vselect 165 170 $shift
|
||||||
|
|
||||||
vrelation redgess -identic
|
vrelation redges -identic
|
||||||
|
|
||||||
vdump $imagedir/${casename}_edges.png
|
vdump $imagedir/${casename}_edges.png
|
||||||
|
|
||||||
|
@ -58,7 +58,6 @@ vsetlocation cc 70 0 0
|
|||||||
set aPln1Z 40
|
set aPln1Z 40
|
||||||
set aPln2Y 15
|
set aPln2Y 15
|
||||||
|
|
||||||
vremove -noupdate p1 p2 p3 pp1 pp2
|
|
||||||
vpoint p1 0 0 1
|
vpoint p1 0 0 1
|
||||||
vpoint p2 1 0 1
|
vpoint p2 1 0 1
|
||||||
vpoint p3 0 1 1
|
vpoint p3 0 1 1
|
||||||
|
@ -5,7 +5,7 @@ puts "========"
|
|||||||
pload MODELING OCAF XDE
|
pload MODELING OCAF XDE
|
||||||
box b 10 10 10
|
box b 10 10 10
|
||||||
vclear
|
vclear
|
||||||
vclose all
|
vinit View1
|
||||||
catch { Close D }
|
catch { Close D }
|
||||||
NewDocument D BinXCAF
|
NewDocument D BinXCAF
|
||||||
XAddShape D b
|
XAddShape D b
|
||||||
@ -13,14 +13,14 @@ XSetColor D b 0 0 1
|
|||||||
explode b f
|
explode b f
|
||||||
XSetColor D b_1 1 0 0
|
XSetColor D b_1 1 0 0
|
||||||
|
|
||||||
XShow D
|
XDisplay D
|
||||||
vviewparams -proj 1 0.1 0.1
|
vviewparams -proj 1 0.1 0.1
|
||||||
vfit
|
vfit
|
||||||
vsetdispmode 1
|
vsetdispmode 1
|
||||||
|
|
||||||
catch { vclipplane delete pln }
|
catch { vclipplane delete pln }
|
||||||
vclipplane create pln
|
vclipplane create pln
|
||||||
vclipplane set pln view Driver1/Document_D/View1
|
vclipplane set pln view Driver1/Viewer1/View1
|
||||||
vclipplane change pln equation -1 0 0 5
|
vclipplane change pln equation -1 0 0 5
|
||||||
|
|
||||||
# FFP on, pixel is RED3, which is expected
|
# FFP on, pixel is RED3, which is expected
|
||||||
|
Loading…
x
Reference in New Issue
Block a user