1 // Created on: 2014-04-24
2 // Created by: Kirill Gavrilov
3 // Copyright (c) 2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <ViewerTest_AutoUpdater.hxx>
18 //=======================================================================
19 //function : ViewerTest_AutoUpdater
21 //=======================================================================
22 ViewerTest_AutoUpdater::ViewerTest_AutoUpdater (const Handle(AIS_InteractiveContext)& theContext,
23 const Handle(V3d_View)& theView)
24 : myContext (theContext),
26 myToUpdate (RedrawMode_Auto),
27 myWasAutoUpdate (Standard_False)
29 if (!theView.IsNull())
31 myWasAutoUpdate = theView->SetImmediateUpdate (Standard_False);
35 //=======================================================================
36 //function : ~ViewerTest_AutoUpdater
38 //=======================================================================
39 ViewerTest_AutoUpdater::~ViewerTest_AutoUpdater()
44 //=======================================================================
45 //function : parseRedrawMode
47 //=======================================================================
48 Standard_Boolean ViewerTest_AutoUpdater::parseRedrawMode (const TCollection_AsciiString& theArg)
50 TCollection_AsciiString anArgCase (theArg);
51 anArgCase.LowerCase();
52 if (anArgCase == "-update"
53 || anArgCase == "-redraw")
55 myToUpdate = RedrawMode_Forced;
58 else if (anArgCase == "-noupdate"
59 || anArgCase == "-noredraw")
61 myToUpdate = RedrawMode_Suppressed;
64 return Standard_False;
67 //=======================================================================
68 //function : Invalidate
70 //=======================================================================
71 void ViewerTest_AutoUpdater::Invalidate()
73 myToUpdate = ViewerTest_AutoUpdater::RedrawMode_Suppressed;
77 myView->SetImmediateUpdate (myWasAutoUpdate);
81 //=======================================================================
84 //=======================================================================
85 void ViewerTest_AutoUpdater::Update()
89 myView->SetImmediateUpdate (myWasAutoUpdate);
94 case ViewerTest_AutoUpdater::RedrawMode_Suppressed:
98 case ViewerTest_AutoUpdater::RedrawMode_Auto:
100 if (!myWasAutoUpdate)
106 case ViewerTest_AutoUpdater::RedrawMode_Forced:
108 if (!myContext.IsNull())
110 myContext->UpdateCurrentViewer();
112 else if (!myView.IsNull())