mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-04 13:13:25 +03:00
0024644: Draw_Printer - provide the way to control messages gravity filter
Message_Printer - define GetTraceLevel()/SetTraceLevel() methods in base interface. Implement message gravity filter in Draw_Printer. Add new Draw Harness command dtracelevel to show/change message gravity filter. Redirect default messenger to Draw_Printer within TKDraw instead of TKXSDRAW Draw::Commands() - assign Draw_Printer only once
This commit is contained in:
@@ -15,42 +15,59 @@
|
||||
|
||||
deferred class Printer from Message inherits TShared from MMgt
|
||||
|
||||
---Purpose: Abstract interface class defining printer as output context for
|
||||
-- text messages
|
||||
--
|
||||
-- The message, besides being text string, has associated gravity
|
||||
-- level, which can be used by printer to decide either to process
|
||||
-- a message or ignore it.
|
||||
---Purpose: Abstract interface class defining printer as output context for text messages
|
||||
--
|
||||
-- The message, besides being text string, has associated gravity
|
||||
-- level, which can be used by printer to decide either to process a message or ignore it.
|
||||
|
||||
uses
|
||||
|
||||
Gravity from Message,
|
||||
AsciiString from TCollection,
|
||||
ExtendedString from TCollection
|
||||
|
||||
Gravity from Message,
|
||||
AsciiString from TCollection,
|
||||
ExtendedString from TCollection
|
||||
|
||||
is
|
||||
|
||||
Send (me; theString: ExtendedString from TCollection;
|
||||
theGravity: Gravity from Message;
|
||||
putEndl: Boolean) is deferred;
|
||||
---Purpose: Send a string message with specified trace level.
|
||||
-- The parameter putEndl specified whether end-of-line
|
||||
-- should be added to the end of the message.
|
||||
-- This method must be redefined in descentant.
|
||||
Initialize returns Printer from Message;
|
||||
---Purpose: Empty constructor with Message_Info trace level
|
||||
|
||||
Send (me; theString: CString; theGravity: Gravity from Message;
|
||||
putEndl: Boolean) is virtual;
|
||||
---Purpose: Send a string message with specified trace level.
|
||||
-- The parameter putEndl specified whether end-of-line
|
||||
-- should be added to the end of the message.
|
||||
-- Default implementation calls first method Send().
|
||||
GetTraceLevel (me) returns Gravity from Message;
|
||||
---C++: inline
|
||||
---Purpose: Return trace level used for filtering messages;
|
||||
-- messages with lover gravity will be ignored.
|
||||
|
||||
Send (me; theString: AsciiString from TCollection;
|
||||
theGravity: Gravity from Message;
|
||||
putEndl: Boolean) is virtual;
|
||||
---Purpose: Send a string message with specified trace level.
|
||||
-- The parameter putEndl specified whether end-of-line
|
||||
-- should be added to the end of the message.
|
||||
-- Default implementation calls first method Send().
|
||||
SetTraceLevel (me : mutable;
|
||||
theTraceLevel : Gravity from Message);
|
||||
---C++: inline
|
||||
---Purpose: Set trace level used for filtering messages.
|
||||
-- By default, trace level is Message_Info, so that all messages are output
|
||||
|
||||
Send (me;
|
||||
theString : ExtendedString from TCollection;
|
||||
theGravity : Gravity from Message;
|
||||
theToPutEol : Boolean) is deferred;
|
||||
---Purpose: Send a string message with specified trace level.
|
||||
-- The parameter theToPutEol specified whether end-of-line should be added to the end of the message.
|
||||
-- This method must be redefined in descentant.
|
||||
|
||||
Send (me;
|
||||
theString : CString;
|
||||
theGravity : Gravity from Message;
|
||||
theToPutEol : Boolean) is virtual;
|
||||
---Purpose: Send a string message with specified trace level.
|
||||
-- The parameter theToPutEol specified whether end-of-line should be added to the end of the message.
|
||||
-- Default implementation calls first method Send().
|
||||
|
||||
Send (me;
|
||||
theString : AsciiString from TCollection;
|
||||
theGravity : Gravity from Message;
|
||||
theToPutEol : Boolean) is virtual;
|
||||
---Purpose: Send a string message with specified trace level.
|
||||
-- The parameter theToPutEol specified whether end-of-line should be added to the end of the message.
|
||||
-- Default implementation calls first method Send().
|
||||
|
||||
fields
|
||||
|
||||
myTraceLevel : Gravity from Message is protected;
|
||||
|
||||
end Printer;
|
||||
|
@@ -18,26 +18,42 @@
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <TCollection_ExtendedString.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : Constructor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Message_Printer::Message_Printer()
|
||||
: myTraceLevel (Message_Info)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Send
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Message_Printer::Send (const Standard_CString theString,
|
||||
const Message_Gravity theGravity,
|
||||
const Standard_Boolean putEndl) const
|
||||
const Message_Gravity theGravity,
|
||||
const Standard_Boolean theToOutEol) const
|
||||
{
|
||||
Send ( TCollection_ExtendedString(theString), theGravity, putEndl );
|
||||
if (theGravity >= myTraceLevel)
|
||||
{
|
||||
Send (TCollection_ExtendedString (theString), theGravity, theToOutEol);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Send
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Message_Printer::Send (const TCollection_AsciiString& theString,
|
||||
const Message_Gravity theGravity,
|
||||
const Standard_Boolean putEndl) const
|
||||
const Message_Gravity theGravity,
|
||||
const Standard_Boolean theToOutEol) const
|
||||
{
|
||||
Send ( TCollection_ExtendedString(theString), theGravity, putEndl );
|
||||
if (theGravity >= myTraceLevel)
|
||||
{
|
||||
Send (TCollection_ExtendedString (theString), theGravity, theToOutEol);
|
||||
}
|
||||
}
|
||||
|
36
src/Message/Message_Printer.lxx
Normal file
36
src/Message/Message_Printer.lxx
Normal file
@@ -0,0 +1,36 @@
|
||||
// Created on: 2007-06-28
|
||||
// Created by: Pavel TELKOV
|
||||
// Copyright (c) 2007-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and / or modify it
|
||||
// under the terms of the GNU Lesser General Public version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <Message_Printer.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : GetTraceLevel
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Message_Gravity Message_Printer::GetTraceLevel() const
|
||||
{
|
||||
return myTraceLevel;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetTraceLevel
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline void Message_Printer::SetTraceLevel (const Message_Gravity theTraceLevel)
|
||||
{
|
||||
myTraceLevel = theTraceLevel;
|
||||
}
|
@@ -46,17 +46,6 @@ is
|
||||
---Purpose: Flushes the output stream and destroys it if it has been
|
||||
-- specified externally with option doFree (or if it is internal
|
||||
-- file stream)
|
||||
|
||||
GetTraceLevel (me) returns Gravity from Message;
|
||||
---C++: inline
|
||||
---Purpose: Return trace level used for filtering messages;
|
||||
-- messages with lover gravity will be ignored.
|
||||
|
||||
SetTraceLevel (me: mutable; theTraceLevel: Gravity from Message);
|
||||
---C++: inline
|
||||
---Purpose: Set trace level used for filtering messages.
|
||||
-- By default, trace level is Message_Info, so that
|
||||
-- all messages are output
|
||||
|
||||
GetUseUtf8 (me) returns Boolean;
|
||||
---Purpose: Returns option to convert non-Ascii symbols to UTF8 encoding
|
||||
@@ -95,7 +84,6 @@ is
|
||||
|
||||
fields
|
||||
|
||||
myTraceLevel: Gravity from Message;
|
||||
myStream: Address from Standard; -- pointer to OStream
|
||||
myIsFile: Boolean from Standard;
|
||||
myUseUtf8: Boolean from Standard;
|
||||
|
@@ -26,10 +26,12 @@
|
||||
//purpose : Empty constructor, defaulting to cerr
|
||||
//=======================================================================
|
||||
|
||||
Message_PrinterOStream::Message_PrinterOStream (const Message_Gravity theTraceLevel)
|
||||
: myTraceLevel(theTraceLevel), myStream(&cout),
|
||||
myIsFile(Standard_False), myUseUtf8(Standard_False)
|
||||
Message_PrinterOStream::Message_PrinterOStream (const Message_Gravity theTraceLevel)
|
||||
: myStream (&cout),
|
||||
myIsFile (Standard_False),
|
||||
myUseUtf8 (Standard_False)
|
||||
{
|
||||
myTraceLevel = theTraceLevel;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -38,10 +40,12 @@ Message_PrinterOStream::Message_PrinterOStream (const Message_Gravity theTraceLe
|
||||
// for specific file names standard streams are created
|
||||
//=======================================================================
|
||||
Message_PrinterOStream::Message_PrinterOStream (const Standard_CString theFileName,
|
||||
const Standard_Boolean doAppend,
|
||||
const Message_Gravity theTraceLevel)
|
||||
: myTraceLevel(theTraceLevel), myStream(&cout), myIsFile(Standard_False)
|
||||
const Standard_Boolean theToAppend,
|
||||
const Message_Gravity theTraceLevel)
|
||||
: myStream (&cout),
|
||||
myIsFile (Standard_False)
|
||||
{
|
||||
myTraceLevel = theTraceLevel;
|
||||
if ( strcasecmp(theFileName, "cout") == 0 )
|
||||
myStream = &cerr;
|
||||
else if ( strcasecmp(theFileName, "cerr") == 0 )
|
||||
@@ -49,15 +53,15 @@ Message_PrinterOStream::Message_PrinterOStream (const Standard_CString theFileNa
|
||||
else
|
||||
{
|
||||
TCollection_AsciiString aFileName (theFileName);
|
||||
#ifdef WNT
|
||||
#ifdef _WIN32
|
||||
aFileName.ChangeAll ('/', '\\');
|
||||
#endif
|
||||
|
||||
ofstream *ofile = new ofstream (aFileName.ToCString(),
|
||||
#ifdef USE_STL_STREAMS
|
||||
(doAppend ? (std::ios_base::app | std::ios_base::out) : std::ios_base::out ) );
|
||||
(theToAppend ? (std::ios_base::app | std::ios_base::out) : std::ios_base::out ) );
|
||||
#else
|
||||
(doAppend ? ios::app : ios::out ) );
|
||||
(theToAppend ? ios::app : ios::out ) );
|
||||
#endif
|
||||
if ( ofile ) {
|
||||
myStream = (Standard_OStream*)ofile;
|
||||
|
@@ -15,26 +15,6 @@
|
||||
|
||||
#include <Message_PrinterOStream.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : GetTraceLevel
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Message_Gravity Message_PrinterOStream::GetTraceLevel() const
|
||||
{
|
||||
return myTraceLevel;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetTraceLevel
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline void Message_PrinterOStream::SetTraceLevel (const Message_Gravity theTraceLevel)
|
||||
{
|
||||
myTraceLevel = theTraceLevel;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetUseUtf8
|
||||
//purpose :
|
||||
@@ -64,4 +44,3 @@ inline Standard_OStream& Message_PrinterOStream::GetStream () const
|
||||
{
|
||||
return *(Standard_OStream*)myStream;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user