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
#include <BOPTest.hxx>
#include <BRepTest.hxx>
#include <DBRep.hxx>
+#include <Draw.hxx>
#include <Draw_Interpretor.hxx>
#include <Draw_PluginMacro.hxx>
#include <GeometryTest.hxx>
}
// output message with list of shapes
- Message::DefaultMessenger()->Send (aText, anAlertTypes[iGravity]);
+ Draw_Interpretor& aDrawInterpretor = Draw::GetInterpretor();
+ aDrawInterpretor << aText << "\n";
}
}
}
static Standard_Integer XProgress (Draw_Interpretor& di, Standard_Integer argc, const char **argv)
{
- for ( Standard_Integer i=1; i < argc; i++ ) {
+ for ( Standard_Integer i=1; i < argc; i++ )
+ {
Standard_Boolean turn = Standard_True;
if ( argv[i][0] == '-' ) turn = Standard_False;
else if ( argv[i][0] != '+' ) continue;
- if ( argv[i][1] == 't' ) Draw_ProgressIndicator::DefaultTextMode() = turn;
+
+ TCollection_AsciiString anArgCase (argv[i]);
+ anArgCase.LowerCase();
+ if (anArgCase == "-tcloutput")
+ {
+ Draw_ProgressIndicator::DefaultTclOutput() = Standard_True;
+ return 0;
+ }
+ else if ( argv[i][1] == 't' ) Draw_ProgressIndicator::DefaultTextMode() = turn;
else if ( argv[i][1] == 'g' ) Draw_ProgressIndicator::DefaultGraphMode() = turn;
- else if ( ! strcmp ( argv[i], "-stop" ) && i+1 < argc ) {
+ else if ( ! strcmp ( argv[i], "-stop" ) && i+1 < argc )
+ {
Standard_Address aPtr = 0;
if (sscanf (argv[++i], "%p", &aPtr) == 1)
Draw_ProgressIndicator::StopIndicator() = aPtr;
__FILE__,purgemmgt,g);
// Add command for DRAW-specific ProgressIndicator
- theCommands.Add ( "XProgress","XProgress [+|-t] [+|-g]: switch on/off textual and graphical mode of Progress Indicator",XProgress,"DE: General");
+ theCommands.Add ( "XProgress",
+ "XProgress [+|-t] [+|-g] [-tclOutput]"
+ "\n\t\t: The options are:"
+ "\n\t\t: +|-t, +|-g : switch on/off textual and graphical mode of Progress Indicator"
+ "\n\t\t: -tclOutput : switch on data output mode in tcl"
+ "\n\t\t: Allows to control the output form of Progress Indicator",
+ XProgress,"DE: General");
theCommands.Add("binsave", "binsave shape filename\n"
"\t\tsave the shape in the binary format file",
#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);
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 ),
{
Message_ProgressIndicator::Reset();
if ( myShown ) {
- ((Draw_Interpretor*)myDraw)->Eval ( "destroy .xprogress" );
+ myDraw->Eval ( "destroy .xprogress" );
myShown = Standard_False;
}
myBreak = Standard_False;
"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;
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 :
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;
}
//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;
//! 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;
//! 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();
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;
// test behavior of progress indicator when using nested scopes with names set by Sentry objects
Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator (di, 1);
aProgress->SetTextMode (Standard_True);
+ aProgress->SetTclOutput (Standard_True);
// Outer cycle
Message_ProgressSentry anOuter (aProgress, "Outer", 0, nbOuter, 1);
#include <BRepPrimAPI_MakeSphere.hxx>
#include <DBRep.hxx>
#include <Draw_Interpretor.hxx>
+#include <Draw_Printer.hxx>
#include <DrawTrSurf.hxx>
#include <GCE2d_MakeSegment.hxx>
#include <Geom2d_TrimmedCurve.hxx>
#include <gp_Quaternion.hxx>
#include <Image_Color.hxx>
#include <Image_PixMap.hxx>
+#include <Message.hxx>
+#include <Message_Messenger.hxx>
+#include <Message_PrinterOStream.hxx>
#include <NCollection_Handle.hxx>
#include <NCollection_IncAllocator.hxx>
#include <NCollection_Map.hxx>
return 1;
}
- writer.Write(argv[1]);
+ const Handle(Message_Messenger)& aMsgMgr = Message::DefaultMessenger();
+ Message_SequenceOfPrinters aPrinters;
+ aPrinters.Append (aMsgMgr->ChangePrinters());
+ aMsgMgr->AddPrinter (new Draw_Printer (di));
+
+ writer.Write (argv[1]);
+
+ aMsgMgr->RemovePrinters (STANDARD_TYPE(Draw_Printer));
+ aMsgMgr->ChangePrinters().Append (aPrinters);
+
return 0;
}
return 1;
}
+ const Handle(Message_Messenger)& aMsgMgr = Message::DefaultMessenger();
+ Message_SequenceOfPrinters aPrinters;
+ aPrinters.Append (aMsgMgr->ChangePrinters());
+ aMsgMgr->AddPrinter (new Draw_Printer (di));
+
writer.Write (argv[1]);
+
+ aMsgMgr->RemovePrinters (STANDARD_TYPE(Draw_Printer));
+ aMsgMgr->ChangePrinters().Append (aPrinters);
+
return 0;
}
#include <DBRep.hxx>
#include <Draw_Appli.hxx>
+#include <Draw_Printer.hxx>
#include <IFSelect_Functions.hxx>
#include <IFSelect_SessionPilot.hxx>
#include <Interface_InterfaceModel.hxx>
#include <Interface_Macros.hxx>
#include <Interface_Protocol.hxx>
#include <Message.hxx>
+#include <Message_Messenger.hxx>
+#include <Message_PrinterOStream.hxx>
#include <Standard_Transient.hxx>
#include <TCollection_AsciiString.hxx>
#include <TColStd_HSequenceOfAsciiString.hxx>
static Handle(IFSelect_SessionPilot) thepilot; // detient Session, Model
-static Standard_Integer XSTEPDRAWRUN (Draw_Interpretor& , Standard_Integer argc, const char** argv)
+static Standard_Integer XSTEPDRAWRUN (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
TCollection_AsciiString mess;
for (Standard_Integer i = 0; i < argc; i ++) {
mess.AssignCat(argv[i]); mess.AssignCat(" ");
}
+ const Handle(Message_Messenger)& aMsgMgr = Message::DefaultMessenger();
+ Message_SequenceOfPrinters aPrinters;
+ aPrinters.Append (aMsgMgr->ChangePrinters());
+ aMsgMgr->AddPrinter (new Draw_Printer (di));
+
IFSelect_ReturnStatus stat = thepilot->Execute (mess.ToCString());
+
+ aMsgMgr->RemovePrinters (STANDARD_TYPE(Draw_Printer));
+ aMsgMgr->ChangePrinters().Append (aPrinters);
+
if (stat == IFSelect_RetError || stat == IFSelect_RetFail) return 1;
else return 0;
}
restore [locate_data_file OCC22765.brep] a
vinit
+XProgress -tclOutput
XProgress -t
set List1 [sewing result 0.1 a]
if { [string compare $List1 ""] != 0 } {
catch { pload XSDRAW }
vinit
+XProgress -tclOutput
XProgress -t
set List1 [meshfromstl result [locate_data_file bearing.stl]]
puts "----------------------"
catch { pload XSDRAW }
restore [locate_data_file OCC22746-om.brep] a
vinit
+XProgress -tclOutput
XProgress -t
set List1 [fixshape result a]
puts "----------------------"
catch { pload XSDRAW }
restore [locate_data_file OCC22746-trampafus-notfixed.brep] a
vinit
+XProgress -tclOutput
XProgress -t
set List1 [fixshape result a]
puts "----------------------"
restore [locate_data_file OCC22761-TransmissionTestModel5-notfixed.brep] a
vinit
+XProgress -tclOutput
XProgress -t
set List1 [fixshape result a]
puts "----------------------"