#include <Standard_Stream.hxx>
#include <ViewerTest.hxx>
+
#include <TopLoc_Location.hxx>
#include <TopTools_HArray1OfShape.hxx>
#include <TColStd_HArray1OfTransient.hxx>
#include <Prs3d_ShadingAspect.hxx>
#include <Prs3d_IsoAspect.hxx>
#include <TopTools_MapOfShape.hxx>
+#include <ViewerTest_AutoUpdater.hxx>
#include <stdio.h>
#include <Draw_Interpretor.hxx>
#include <TCollection_AsciiString.hxx>
#include <Draw_PluginMacro.hxx>
-#include <ViewerTest.hxx>
// avoid warnings on 'extern "C"' functions returning C++ classes
#ifdef WNT
#define DEFAULT_COLOR Quantity_NOC_GOLDENROD
#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
//purpose : get the Quantity_NameOfColor from a string
const char** theArgVec)
{
const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
+ ViewerTest_AutoUpdater anUpdateTool (aCtx, ViewerTest::CurrentView());
if (aCtx.IsNull())
{
std::cerr << "Error: no active view!\n";
return 1;
}
- ViewerTest_RedrawMode aToUpdate = ViewerTest_RM_Auto;
- Standard_Integer anArgIter = 1;
+ Standard_Integer anArgIter = 1;
for (; anArgIter < theArgNb; ++anArgIter)
{
- if (!parseRedrawMode (theArgVec[anArgIter], aToUpdate))
+ if (!anUpdateTool.parseRedrawMode (theArgVec[anArgIter]))
{
break;
}
aCtx->RecomputePrsOnly (anIO, Standard_False, Standard_True);
}
}
-
- // 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;
}
{
TCollection_AsciiString aCmdName (theArgVec[0]);
const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
+ ViewerTest_AutoUpdater anUpdateTool (aCtx, ViewerTest::CurrentView());
if (aCtx.IsNull())
{
std::cerr << "Error: no active view!\n";
return 1;
}
- ViewerTest_RedrawMode aToUpdate = ViewerTest_RM_Auto;
- Standard_Integer anArgIter = 1;
+ Standard_Integer anArgIter = 1;
NCollection_Sequence<TCollection_AsciiString> aNames;
for (; anArgIter < theArgNb; ++anArgIter)
{
TCollection_AsciiString anArg = theArgVec[anArgIter];
- if (parseRedrawMode (anArg, aToUpdate))
+ if (anUpdateTool.parseRedrawMode (anArg))
{
continue;
}
}
}
}
-
- // 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;
}
const char** theArgVec)
{
const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
+ ViewerTest_AutoUpdater anUpdateTool (aCtx, ViewerTest::CurrentView());
if (aCtx.IsNull())
{
std::cerr << "Error: no active view!\n";
{
aCtx->CloseLocalContext();
}
- ViewerTest_RedrawMode aToUpdate = ViewerTest_RM_Auto;
Standard_Integer anArgIter = 1;
for (; anArgIter < theArgNb; ++anArgIter)
{
- if (!parseRedrawMode (theArgVec[anArgIter], aToUpdate))
+ if (!anUpdateTool.parseRedrawMode (theArgVec[anArgIter]))
{
break;
}
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;
}
Standard_Integer theArgNb,
const char** theArgVec)
{
- if (a3DView().IsNull())
+ const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
+ ViewerTest_AutoUpdater anUpdateTool (aCtx, ViewerTest::CurrentView());
+ if (aCtx.IsNull())
{
- std::cout << "Error: wrong syntax!\n";
+ std::cout << "Error: no active view!\n";
return 1;
}
- TheAISContext()->CloseAllContexts (Standard_False);
+ aCtx->CloseAllContexts (Standard_False);
- ViewerTest_RedrawMode aToUpdate = ViewerTest_RM_Auto;
- Standard_Boolean isContextOnly = Standard_False;
- Standard_Boolean toRemoveAll = Standard_False;
- Standard_Boolean toPrintInfo = Standard_True;
+ Standard_Boolean isContextOnly = Standard_False;
+ Standard_Boolean toRemoveAll = Standard_False;
+ Standard_Boolean toPrintInfo = Standard_True;
Standard_Integer anArgIter = 1;
for (; anArgIter < theArgNb; ++anArgIter)
{
toPrintInfo = Standard_False;
}
- else if (!parseRedrawMode (anArg, aToUpdate))
+ else if (!anUpdateTool.parseRedrawMode (anArg))
{
break;
}
const Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (aTransientObj);
if (!anIO.IsNull())
{
- if (anIO->GetContext() != TheAISContext())
+ if (anIO->GetContext() != aCtx)
{
theDI << aName.ToCString() << " was not displayed in current context.\n";
theDI << "Please activate view with this object displayed and try again.\n";
}
}
}
- else if (TheAISContext()->NbCurrents() > 0
+ else if (aCtx->NbCurrents() > 0
|| TheNISContext()->GetSelected().Extent() > 0)
{
for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
const Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1());
if (!anIO.IsNull())
{
- if (!TheAISContext()->IsCurrent (anIO))
+ if (!aCtx->IsCurrent (anIO))
{
continue;
}
const Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (anIter.Value()));
if (!anIO.IsNull())
{
- TheAISContext()->Remove (anIO, Standard_False);
+ aCtx->Remove (anIO, Standard_False);
if (toPrintInfo)
{
theDI << anIter.Value().ToCString() << " was removed\n";
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();
- }
-
return 0;
}
Standard_Integer theArgNb,
const char** theArgVec)
{
- if (a3DView().IsNull())
+ const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
+ ViewerTest_AutoUpdater anUpdateTool (aCtx, ViewerTest::CurrentView());
+ if (aCtx.IsNull())
{
std::cout << "Error: no active view!\n";
return 1;
}
- TheAISContext()->CloseAllContexts (Standard_False);
+ aCtx->CloseAllContexts (Standard_False);
- 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 (!parseRedrawMode (theArgVec[anArgIter], aToUpdate))
+ if (!anUpdateTool.parseRedrawMode (theArgVec[anArgIter]))
{
break;
}
theDI << aName.ToCString() << " ";
if (!anIO.IsNull())
{
- TheAISContext()->Erase (anIO, Standard_False);
+ aCtx->Erase (anIO, Standard_False);
}
else
{
}
}
else if (!toEraseAll
- && TheAISContext()->NbCurrents() > 0)
+ && aCtx->NbCurrents() > 0)
{
// remove all currently selected objects
for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
{
const Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1());
if (!anIO.IsNull()
- && TheAISContext()->IsCurrent (anIO))
+ && aCtx->IsCurrent (anIO))
{
theDI << anIter.Key2().ToCString() << " ";
- TheAISContext()->Erase (anIO, Standard_False);
+ aCtx->Erase (anIO, Standard_False);
}
}
}
const Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1());
if (!anIO.IsNull())
{
- TheAISContext()->Erase (anIO, Standard_False);
+ aCtx->Erase (anIO, Standard_False);
}
else
{
}
}
}
-
- // 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;
}
const char** theArgVec)
{
- if (a3DView().IsNull())
+ const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
+ ViewerTest_AutoUpdater anUpdateTool (aCtx, ViewerTest::CurrentView());
+ if (aCtx.IsNull())
{
std::cout << "Error: no active view!\n";
return 1;
}
- ViewerTest_RedrawMode aToUpdate = ViewerTest_RM_Auto;
-
Standard_Integer anArgIter = 1;
for (; anArgIter < theArgNb; ++anArgIter)
{
- if (!parseRedrawMode (theArgVec[anArgIter], aToUpdate))
+ if (!anUpdateTool.parseRedrawMode (theArgVec[anArgIter]))
{
break;
}
return 1;
}
- if (TheAISContext()->HasOpenedContext())
+ if (aCtx->HasOpenedContext())
{
- TheAISContext()->CloseLocalContext();
+ aCtx->CloseLocalContext();
}
for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
if (anIter.Key1()->IsKind (STANDARD_TYPE(AIS_InteractiveObject)))
{
const Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1());
- TheAISContext()->Erase (aShape, Standard_False);
+ aCtx->Erase (aShape, Standard_False);
}
else if (anIter.Key1()->IsKind(STANDARD_TYPE(NIS_InteractiveObject)))
{
if (anIter.Key1()->IsKind (STANDARD_TYPE(AIS_InteractiveObject)))
{
const Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1());
- TheAISContext()->Display (aShape, Standard_False);
+ aCtx->Display (aShape, Standard_False);
}
else if (anIter.Key1()->IsKind (STANDARD_TYPE(NIS_InteractiveObject)))
{
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;
}
const char** theArgVec)
{
Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
+ ViewerTest_AutoUpdater anUpdateTool (aCtx, ViewerTest::CurrentView());
if (aCtx.IsNull())
{
std::cout << "Error: no active view!\n";
return 1;
}
- ViewerTest_RedrawMode aToUpdate = ViewerTest_RM_Auto;
- ViewerTest_BndAction anAction = BndAction_Show;
- Standard_Integer aMode = -1;
+ ViewerTest_BndAction anAction = BndAction_Show;
+ Standard_Integer aMode = -1;
Standard_Integer anArgIter = 1;
for (; anArgIter < theArgNb; ++anArgIter)
}
aMode = Draw::Atoi (theArgVec[anArgIter]);
}
- else if (!parseRedrawMode (anArg, aToUpdate))
+ else if (!anUpdateTool.parseRedrawMode (anArg))
{
break;
}
bndPresentation (theDI, aPrs, aName, anAction);
}
}
- else if (TheAISContext()->NbCurrents() > 0)
+ else if (aCtx->NbCurrents() > 0)
{
// remove all currently selected objects
for (aCtx->InitCurrent(); aCtx->MoreCurrent(); aCtx->NextCurrent())
}
}
}
-
- // 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;
}
Standard_Integer theArgNb,
const char** theArgVec)
{
+ Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
if (theArgNb < 2)
{
std::cout << theArgVec[0] << "Error: wrong syntax!\n";
return 1;
}
- else if (a3DView().IsNull())
+ else if (aCtx.IsNull())
{
ViewerTest::ViewerInit();
std::cout << "Command vinit should be called before!\n";
// return 1;
+ aCtx = ViewerTest::GetAISContext();
}
- const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
+ ViewerTest_AutoUpdater anUpdateTool (aCtx, ViewerTest::CurrentView());
if (aCtx->HasOpenedContext())
{
aCtx->CloseLocalContext();
}
- ViewerTest_RedrawMode aToUpdate = ViewerTest_RM_Auto;
- Standard_Integer isMutable = -1;
+ Standard_Integer isMutable = -1;
for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
{
const TCollection_AsciiString aName = theArgVec[anArgIter];
TCollection_AsciiString aNameCase = aName;
aNameCase.LowerCase();
- if (parseRedrawMode (aName, aToUpdate))
+ if (anUpdateTool.parseRedrawMode (aName))
{
continue;
}
TheNISContext()->Display (aShape);
}
}
-
- const Standard_Boolean isAutoUpdate = a3DView()->SetImmediateUpdate (Standard_False);
- a3DView()->SetImmediateUpdate (isAutoUpdate);
- if ((isAutoUpdate && aToUpdate != ViewerTest_RM_RedrawSuppress)
- || aToUpdate == ViewerTest_RM_RedrawForce)
- {
- // update the screen and redraw the view
- aCtx->UpdateCurrentViewer();
- }
return 0;
}