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

0024705: Draw Harness - add -noupdate option to vdisplay command

Add option to suppress viewer redraw to the following commands:
vdisplay, vdonly, verase, vremove
This commit is contained in:
kgv 2014-03-09 11:17:30 +04:00 committed by bugmaster
parent db71702d4b
commit 519d35d81e

@ -88,6 +88,34 @@ extern int ViewerMainLoop(Standard_Integer argc, const char** argv);
#define DEFAULT_COLOR Quantity_NOC_GOLDENROD #define DEFAULT_COLOR Quantity_NOC_GOLDENROD
#define DEFAULT_MATERIAL Graphic3d_NOM_BRASS #define DEFAULT_MATERIAL Graphic3d_NOM_BRASS
enum ViewerTest_RedrawMode
{
ViewerTest_RM_Auto = -1,
ViewerTest_RM_RedrawForce,
ViewerTest_RM_RedrawSuppress
};
//! Auxiliary method to parse redraw mode argument
static Standard_Boolean parseRedrawMode (const TCollection_AsciiString& theArg,
ViewerTest_RedrawMode& theMode)
{
TCollection_AsciiString anArgCase (theArg);
anArgCase.LowerCase();
if (anArgCase == "-update"
|| anArgCase == "-redraw")
{
theMode = ViewerTest_RM_RedrawForce;
return Standard_True;
}
else if (anArgCase == "-noupdate"
|| anArgCase == "-noredraw")
{
theMode = ViewerTest_RM_RedrawSuppress;
return Standard_True;
}
return Standard_False;
}
//======================================================================= //=======================================================================
//function : GetColorFromName //function : GetColorFromName
//purpose : get the Quantity_NameOfColor from a string //purpose : get the Quantity_NameOfColor from a string
@ -700,22 +728,23 @@ static int VClearSensi (Draw_Interpretor& ,Standard_Integer , const char** )
} }
//============================================================================== //==============================================================================
//function : VDebug //function : VDir
//purpose : To list the displayed object with their attributes //purpose : To list the displayed object with their attributes
//Draw arg : No args
//============================================================================== //==============================================================================
static int VDebug(Draw_Interpretor& di, Standard_Integer , const char** ) static int VDir (Draw_Interpretor& theDI,
{ if ( !a3DView().IsNull() ) { Standard_Integer ,
di << "List of object in the viewer :" << "\n"; const char** )
{
ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it(GetMapOfAIS()); if (!a3DView().IsNull())
{
while ( it.More() ) { return 0;
di << "\t" << it.Key2().ToCString() << "\n";
it.Next();
}
} }
for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
anIter.More(); anIter.Next())
{
theDI << "\t" << anIter.Key2().ToCString() << "\n";
}
return 0; return 0;
} }
@ -1529,77 +1558,101 @@ static int VInteriorStyle (Draw_Interpretor& di, Standard_Integer argc, const ch
//function : VDonly2 //function : VDonly2
//author : ege //author : ege
//purpose : Display only a selected or named object //purpose : Display only a selected or named object
// if there is no selected or named object s, nothing is donne // if there is no selected or named object s, nothing is done
//Draw arg : vdonly2 [name1] ... [name n]
//============================================================================== //==============================================================================
static int VDonly2(Draw_Interpretor& , Standard_Integer argc, const char** argv) static int VDonly2 (Draw_Interpretor& ,
Standard_Integer theArgNb,
const char** theArgVec)
{ {
if ( a3DView().IsNull() ) const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
if (aCtx.IsNull())
{
std::cerr << "Error: no active view!\n";
return 1; return 1;
Standard_Boolean ThereIsCurrent = TheAISContext() -> NbCurrents() > 0;
Standard_Boolean ThereIsArgument= argc>1;
if (TheAISContext()->HasOpenedContext())
TheAISContext()->CloseLocalContext();
//===============================================================
// Il n'y a pas d'arguments mais des objets selectionnes(current)
// dans le viewer
//===============================================================
if (!ThereIsArgument && ThereIsCurrent) {
#ifdef DEB
ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName
it (GetMapOfAIS());
#endif
for(TheAISContext()->InitCurrent();
TheAISContext()->MoreCurrent();
TheAISContext()->NextCurrent()){
Handle(AIS_InteractiveObject) aShape = TheAISContext()->Current();
TheAISContext()->Erase(aShape,Standard_False);}
} }
TheAISContext() ->UpdateCurrentViewer();
//=============================================================== if (aCtx->HasOpenedContext())
// Il y a des arguments {
//=============================================================== aCtx->CloseLocalContext();
if (ThereIsArgument) { }
ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName ViewerTest_RedrawMode aToUpdate = ViewerTest_RM_Auto;
it (GetMapOfAIS());
while ( it.More() ) { Standard_Integer anArgIter = 1;
if (it.Key1()->IsKind(STANDARD_TYPE(AIS_InteractiveObject))) { for (; anArgIter < theArgNb; ++anArgIter)
const Handle(AIS_InteractiveObject) aShape = {
Handle(AIS_InteractiveObject)::DownCast(it.Key1()); if (!parseRedrawMode (theArgVec[anArgIter], aToUpdate))
TheAISContext()->Erase(aShape,Standard_False); {
} else if (it.Key1()->IsKind(STANDARD_TYPE(NIS_InteractiveObject))) { break;
const Handle(NIS_InteractiveObject) aShape = }
Handle(NIS_InteractiveObject)::DownCast(it.Key1()); }
TheNISContext()->Erase(aShape);
} NCollection_Map<Handle(Standard_Transient)> aDispSet;
it.Next(); if (anArgIter >= theArgNb)
{
// display only selected objects
if (aCtx->NbCurrents() < 1)
{
return 0;
} }
// On display les objets passes par parametre for (aCtx->InitCurrent(); aCtx->MoreCurrent(); aCtx->NextCurrent())
for (int i=1; i<argc ; i++) { {
TCollection_AsciiString name=argv[i]; aDispSet.Add (aCtx->Current());
Standard_Boolean IsBound = GetMapOfAIS().IsBound2(name); }
if (IsBound) { }
const Handle(Standard_Transient) anObj = GetMapOfAIS().Find2(name); else
if (anObj->IsKind(STANDARD_TYPE(AIS_InteractiveObject))) { {
const Handle(AIS_InteractiveObject) aShape = // display only specified objects
Handle(AIS_InteractiveObject)::DownCast (anObj); for (; anArgIter < theArgNb; ++anArgIter)
TheAISContext()->Display(aShape, Standard_False); {
} else if (anObj->IsKind(STANDARD_TYPE(NIS_InteractiveObject))) { TCollection_AsciiString aName = theArgVec[anArgIter];
Handle(NIS_InteractiveObject) aShape = if (GetMapOfAIS().IsBound2 (aName))
Handle(NIS_InteractiveObject)::DownCast (anObj); {
TheNISContext()->Display(aShape); const Handle(Standard_Transient) anObj = GetMapOfAIS().Find2 (aName);
if (anObj->IsKind (STANDARD_TYPE(AIS_InteractiveObject)))
{
const Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast (anObj);
aCtx->Display (aShape, Standard_False);
} }
else if (anObj->IsKind (STANDARD_TYPE(NIS_InteractiveObject)))
{
Handle(NIS_InteractiveObject) aShape = Handle(NIS_InteractiveObject)::DownCast (anObj);
TheNISContext()->Display (aShape);
}
aDispSet.Add (anObj);
} }
} }
TheAISContext() ->UpdateCurrentViewer();
// TheNISContext() ->UpdateViews();
} }
// weed out other objects
for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS()); anIter.More(); anIter.Next())
{
if (aDispSet.Contains (anIter.Key1()))
{
continue;
}
if (anIter.Key1()->IsKind (STANDARD_TYPE(AIS_InteractiveObject)))
{
const Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1());
aCtx->Erase (aShape, Standard_False);
}
else if (anIter.Key1()->IsKind (STANDARD_TYPE(NIS_InteractiveObject)))
{
const Handle(NIS_InteractiveObject) aShape = Handle(NIS_InteractiveObject)::DownCast (anIter.Key1());
TheNISContext()->Erase (aShape);
}
}
// update the screen and redraw the view
const Standard_Boolean isAutoUpdate = a3DView()->SetImmediateUpdate (Standard_False);
a3DView()->SetImmediateUpdate (isAutoUpdate);
if ((isAutoUpdate && aToUpdate != ViewerTest_RM_RedrawSuppress)
|| aToUpdate == ViewerTest_RM_RedrawForce)
{
TheAISContext()->UpdateCurrentViewer();
}
return 0; return 0;
} }
@ -1612,28 +1665,48 @@ static int VDonly2(Draw_Interpretor& , Standard_Integer argc, const char** argv)
// objects (deleted only from the current context). // objects (deleted only from the current context).
//============================================================================== //==============================================================================
int VRemove (Draw_Interpretor& theDI, int VRemove (Draw_Interpretor& theDI,
Standard_Integer theArgNb, Standard_Integer theArgNb,
const char** theArgVec) const char** theArgVec)
{ {
if (a3DView().IsNull()) if (a3DView().IsNull())
{ {
std::cout << "Error: wrong syntax!\n";
return 1; return 1;
} }
TheAISContext()->CloseAllContexts (Standard_False); TheAISContext()->CloseAllContexts (Standard_False);
//Standard_Boolean isStayedInMap = Standard_False; ViewerTest_RedrawMode aToUpdate = ViewerTest_RM_Auto;
TCollection_AsciiString aContextOnlyStr ("-context"); Standard_Boolean isContextOnly = Standard_False;
TCollection_AsciiString aRemoveAllStr ("-all"); Standard_Boolean toRemoveAll = Standard_False;
Standard_Boolean isContextOnly = (theArgNb > 1 && TCollection_AsciiString (theArgVec[1]) == aContextOnlyStr); Standard_Integer anArgIter = 1;
for (; anArgIter < theArgNb; ++anArgIter)
Standard_Boolean isRemoveAll = (theArgNb == 3 && TCollection_AsciiString (theArgVec[2]) == aRemoveAllStr) || {
(theArgNb == 2 && TCollection_AsciiString (theArgVec[1]) == aRemoveAllStr); TCollection_AsciiString anArg = theArgVec[anArgIter];
anArg.LowerCase();
if (anArg == "-context")
{
isContextOnly = Standard_True;
}
else if (anArg == "-all")
{
toRemoveAll = Standard_True;
}
else if (!parseRedrawMode (anArg, aToUpdate))
{
break;
}
}
if (toRemoveAll
&& anArgIter < theArgNb)
{
std::cout << "Error: wrong syntax!\n";
return 1;
}
NCollection_List<TCollection_AsciiString> anIONameList; NCollection_List<TCollection_AsciiString> anIONameList;
if (toRemoveAll)
if (isRemoveAll)
{ {
for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS()); for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
anIter.More(); anIter.Next()) anIter.More(); anIter.Next())
@ -1641,12 +1714,11 @@ int VRemove (Draw_Interpretor& theDI,
anIONameList.Append (anIter.Key2()); anIONameList.Append (anIter.Key2());
} }
} }
else if (isContextOnly ? theArgNb > 2 : theArgNb > 1) // removed objects names are in argument list else if (anArgIter < theArgNb) // removed objects names are in argument list
{ {
for (Standard_Integer anIt = isContextOnly ? 2 : 1; anIt < theArgNb; ++anIt) for (; anArgIter < theArgNb; ++anArgIter)
{ {
TCollection_AsciiString aName = theArgVec[anIt]; TCollection_AsciiString aName = theArgVec[anArgIter];
if (!GetMapOfAIS().IsBound2 (aName)) if (!GetMapOfAIS().IsBound2 (aName))
{ {
theDI << aName.ToCString() << " was not bound to some object.\n"; theDI << aName.ToCString() << " was not bound to some object.\n";
@ -1711,30 +1783,38 @@ int VRemove (Draw_Interpretor& theDI,
for (NCollection_List<TCollection_AsciiString>::Iterator anIter (anIONameList); for (NCollection_List<TCollection_AsciiString>::Iterator anIter (anIONameList);
anIter.More(); anIter.Next()) anIter.More(); anIter.Next())
{ {
const Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (anIter.Value())); const Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (anIter.Value()));
if (!anIO.IsNull()) if (!anIO.IsNull())
{
TheAISContext()->Remove (anIO, Standard_False);
theDI << anIter.Value().ToCString() << " was removed\n";
}
else
{
const Handle(NIS_InteractiveObject) aNisIO = Handle(NIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (anIter.Value()));
if (!aNisIO.IsNull())
{ {
TheAISContext()->Remove (anIO, Standard_False); TheNISContext()->Remove (aNisIO);
theDI << anIter.Value().ToCString() << " was removed\n"; theDI << anIter.Value().ToCString() << " was removed\n";
} }
else }
{
const Handle(NIS_InteractiveObject) aNisIO = Handle(NIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (anIter.Value()));
if (!aNisIO.IsNull())
{
TheNISContext()->Remove (aNisIO);
theDI << anIter.Value().ToCString() << " was removed\n";
}
}
if (!isContextOnly) if (!isContextOnly)
{ {
GetMapOfAIS().UnBind2 (anIter.Value()); GetMapOfAIS().UnBind2 (anIter.Value());
} }
}
// update the screen and redraw the view
const Standard_Boolean isAutoUpdate = a3DView()->SetImmediateUpdate (Standard_False);
a3DView()->SetImmediateUpdate (isAutoUpdate);
if ((isAutoUpdate && aToUpdate != ViewerTest_RM_RedrawSuppress)
|| aToUpdate == ViewerTest_RM_RedrawForce)
{
TheAISContext()->UpdateCurrentViewer();
} }
TheAISContext()->UpdateCurrentViewer();
return 0; return 0;
} }
@ -1749,21 +1829,33 @@ int VErase (Draw_Interpretor& theDI,
{ {
if (a3DView().IsNull()) if (a3DView().IsNull())
{ {
std::cout << "Error: no active view!\n";
return 1; return 1;
} }
TheAISContext()->CloseAllContexts (Standard_False); TheAISContext()->CloseAllContexts (Standard_False);
const Standard_Boolean isEraseAll = TCollection_AsciiString (theArgNb > 0 ? theArgVec[0] : "").IsEqual ("veraseall");
if (theArgNb > 1) ViewerTest_RedrawMode aToUpdate = ViewerTest_RM_Auto;
const Standard_Boolean toEraseAll = TCollection_AsciiString (theArgNb > 0 ? theArgVec[0] : "") == "veraseall";
Standard_Integer anArgIter = 1;
for (; anArgIter < theArgNb; ++anArgIter)
{ {
if (isEraseAll) if (!parseRedrawMode (theArgVec[anArgIter], aToUpdate))
{ {
std::cerr << " Syntax error: " << theArgVec[0] << " too much arguments.\n"; break;
}
}
if (anArgIter < theArgNb)
{
if (toEraseAll)
{
std::cerr << "Error: wrong syntax, " << theArgVec[0] << " too much arguments.\n";
return 1; return 1;
} }
// has a list of names // has a list of names
for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter) for (; anArgIter < theArgNb; ++anArgIter)
{ {
TCollection_AsciiString aName = theArgVec[anArgIter]; TCollection_AsciiString aName = theArgVec[anArgIter];
if (!GetMapOfAIS().IsBound2 (aName)) if (!GetMapOfAIS().IsBound2 (aName))
@ -1787,12 +1879,9 @@ int VErase (Draw_Interpretor& theDI,
} }
} }
} }
TheAISContext()->UpdateCurrentViewer();
return 0;
} }
else if (!toEraseAll
if (!isEraseAll && TheAISContext()->NbCurrents() > 0)
&& TheAISContext()->NbCurrents() > 0)
{ {
// remove all currently selected objects // remove all currently selected objects
for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS()); for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
@ -1806,30 +1895,38 @@ int VErase (Draw_Interpretor& theDI,
TheAISContext()->Erase (anIO, Standard_False); TheAISContext()->Erase (anIO, Standard_False);
} }
} }
TheAISContext()->UpdateCurrentViewer();
return 0;
} }
else
// erase entire viewer
for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
anIter.More(); anIter.Next())
{ {
const Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1()); // erase entire viewer
if (!anIO.IsNull()) for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
anIter.More(); anIter.Next())
{ {
TheAISContext()->Erase (anIO, Standard_False); const Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1());
} if (!anIO.IsNull())
else
{
const Handle(NIS_InteractiveObject) aNisIO = Handle(NIS_InteractiveObject)::DownCast (anIter.Key1());
if (!aNisIO.IsNull())
{ {
TheNISContext()->Erase (aNisIO); TheAISContext()->Erase (anIO, Standard_False);
}
else
{
const Handle(NIS_InteractiveObject) aNisIO = Handle(NIS_InteractiveObject)::DownCast (anIter.Key1());
if (!aNisIO.IsNull())
{
TheNISContext()->Erase (aNisIO);
}
} }
} }
} }
TheAISContext()->UpdateCurrentViewer();
// update the screen and redraw the view
const Standard_Boolean isAutoUpdate = a3DView()->SetImmediateUpdate (Standard_False);
a3DView()->SetImmediateUpdate (isAutoUpdate);
if ((isAutoUpdate && aToUpdate != ViewerTest_RM_RedrawSuppress)
|| aToUpdate == ViewerTest_RM_RedrawForce)
{
TheAISContext()->UpdateCurrentViewer();
}
return 0; return 0;
} }
@ -1837,45 +1934,78 @@ int VErase (Draw_Interpretor& theDI,
//function : VDisplayAll //function : VDisplayAll
//author : ege //author : ege
//purpose : Display all the objects of the Map //purpose : Display all the objects of the Map
//Draw arg : vdisplayall
//============================================================================== //==============================================================================
static int VDisplayAll( Draw_Interpretor& di, Standard_Integer argc, const char** argv) static int VDisplayAll (Draw_Interpretor& ,
Standard_Integer theArgNb,
const char** theArgVec)
{ {
if (! a3DView().IsNull() ) { if (a3DView().IsNull())
if (argc > 1) {di<<argv[0]<<" Syntaxe error"<<"\n"; return 1;} {
if (TheAISContext()->HasOpenedContext()) std::cout << "Error: no active view!\n";
TheAISContext()->CloseLocalContext(); return 1;
ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName
it (GetMapOfAIS());
while ( it.More() ) {
if (it.Key1()->IsKind(STANDARD_TYPE(AIS_InteractiveObject))) {
const Handle(AIS_InteractiveObject) aShape =
Handle(AIS_InteractiveObject)::DownCast(it.Key1());
TheAISContext()->Erase(aShape,Standard_False);
} else if (it.Key1()->IsKind(STANDARD_TYPE(NIS_InteractiveObject))) {
const Handle(NIS_InteractiveObject) aShape =
Handle(NIS_InteractiveObject)::DownCast(it.Key1());
TheNISContext()->Erase(aShape);
}
it.Next();
}
it.Reset();
while ( it.More() ) {
if (it.Key1()->IsKind(STANDARD_TYPE(AIS_InteractiveObject))) {
const Handle(AIS_InteractiveObject) aShape =
Handle(AIS_InteractiveObject)::DownCast(it.Key1());
TheAISContext()->Display(aShape, Standard_False);
} else if (it.Key1()->IsKind(STANDARD_TYPE(NIS_InteractiveObject))) {
Handle(NIS_InteractiveObject) aShape =
Handle(NIS_InteractiveObject)::DownCast(it.Key1());
TheNISContext()->Display(aShape);
}
it.Next();
}
TheAISContext() ->UpdateCurrentViewer();
// TheNISContext() ->UpdateViews();
} }
ViewerTest_RedrawMode aToUpdate = ViewerTest_RM_Auto;
Standard_Integer anArgIter = 1;
for (; anArgIter < theArgNb; ++anArgIter)
{
if (!parseRedrawMode (theArgVec[anArgIter], aToUpdate))
{
break;
}
}
if (anArgIter < theArgNb)
{
std::cout << theArgVec[0] << "Error: wrong syntax\n";
return 1;
}
if (TheAISContext()->HasOpenedContext())
{
TheAISContext()->CloseLocalContext();
}
for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
anIter.More(); anIter.Next())
{
if (anIter.Key1()->IsKind (STANDARD_TYPE(AIS_InteractiveObject)))
{
const Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1());
TheAISContext()->Erase (aShape, Standard_False);
}
else if (anIter.Key1()->IsKind(STANDARD_TYPE(NIS_InteractiveObject)))
{
const Handle(NIS_InteractiveObject) aShape = Handle(NIS_InteractiveObject)::DownCast (anIter.Key1());
TheNISContext()->Erase (aShape);
}
}
for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
anIter.More(); anIter.Next())
{
if (anIter.Key1()->IsKind (STANDARD_TYPE(AIS_InteractiveObject)))
{
const Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1());
TheAISContext()->Display (aShape, Standard_False);
}
else if (anIter.Key1()->IsKind (STANDARD_TYPE(NIS_InteractiveObject)))
{
Handle(NIS_InteractiveObject) aShape = Handle(NIS_InteractiveObject)::DownCast (anIter.Key1());
TheNISContext()->Display (aShape);
}
}
// update the screen and redraw the view
const Standard_Boolean isAutoUpdate = a3DView()->SetImmediateUpdate (Standard_False);
a3DView()->SetImmediateUpdate (isAutoUpdate);
if ((isAutoUpdate && aToUpdate != ViewerTest_RM_RedrawSuppress)
|| aToUpdate == ViewerTest_RM_RedrawForce)
{
TheAISContext()->UpdateCurrentViewer();
}
return 0; return 0;
} }
@ -2049,74 +2179,89 @@ Standard_Integer VTexture (Draw_Interpretor& di,Standard_Integer argc, const cha
//function : VDisplay2 //function : VDisplay2
//author : ege //author : ege
//purpose : Display an object from its name //purpose : Display an object from its name
//Draw arg : vdisplay name1 [name2] ... [name n]
//============================================================================== //==============================================================================
static int VDisplay2 (Draw_Interpretor& di, Standard_Integer argc, const char** argv) static int VDisplay2 (Draw_Interpretor& theDI,
Standard_Integer theArgNb,
const char** theArgVec)
{ {
// Verification des arguments if (theArgNb < 2)
if ( a3DView().IsNull() ) { {
std::cout << theArgVec[0] << "Error: wrong syntax!\n";
ViewerTest::ViewerInit();
di<<"La commande vinit n'a pas ete appele avant"<<"\n";
// return 1;
}
if ( argc<2) {
di<<argv[0]<<" Syntaxe error"<<"\n";
return 1; return 1;
} }
else if (a3DView().IsNull())
{
ViewerTest::ViewerInit();
std::cout << "Command vinit should be called before!\n";
// return 1;
}
const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
if (aCtx->HasOpenedContext())
{
aCtx->CloseLocalContext();
}
TCollection_AsciiString name; ViewerTest_RedrawMode aToUpdate = ViewerTest_RM_Auto;
if (TheAISContext()->HasOpenedContext()) for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
TheAISContext()->CloseLocalContext(); {
const TCollection_AsciiString aName = theArgVec[anArgIter];
for ( int i = 1; i < argc; i++ ) { if (parseRedrawMode (aName, aToUpdate))
name = argv[i]; {
Standard_Boolean IsBound = GetMapOfAIS().IsBound2(name); continue;
Standard_Boolean IsDatum = Standard_False;
Handle(Standard_Transient) anObj;
if ( IsBound ) {
anObj = GetMapOfAIS().Find2(name);
if (anObj->IsKind(STANDARD_TYPE(AIS_InteractiveObject))) {
Handle(AIS_InteractiveObject) aShape =
Handle(AIS_InteractiveObject)::DownCast(anObj);
if (aShape->Type()==AIS_KOI_Datum) {
IsDatum = Standard_True;
TheAISContext()->Display(aShape, Standard_False);
}
if (!IsDatum) {
di << "Display " << name.ToCString() << "\n";
// Get the Shape from a name
TopoDS_Shape NewShape = GetShapeFromName((const char *)name.ToCString());
// Update the Shape in the AIS_Shape
Handle(AIS_Shape) TheRealSh = Handle(AIS_Shape)::DownCast(aShape);
if(!TheRealSh.IsNull())
TheRealSh->Set(NewShape);
TheAISContext()->Redisplay(aShape, Standard_False);
TheAISContext()->Display(aShape, Standard_False);
}
aShape.Nullify();
} else if (anObj->IsKind(STANDARD_TYPE(NIS_InteractiveObject))) {
Handle(NIS_InteractiveObject) aShape =
Handle(NIS_InteractiveObject)::DownCast(anObj);
TheNISContext()->Display(aShape);
}
} }
else { // Create the AIS_Shape from a name else if (!GetMapOfAIS().IsBound2 (aName))
const Handle(AIS_InteractiveObject) aShape = {
GetAISShapeFromName((const char *)name.ToCString()); // create the AIS_Shape from a name
if ( !aShape.IsNull() ) { const Handle(AIS_InteractiveObject) aShape = GetAISShapeFromName (aName.ToCString());
GetMapOfAIS().Bind(aShape, name); if (!aShape.IsNull())
TheAISContext()->Display(aShape, Standard_False); {
GetMapOfAIS().Bind (aShape, aName);
aCtx->Display (aShape, Standard_False);
} }
continue;
}
Handle(Standard_Transient) anObj = GetMapOfAIS().Find2 (aName);
if (anObj->IsKind (STANDARD_TYPE (AIS_InteractiveObject)))
{
Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast (anObj);
if (aShape->Type() == AIS_KOI_Datum)
{
aCtx->Display (aShape, Standard_False);
}
else
{
theDI << "Display " << aName.ToCString() << "\n";
// get the Shape from a name
TopoDS_Shape aNewShape = GetShapeFromName (aName.ToCString());
// update the Shape in the AIS_Shape
Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast(aShape);
if (!aShapePrs.IsNull())
{
aShapePrs->Set (aNewShape);
}
aCtx->Redisplay (aShape, Standard_False);
aCtx->Display (aShape, Standard_False);
}
aShape.Nullify();
}
else if (anObj->IsKind (STANDARD_TYPE (NIS_InteractiveObject)))
{
Handle(NIS_InteractiveObject) aShape = Handle(NIS_InteractiveObject)::DownCast (anObj);
TheNISContext()->Display (aShape);
} }
} }
// Upadate the screen and redraw the view
TheAISContext()->UpdateCurrentViewer(); const Standard_Boolean isAutoUpdate = a3DView()->SetImmediateUpdate (Standard_False);
// TheNISContext()->UpdateViews(); a3DView()->SetImmediateUpdate (isAutoUpdate);
if ((isAutoUpdate && aToUpdate != ViewerTest_RM_RedrawSuppress)
|| aToUpdate == ViewerTest_RM_RedrawForce)
{
// update the screen and redraw the view
aCtx->UpdateCurrentViewer();
}
return 0; return 0;
} }
@ -3419,8 +3564,9 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands)
__FILE__, visos, group); __FILE__, visos, group);
theCommands.Add("vdisplay", theCommands.Add("vdisplay",
"vdisplay name1 [name2] ... [name n]" "vdisplay [-noupdate|-update] name1 [name2] ... [name n]"
"\n\t\t: Displays named objects", "\n\t\t: Displays named objects."
"\n\t\t: Option -noupdate suppresses viewer redraw call."
__FILE__,VDisplay2,group); __FILE__,VDisplay2,group);
theCommands.Add ("vupdate", theCommands.Add ("vupdate",
@ -3429,21 +3575,22 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands)
__FILE__, VUpdate, group); __FILE__, VUpdate, group);
theCommands.Add("verase", theCommands.Add("verase",
"verase [name1] ... [name n]" "verase [-noupdate|-update] [name1] ... [name n]"
"\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.",
__FILE__, VErase, group); __FILE__, VErase, group);
theCommands.Add("vremove", theCommands.Add("vremove",
"vremove [-context] [name1] ... [name n]" "vremove [-noupdate|-update] [-context] [-all] [name1] ... [name n]"
"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"
"\n\t\t from the map of objects and names.", "\n\t\t from the map of objects and names."
"\n\t\t: Option -noupdate suppresses viewer redraw call.",
__FILE__, VRemove, group); __FILE__, VRemove, group);
theCommands.Add("vdonly", theCommands.Add("vdonly",
"vdonly [name1] ... [name n]" "vdonly [-noupdate|-update] [name1] ... [name n]"
"\n\t\t: Displays only selected or named objects", "\n\t\t: Displays only selected or named objects",
__FILE__,VDonly2,group); __FILE__,VDonly2,group);
@ -3484,7 +3631,7 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands)
theCommands.Add("vdir", theCommands.Add("vdir",
"Lists all objects displayed in 3D viewer", "Lists all objects displayed in 3D viewer",
__FILE__,VDebug,group); __FILE__,VDir,group);
theCommands.Add("vdump", theCommands.Add("vdump",
#ifdef HAVE_FREEIMAGE #ifdef HAVE_FREEIMAGE