mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0030697: Draw Harness - Draw_Printer should not be set to Message::DefaultMessenger() by default
Fixed bugs that occurred when using the default std::cout from Message::DefaultMessenger() instead of Draw_Printer A dedicated option was added to Draw_ProgressIndicator, for outputting data to the tcl when performing tests Added -tclOutput parameter to XProgress command
This commit is contained in:
@@ -17,29 +17,11 @@
|
||||
|
||||
#include <Draw.hxx>
|
||||
#include <Draw_Drawable3D.hxx>
|
||||
#include <Draw_Printer.hxx>
|
||||
#include <Draw_ProgressIndicator.hxx>
|
||||
#include <Message.hxx>
|
||||
#include <Message_Messenger.hxx>
|
||||
#include <Message_PrinterOStream.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
|
||||
void Draw::Commands (Draw_Interpretor& theCommands)
|
||||
{
|
||||
static Standard_Boolean isFirstTime = Standard_True;
|
||||
if (isFirstTime)
|
||||
{
|
||||
// override default std::cout printer by draw interpretor printer
|
||||
const Handle(Message_Messenger)& aMsgMgr = Message::DefaultMessenger();
|
||||
if (!aMsgMgr.IsNull())
|
||||
{
|
||||
aMsgMgr->RemovePrinters (STANDARD_TYPE (Message_PrinterOStream));
|
||||
aMsgMgr->RemovePrinters (STANDARD_TYPE (Draw_Printer));
|
||||
aMsgMgr->AddPrinter (new Draw_Printer (theCommands));
|
||||
}
|
||||
isFirstTime = Standard_False;
|
||||
}
|
||||
|
||||
Draw::BasicCommands(theCommands);
|
||||
Draw::VariableCommands(theCommands);
|
||||
Draw::GraphicCommands(theCommands);
|
||||
|
@@ -31,7 +31,8 @@ IMPLEMENT_STANDARD_RTTIEXT(Draw_ProgressIndicator,Message_ProgressIndicator)
|
||||
Draw_ProgressIndicator::Draw_ProgressIndicator (const Draw_Interpretor &di, Standard_Real theUpdateThreshold)
|
||||
: myTextMode ( DefaultTextMode() ),
|
||||
myGraphMode ( DefaultGraphMode() ),
|
||||
myDraw ( (Standard_Address)&di ),
|
||||
myTclOutput ( DefaultTclOutput() ),
|
||||
myDraw ( (Draw_Interpretor*)&di ),
|
||||
myShown ( Standard_False ),
|
||||
myBreak ( Standard_False ),
|
||||
myUpdateThreshold ( 0.01 * theUpdateThreshold ),
|
||||
@@ -59,7 +60,7 @@ void Draw_ProgressIndicator::Reset()
|
||||
{
|
||||
Message_ProgressIndicator::Reset();
|
||||
if ( myShown ) {
|
||||
((Draw_Interpretor*)myDraw)->Eval ( "destroy .xprogress" );
|
||||
myDraw->Eval ( "destroy .xprogress" );
|
||||
myShown = Standard_False;
|
||||
}
|
||||
myBreak = Standard_False;
|
||||
@@ -145,7 +146,7 @@ Standard_Boolean Draw_ProgressIndicator::Show(const Standard_Boolean force)
|
||||
"message .xprogress.text -width 400 -text \"Progress 0%%\";"
|
||||
"button .xprogress.stop -text \"Break\" -relief groove -width 9 -command {XProgress -stop %p};"
|
||||
"pack .xprogress.bar .xprogress.text .xprogress.stop -side top;", this );
|
||||
((Draw_Interpretor*)myDraw)->Eval ( command );
|
||||
myDraw->Eval ( command );
|
||||
myShown = Standard_True;
|
||||
}
|
||||
std::stringstream aCommand;
|
||||
@@ -155,16 +156,24 @@ Standard_Boolean Draw_ProgressIndicator::Show(const Standard_Boolean force)
|
||||
aCommand << ".xprogress.bar coords progress_next 2 2 " << (1 + 400 * GetScope(1).GetLast()) << " 21;";
|
||||
aCommand << ".xprogress.text configure -text \"" << aText.str() << "\";";
|
||||
aCommand << "update";
|
||||
((Draw_Interpretor*)myDraw)->Eval (aCommand.str().c_str());
|
||||
myDraw->Eval (aCommand.str().c_str());
|
||||
}
|
||||
|
||||
// Print textual progress info
|
||||
if ( myTextMode )
|
||||
Message::DefaultMessenger()->Send (aText.str().c_str(), Message_Info);
|
||||
|
||||
if (myTextMode)
|
||||
{
|
||||
if (myTclOutput && myDraw)
|
||||
{
|
||||
*myDraw << aText.str().c_str() << "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << aText.str().c_str() << "\n";
|
||||
}
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : UserBreak
|
||||
//purpose :
|
||||
@@ -175,7 +184,7 @@ Standard_Boolean Draw_ProgressIndicator::UserBreak()
|
||||
if ( StopIndicator() == this ) {
|
||||
// std::cout << "Progress Indicator - User Break: " << StopIndicator() << ", " << (void*)this << std::endl;
|
||||
myBreak = Standard_True;
|
||||
((Draw_Interpretor*)myDraw)->Eval ( "XProgress -stop 0" );
|
||||
myDraw->Eval ( "XProgress -stop 0" );
|
||||
}
|
||||
return myBreak;
|
||||
}
|
||||
@@ -225,29 +234,40 @@ Standard_Boolean Draw_ProgressIndicator::GetGraphMode() const
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean &Draw_ProgressIndicator::DefaultTextMode ()
|
||||
Standard_Boolean &Draw_ProgressIndicator::DefaultTextMode()
|
||||
{
|
||||
static Standard_Boolean defTextMode = Standard_False;
|
||||
return defTextMode;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DefaultGraphMode
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean &Draw_ProgressIndicator::DefaultGraphMode ()
|
||||
Standard_Boolean &Draw_ProgressIndicator::DefaultGraphMode()
|
||||
{
|
||||
static Standard_Boolean defGraphMode = Standard_False;
|
||||
return defGraphMode;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DefaultTclOutput
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean &Draw_ProgressIndicator::DefaultTclOutput()
|
||||
{
|
||||
static Standard_Boolean defTclOutput = Standard_False;
|
||||
return defTclOutput;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : StopIndicator
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Address &Draw_ProgressIndicator::StopIndicator ()
|
||||
Standard_Address &Draw_ProgressIndicator::StopIndicator()
|
||||
{
|
||||
static Standard_Address stopIndicator = 0;
|
||||
return stopIndicator;
|
||||
|
@@ -54,7 +54,13 @@ public:
|
||||
|
||||
//! Gets graphical output mode (on/off)
|
||||
Standard_EXPORT Standard_Boolean GetGraphMode() const;
|
||||
|
||||
|
||||
//! Sets tcl output mode (on/off)
|
||||
void SetTclOutput (const Standard_Boolean theTclOutput) { myTclOutput = theTclOutput; }
|
||||
|
||||
//! Gets tcl output mode (on/off)
|
||||
Standard_Boolean GetTclOutput() const { return myTclOutput; }
|
||||
|
||||
//! Clears/erases opened TCL windows if any
|
||||
//! and sets myBreak to False
|
||||
Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
|
||||
@@ -69,7 +75,10 @@ public:
|
||||
|
||||
//! Get/Set default values for output modes
|
||||
Standard_EXPORT static Standard_Boolean& DefaultGraphMode();
|
||||
|
||||
|
||||
//! Get/Set default values for tcl output mode
|
||||
Standard_EXPORT static Standard_Boolean& DefaultTclOutput();
|
||||
|
||||
//! Internal method for implementation of UserBreak mechanism;
|
||||
//! note that it uses static variable and thus not thread-safe!
|
||||
Standard_EXPORT static Standard_Address& StopIndicator();
|
||||
@@ -79,7 +88,8 @@ public:
|
||||
private:
|
||||
Standard_Boolean myTextMode;
|
||||
Standard_Boolean myGraphMode;
|
||||
Standard_Address myDraw;
|
||||
Standard_Boolean myTclOutput;
|
||||
Draw_Interpretor* myDraw;
|
||||
Standard_Boolean myShown;
|
||||
Standard_Boolean myBreak;
|
||||
Standard_Real myUpdateThreshold;
|
||||
|
Reference in New Issue
Block a user