mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0031731: Draw Harness - colorize errors and exception messages
Draw_Interpretor, CommandCmd() - catched exceptions and messages put into Tcl string result before throwing a Tcl exception (return 1) are now print in intense red (using Message::SendFail()). Duplication of exception message in std::cout and Tcl output has been removed. Draw Harness plugins have been updated to use either Message::SendFail() or theDI instead of std::cout/std::cerr for printing colored error message before throwing a Tcl exception.
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
#include <Draw_Marker3D.hxx>
|
||||
#include <Draw_Color.hxx>
|
||||
#include <Draw_MarkerShape.hxx>
|
||||
#include <Message.hxx>
|
||||
#include <TColgp_Array1OfPnt.hxx>
|
||||
#include <TColgp_Array2OfPnt.hxx>
|
||||
#include <TColStd_Array2OfReal.hxx>
|
||||
@@ -90,7 +91,7 @@ static Standard_Integer proj (Draw_Interpretor& di, Standard_Integer n, const ch
|
||||
{
|
||||
if ( n < 5)
|
||||
{
|
||||
std::cout << " Use proj curve/surf x y z [{extrema algo: g(grad)/t(tree)}|{u v}]" << std::endl;
|
||||
Message::SendFail() << " Use proj curve/surf x y z [{extrema algo: g(grad)/t(tree)}|{u v}]";
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@@ -27,6 +27,7 @@
|
||||
#include <Draw_Appli.hxx>
|
||||
#include <Draw.hxx>
|
||||
#include <Draw_Interpretor.hxx>
|
||||
#include <Message.hxx>
|
||||
|
||||
/*********************************************************************************/
|
||||
void InitEpsSurf(Standard_Real& epsnl,Standard_Real& epsdis, Standard_Real& epsangk1,
|
||||
@@ -106,7 +107,7 @@ static Standard_Integer surfaceCcontinuity (Draw_Interpretor& di, Standard_Integ
|
||||
Standard_FALLTHROUGH
|
||||
case 8 : break;
|
||||
default :
|
||||
std::cerr << "Error: invalid number of arguments: expected to get 8 - 10 parameters" << std::endl;
|
||||
Message::SendFail() << "Error: invalid number of arguments: expected to get 8 - 10 parameters";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -125,7 +126,7 @@ static Standard_Integer surfaceCcontinuity (Draw_Interpretor& di, Standard_Integ
|
||||
Standard_FALLTHROUGH
|
||||
case 8 : break;
|
||||
default :
|
||||
std::cerr << "Error: invalid number of arguments: expected to get 8 - 11 parameters" << std::endl;
|
||||
Message::SendFail() << "Error: invalid number of arguments: expected to get 8 - 11 parameters";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -146,13 +147,13 @@ static Standard_Integer surfaceCcontinuity (Draw_Interpretor& di, Standard_Integ
|
||||
Standard_FALLTHROUGH
|
||||
case 8 : break;
|
||||
default :
|
||||
std::cerr << "Error: invalid number of arguments: expected to get 8 - 12 parameters" << std::endl;
|
||||
Message::SendFail() << "Error: invalid number of arguments: expected to get 8 - 12 parameters";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
std::cerr << "Error: invalid value of parameter 1 (" << a[1] << "): should be 0, 1, or 2" << std::endl;
|
||||
Message::SendFail() << "Error: invalid value of parameter 1 (" << a[1] << "): should be 0, 1, or 2";
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -217,7 +218,7 @@ static Standard_Integer surfaceGcontinuity (Draw_Interpretor& di, Standard_Integ
|
||||
Standard_FALLTHROUGH
|
||||
case 8 : break;
|
||||
default :
|
||||
std::cerr << "Error: invalid number of arguments: expected to get 8 - 11 parameters" << std::endl;
|
||||
Message::SendFail() << "Error: invalid number of arguments: expected to get 8 - 11 parameters";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -240,13 +241,13 @@ static Standard_Integer surfaceGcontinuity (Draw_Interpretor& di, Standard_Integ
|
||||
Standard_FALLTHROUGH
|
||||
case 8 : break;
|
||||
default :
|
||||
std::cerr << "Error: invalid number of arguments: expected to get 8 - 13 parameters" << std::endl;
|
||||
Message::SendFail() << "Error: invalid number of arguments: expected to get 8 - 13 parameters";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
std::cerr << "Error: invalid value of parameter 1 (" << a[1] << "): should be 1 or 2" << std::endl;
|
||||
Message::SendFail() << "Error: invalid value of parameter 1 (" << a[1] << "): should be 1 or 2";
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -306,7 +307,7 @@ static Standard_Integer curveGcontinuity(Draw_Interpretor& di, Standard_Integer
|
||||
Standard_FALLTHROUGH
|
||||
case 6 : break;
|
||||
default :
|
||||
std::cerr << "Error: invalid number of arguments: expected to get 6 - 8 parameters" << std::endl;
|
||||
Message::SendFail() << "Error: invalid number of arguments: expected to get 6 - 8 parameters";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -330,14 +331,14 @@ static Standard_Integer curveGcontinuity(Draw_Interpretor& di, Standard_Integer
|
||||
Standard_FALLTHROUGH
|
||||
case 6 : break;
|
||||
default :
|
||||
std::cerr << "Error: invalid number of arguments: expected to get 6 - 12 parameters" << std::endl;
|
||||
Message::SendFail() << "Error: invalid number of arguments: expected to get 6 - 12 parameters";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
std::cerr << "Error: invalid value of parameter 1 (" << a[1] << "): should be 1 or 2" << std::endl;
|
||||
Message::SendFail() << "Error: invalid value of parameter 1 (" << a[1] << "): should be 1 or 2";
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -395,7 +396,7 @@ static Standard_Integer curveCcontinuity(Draw_Interpretor& di, Standard_Integer
|
||||
Standard_FALLTHROUGH
|
||||
case 6 : break;
|
||||
default :
|
||||
std::cerr << "Error: invalid number of arguments: expected to get 6 - 8 parameters" << std::endl;
|
||||
Message::SendFail() << "Error: invalid number of arguments: expected to get 6 - 8 parameters";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -413,7 +414,7 @@ static Standard_Integer curveCcontinuity(Draw_Interpretor& di, Standard_Integer
|
||||
Standard_FALLTHROUGH
|
||||
case 6 : break;
|
||||
default :
|
||||
std::cerr << "Error: invalid number of arguments: expected to get 6 - 9 parameters" << std::endl;
|
||||
Message::SendFail() << "Error: invalid number of arguments: expected to get 6 - 9 parameters";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -434,14 +435,14 @@ static Standard_Integer curveCcontinuity(Draw_Interpretor& di, Standard_Integer
|
||||
Standard_FALLTHROUGH
|
||||
case 6 : break;
|
||||
default :
|
||||
std::cerr << "Error: invalid number of arguments: expected to get 6 - 10 parameters" << std::endl;
|
||||
Message::SendFail() << "Error: invalid number of arguments: expected to get 6 - 10 parameters";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
std::cerr << "Error: invalid value of parameter 1 (" << a[1] << "): should be 0, 1, or 2" << std::endl;
|
||||
Message::SendFail() << "Error: invalid value of parameter 1 (" << a[1] << "): should be 0, 1, or 2";
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@@ -98,7 +98,7 @@
|
||||
#include <Approx_CurveOnSurface.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <Geom2dAdaptor.hxx>
|
||||
|
||||
#include <Message.hxx>
|
||||
|
||||
#include <Precision.hxx>
|
||||
|
||||
@@ -944,7 +944,7 @@ static Standard_Integer crvpoints (Draw_Interpretor& di, Standard_Integer /*n*/,
|
||||
TopoDS_Wire aWire = TopoDS::Wire(DBRep::Get(a[2], TopAbs_WIRE));
|
||||
if (aWire.IsNull())
|
||||
{
|
||||
std::cout << "cannot evaluate the argument " << a[2] << " as a curve" << std::endl;
|
||||
Message::SendFail() << "cannot evaluate the argument " << a[2] << " as a curve";
|
||||
return 1;
|
||||
}
|
||||
BRepAdaptor_CompCurve aCompCurve(aWire);
|
||||
@@ -1018,7 +1018,7 @@ static Standard_Integer crvtpoints (Draw_Interpretor& di, Standard_Integer n, co
|
||||
TopoDS_Wire aWire = TopoDS::Wire(DBRep::Get(a[2], TopAbs_WIRE));
|
||||
if (aWire.IsNull())
|
||||
{
|
||||
std::cout << "cannot evaluate the argument " << a[2] << " as a curve" << std::endl;
|
||||
Message::SendFail() << "cannot evaluate the argument " << a[2] << " as a curve";
|
||||
return 1;
|
||||
}
|
||||
BRepAdaptor_CompCurve aCompCurve(aWire);
|
||||
|
@@ -25,6 +25,7 @@
|
||||
#include <Geom2dAdaptor_Curve.hxx>
|
||||
#include <GeometryTest.hxx>
|
||||
#include <GeometryTest_DrawableQualifiedCurve2d.hxx>
|
||||
#include <Message.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <stdio.h>
|
||||
@@ -37,7 +38,7 @@ static Standard_Integer qcurve (Draw_Interpretor&, Standard_Integer theArgsNb, c
|
||||
{
|
||||
if (theArgsNb < 5)
|
||||
{
|
||||
std::cout << "Error: wrong number of arguments.\n";
|
||||
Message::SendFail() << "Error: wrong number of argument";
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -61,7 +62,7 @@ static Standard_Integer qcurve (Draw_Interpretor&, Standard_Integer theArgsNb, c
|
||||
{
|
||||
if (theArgsNb < 6)
|
||||
{
|
||||
std::cout << "Error: wrong number of arguments.\n";
|
||||
Message::SendFail() << "Error: wrong number of arguments";
|
||||
return 1;
|
||||
}
|
||||
aResult2d = new Geom2d_Line (gp_Pnt2d (Draw::Atof (theArgVec[2]), Draw::Atof (theArgVec[3])),
|
||||
@@ -71,7 +72,7 @@ static Standard_Integer qcurve (Draw_Interpretor&, Standard_Integer theArgsNb, c
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Error: wrong command name.\n";
|
||||
Message::SendFail() << "Error: wrong command name";
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -95,7 +96,7 @@ static Standard_Integer solutions (Draw_Interpretor& theDI, GccAna_Circ2d3Tan& t
|
||||
{
|
||||
if (!theCirTan3.IsDone())
|
||||
{
|
||||
std::cout << "GccAna_Circ2d3Tan is not done";
|
||||
Message::SendFail() << "GccAna_Circ2d3Tan is not done";
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -159,7 +160,7 @@ static Standard_Integer circ2d3Tan (Draw_Interpretor& theDI, Standard_Integer th
|
||||
{
|
||||
if (theArgsNb < 5)
|
||||
{
|
||||
std::cout << "Error: wrong number of arguments.\n";
|
||||
Message::SendFail() << "Error: wrong number of arguments";
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -183,7 +184,7 @@ static Standard_Integer circ2d3Tan (Draw_Interpretor& theDI, Standard_Integer th
|
||||
{
|
||||
if (!anIsPoint1 || !anIsPoint2 || !anIsPoint3)
|
||||
{
|
||||
std::cout << "Error: wrong points definition.\n";
|
||||
Message::SendFail() << "Error: wrong points definition";
|
||||
return 1;
|
||||
}
|
||||
GccAna_Circ2d3Tan aCircBuilder (aPoint1, aPoint2, aPoint3, aTolerance);
|
||||
@@ -195,7 +196,7 @@ static Standard_Integer circ2d3Tan (Draw_Interpretor& theDI, Standard_Integer th
|
||||
{
|
||||
if (!anIsPoint2 || !anIsPoint3)
|
||||
{
|
||||
std::cout << "Error: wrong points definition.\n";
|
||||
Message::SendFail() << "Error: wrong points definition";
|
||||
return 1;
|
||||
}
|
||||
Geom2dAdaptor_Curve anAdaptorCurve1 (aQCurve1->GetCurve());
|
||||
@@ -211,7 +212,7 @@ static Standard_Integer circ2d3Tan (Draw_Interpretor& theDI, Standard_Integer th
|
||||
GccAna_Circ2d3Tan aCircBuilder (aQualifiedLin1, aPoint2, aPoint3, aTolerance);
|
||||
return solutions (theDI, aCircBuilder, theArgVec[1]);
|
||||
}
|
||||
std::cout << "Error: wrong curve type.\n";
|
||||
Message::SendFail() << "Error: wrong curve type";
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -220,7 +221,7 @@ static Standard_Integer circ2d3Tan (Draw_Interpretor& theDI, Standard_Integer th
|
||||
{
|
||||
if (!anIsPoint3)
|
||||
{
|
||||
std::cout << "Error: wrong point definition.\n";
|
||||
Message::SendFail() << "Error: wrong point definition";
|
||||
return 1;
|
||||
}
|
||||
Geom2dAdaptor_Curve anAdaptorCurve1 (aQCurve1->GetCurve());
|
||||
@@ -246,7 +247,7 @@ static Standard_Integer circ2d3Tan (Draw_Interpretor& theDI, Standard_Integer th
|
||||
GccAna_Circ2d3Tan aCircBuilder (aQualifiedLin1, aQualifiedLin2, aPoint3, aTolerance);
|
||||
return solutions (theDI, aCircBuilder, theArgVec[1]);
|
||||
}
|
||||
std::cout << "Error: wrong curve type.\n";
|
||||
Message::SendFail() << "Error: wrong curve type";
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -292,7 +293,7 @@ static Standard_Integer circ2d3Tan (Draw_Interpretor& theDI, Standard_Integer th
|
||||
return solutions (theDI, aCircBuilder, theArgVec[1]);
|
||||
}
|
||||
|
||||
std::cout << "Error: wrong curve type.\n";
|
||||
Message::SendFail() << "Error: wrong curve type";
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user