Standard_Integer theArgNb,
const char** theArgVec)
{
- if (theArgNb != 2)
+ bool toComplain = true;
+ NCollection_List<TCollection_AsciiString> aDocNames;
+ for (Standard_Integer anArgIt = 1; anArgIt < theArgNb; ++anArgIt)
{
- theDI << "DDocStd_Close : Error\n";
- return 1;
+ const TCollection_AsciiString anArg (theArgVec[anArgIt]);
+ TCollection_AsciiString anArgCase (anArg);
+ anArgCase.LowerCase();
+ if (anArgCase == "*"
+ || anArgCase == "-all"
+ || anArgCase == "all")
+ {
+ for (NCollection_Map<Handle(Draw_Drawable3D)>::Iterator anIter (Draw::Drawables());
+ anIter.More(); anIter.Next())
+ {
+ if (Handle(DDocStd_DrawDocument) aDrawDocument = Handle(DDocStd_DrawDocument)::DownCast (anIter.Value()))
+ {
+ aDocNames.Append (aDrawDocument->Name());
+ }
+ }
+ if (aDocNames.IsEmpty())
+ {
+ return 0;
+ }
+ }
+ else if (anArgCase == "-silent")
+ {
+ toComplain = false;
+ }
+ else
+ {
+ aDocNames.Append (anArg);
+ }
}
- Handle(TDocStd_Document) aDoc;
- Standard_CString aDocName = theArgVec[1];
- if (!DDocStd::GetDocument (aDocName, aDoc))
+ if (aDocNames.IsEmpty())
{
+ theDI << "Syntax error: wrong number of arguments";
return 1;
}
- TDF_Label aRoot = aDoc->GetData()->Root();
- Handle(TPrsStd_AISViewer) aDocViewer;
- if (TPrsStd_AISViewer::Find (aRoot, aDocViewer)
- && !aDocViewer->GetInteractiveContext().IsNull())
+ Handle(TDocStd_Application) aDocApp = DDocStd::GetApplication();
+ for (NCollection_List<TCollection_AsciiString>::Iterator aDocNameIter (aDocNames);
+ aDocNameIter.More(); aDocNameIter.Next())
{
- Handle(V3d_Viewer) aViewer = aDocViewer->GetInteractiveContext()->CurrentViewer();
- V3d_ListOfView aViews;
- for (V3d_ListOfViewIterator aViewIter (aDocViewer->GetInteractiveContext()->CurrentViewer()->DefinedViewIterator()); aViewIter.More(); aViewIter.Next())
+ Standard_CString aDocName = aDocNameIter.Value().ToCString();
+ Handle(TDocStd_Document) aDoc;
+ if (DDocStd::GetDocument (aDocName, aDoc, toComplain))
{
- aViews.Append (aViewIter.Value());
+ TDF_Label aRoot = aDoc->GetData()->Root();
+ Handle(TPrsStd_AISViewer) aDocViewer;
+ if (TPrsStd_AISViewer::Find (aRoot, aDocViewer)
+ && !aDocViewer->GetInteractiveContext().IsNull())
+ {
+ Handle(V3d_Viewer) aViewer = aDocViewer->GetInteractiveContext()->CurrentViewer();
+ V3d_ListOfView aViews;
+ for (V3d_ListOfViewIterator aViewIter (aDocViewer->GetInteractiveContext()->CurrentViewer()->DefinedViewIterator()); aViewIter.More(); aViewIter.Next())
+ {
+ aViews.Append (aViewIter.Value());
+ }
+ for (V3d_ListOfViewIterator aViewIter (aViews); aViewIter.More(); aViewIter.Next())
+ {
+ Handle(V3d_View) aView = aViewIter.Value();
+ ViewerTest::RemoveView (aView);
+ }
+ }
+ aDocApp->Close (aDoc);
}
- for (V3d_ListOfViewIterator aViewIter (aViews); aViewIter.More(); aViewIter.Next())
+ else if (toComplain)
{
- Handle(V3d_View) aView = aViewIter.Value();
- ViewerTest::RemoveView (aView);
+ return 1;
}
- }
- Handle(TDocStd_Application) aDocApp = DDocStd::GetApplication();
-
- aDocApp->Close (aDoc);
-
- if (Handle(Draw_Drawable3D) aDrawable = Draw::GetExisting (aDocName))
- {
- dout.RemoveDrawable (aDrawable);
+ if (Handle(Draw_Drawable3D) aDrawable = Draw::GetExisting (aDocName))
+ {
+ dout.RemoveDrawable (aDrawable);
+ }
+ Draw::Set (aDocName, Handle(Draw_Drawable3D)());
}
- Draw::Set (theArgVec[1], Handle(Draw_Drawable3D)());
return 0;
}
__FILE__, DDocStd_Save, g);
theCommands.Add("Close",
- "Close DOC",
+ "Close the specific document or all documents\n"
+ "Close DOC [-silent]"
+ "\n\t\t: Close the specific document."
+ "\n\t\t: -silent not raise an exception or print error message for an empty document \n"
+ "Close *"
+ "\n\t\t: Close all open documents.",
__FILE__, DDocStd_Close, g);
theCommands.Add("IsInSession",
#define _Draw_HeaderFile
#include <Draw_Interpretor.hxx>
+#include <NCollection_Map.hxx>
#include <Quantity_ColorRGBA.hxx>
#include <Standard_Handle.hxx>
//! Sets a TCL string variable
Standard_EXPORT static void Set (const Standard_CString Name, const Standard_CString val);
+ //! Returns a map of Draw_Drawable3D variables.
+ Standard_EXPORT static const NCollection_Map<Handle(Draw_Drawable3D)>& Drawables();
+
public: //! @name argument parsing tools
//! Converts numeric expression, that can involve DRAW
#include <OSD_Environment.hxx>
#include <OSD_OpenFile.hxx>
-Standard_Boolean Draw_ParseFailed;
+Standard_Boolean Draw_ParseFailed = Standard_True;
static Standard_Boolean autodisp = Standard_True;
-static Standard_Boolean repaint2d,repaint3d;
+static Standard_Boolean repaint2d = Standard_False, repaint3d = Standard_False;
-//===============================================
-// dictionary of variables
-// Variables are stored in a map Integer, Transient
-// The Integer Value is the content of the TCl variable
-//===============================================
-
-static NCollection_Map<Handle(Draw_Drawable3D)> theVariables;
+//! Returns dictionary of variables
+//! Variables are stored in a map Integer, Transient.
+//! The Integer Value is the content of the Tcl variable.
+static NCollection_Map<Handle(Draw_Drawable3D)>& Draw_changeDrawables()
+{
+ static NCollection_Map<Handle(Draw_Drawable3D)> theVariables;
+ return theVariables;
+}
//=======================================================================
//function : FindVariable
//purpose :
//=======================================================================
-static Standard_Integer p_id;
-static Standard_Integer p_X;
-static Standard_Integer p_Y;
-static Standard_Integer p_b;
+static Standard_Integer p_id = 0;
+static Standard_Integer p_X = 0;
+static Standard_Integer p_Y = 0;
+static Standard_Integer p_b = 0;
static const char* p_Name = "";
//=======================================================================
}
}
}
-
+
// sauvegarde des proteges visibles
Draw_SequenceOfDrawable3D prot;
- NCollection_Map<Handle(Draw_Drawable3D)>::Iterator aMapIt (theVariables);
- for (; aMapIt.More(); aMapIt.Next()) {
+ for (NCollection_Map<Handle(Draw_Drawable3D)>::Iterator aMapIt (Draw::Drawables()); aMapIt.More(); aMapIt.Next())
+ {
const Handle(Draw_Drawable3D)& D = aMapIt.Key();
- if (!D.IsNull()) {
- if (D->Protected() && D->Visible())
- prot.Append(D);
+ if (!D.IsNull())
+ {
+ if (D->Protected() && D->Visible())
+ {
+ prot.Append(D);
+ }
}
}
static char* tracevar(ClientData CD, Tcl_Interp*,const char* name,const char*, int)
{
// protect if the map was destroyed before the interpretor
- if (theVariables.IsEmpty()) return NULL;
+ if (Draw::Drawables().IsEmpty())
+ {
+ return NULL;
+ }
Draw_Interpretor& aCommands = Draw::GetInterpretor();
}
Tcl_UntraceVar(aCommands.Interp(),name,TCL_TRACE_UNSETS | TCL_TRACE_WRITES,
tracevar,CD);
- theVariables.Remove(D);
+ Draw_changeDrawables().Remove(D);
return NULL;
}
}
tracevar, NULL);
Handle(Draw_Drawable3D) anOldD(reinterpret_cast<Draw_Drawable3D*>(aCD));
if (!anOldD.IsNull()) {
- if (theVariables.Contains(anOldD) && anOldD->Protected()) {
+ if (Draw::Drawables().Contains(anOldD) && anOldD->Protected()) {
std::cout << "variable is protected" << std::endl;
return;
}
Tcl_UnsetVar(aCommands.Interp(),name,0);
if (!D.IsNull()) {
- theVariables.Add(D);
+ Draw_changeDrawables().Add(D);
D->Name(Tcl_SetVar(aCommands.Interp(),name,name,0));
// set the trace function
{
ClientData aCD = Tcl_VarTraceInfo (Draw::GetInterpretor().Interp(), theName, TCL_TRACE_UNSETS | TCL_TRACE_WRITES, tracevar, NULL);
Handle(Draw_Drawable3D) aDrawable = reinterpret_cast<Draw_Drawable3D*>(aCD);
- return theVariables.Contains (aDrawable)
+ return Draw::Drawables().Contains (aDrawable)
? aDrawable
: Handle(Draw_Drawable3D)();
}
//
Tcl_SetVar(Draw::GetInterpretor().Interp(), pName, pVal, 0);
}
+
+//=======================================================================
+//function : Drawables
+//purpose :
+//=======================================================================
+const NCollection_Map<Handle(Draw_Drawable3D)>& Draw::Drawables()
+{
+ return Draw_changeDrawables();
+}
+
//=======================================================================
// Command management
// refresh the screen
#set aTestName "OCC2269"
#set WorkDirectory ${filedir}
#set aFile $WorkDirectory/${aTestName}.${FileSuffix}
-#catch {Close D}
+#Close D -silent
set IsGood 1
Open [locate_data_file OCC2269.xml] DD
set BugNumber OCC29452
set file [locate_data_file bug29452.xml]
-catch {Close D}
+Close D -silent
set res [Open $file D]
set real [GetReal D 0:1]
pload MODELING VISUALIZATION OCAF XDE
-catch { Close D }
-catch { Close D_Cope }
+Close D D_Cope -silent
# create original
box b 0 -20 -10 100 40 20
if { [GetName U 0:1:1:1] != "$theNameTo" } { puts "Error: unable to read UTF-8 STEP" }
if { [GetName ISO 0:1:1:1] != "$theNameTo" } { puts "Error: unable to read $theCodePage STEP" }
if { [GetName A 0:1:1:1] == "$theNameTo" } { puts "Error: broken test case" }
- catch { Close A }
- catch { Close U }
- catch { Close ISO }
+ Close A U ISO -silent
}
pload XDE OCAF MODELING VISUALIZATION
set iso8859_9 [encoding convertfrom utf-8 "\xc4\x9f\xc5\x9f\xc4\x9e\xc5\x9e\xc3\x86"]
box b 1 2 3
-catch { Close A }
-catch { Close T }
-catch { Close U }
-catch { Close CP }
+Close A T U CP -silent
XNewDoc T
XAddShape T b 0
puts ""
pload OCAF
-catch {Close D}
+Close D -silent
# Read File
ReadStep D [locate_data_file bug28454_directives.stp]
# 国标
set aName [encoding convertfrom unicode "\xFD\x56\x07\x68"]
box b 1 2 3
-catch { Close A }
-catch { Close T }
-catch { Close U }
-catch { Close G }
+Close A T U G -silent
XNewDoc T
XAddShape T b 0
XSetColor T b 1 0 0
puts ""
pload OCAF
-catch { Close D }
+Close D -silent
# Read file
ReadStep D [locate_data_file bug31000_InSensitive.stp]
if { [GetName U 0:1:1:1] != "$theNameTo" } { puts "Error: unable to read UTF-8 STEP" }
if { [GetName CP 0:1:1:1] != "$theNameTo" } { puts "Error: unable to read $theCodePage STEP" }
if { [GetName A 0:1:1:1] == "$theNameTo" } { puts "Error: broken test case" }
- catch { Close A }
- catch { Close U }
- catch { Close CP }
+ Close A U CP -silent
}
pload XDE OCAF MODELING VISUALIZATION
set aViettName [encoding convertfrom utf-8 "\u0054\u0068\u00ed \u006e\u0067\u0068\u0069\u1ec7\u006d"]
box b 1 2 3
-catch { Close A }
-catch { Close T }
-catch { Close U }
-catch { Close CP }
+Close A T U CP -silent
XNewDoc T
XAddShape T b 0
pload OCAF
param write.step.schema AP242DIS
-catch { Close D_First }
-catch { Close D_Sec }
+Close D_First D_Sec -silent
# Read file
set Path ${imagedir}/${casename}.stp
# Überprüfung de codificação
set aName [encoding convertfrom utf-8 "\xc3\x9c\x62\x65\x72\x70\x72\xc3\xbc\x66\x75\x6e\x67 \x64\x65 \x63\x6f\x64\x69\x66\x69\x63\x61\xc3\xa7\xc3\xa3\x6f"]
-catch { Close A }
-catch { Close T }
-catch { Close U }
-catch { Close C }
+Close A T U C -silent
box b 1 2 3
XNewDoc T
puts "========================"
pload OCAF
-catch { Close D }
+Close D -silent
# Read file
ReadStep D [locate_data_file bug32049_sp7_04dx_242.stp]
puts ""
pload XDE OCAF VISUALIZATION
-catch { Close D }
+Close D -silent
ReadStep D [locate_data_file bug25381_test_assembly_invisible.step]
XShow D
vaxo
puts ""
pload QAcommands VISUALIZATION DCAF
-catch { Close doc }
+Close Doc -silent
OCC28887 [locate_data_file bug23384-doc_subshapes.xbf] doc
vclear
pload TOPTEST
-catch {Close D}
+Close D -silent
# Normal test execution
if !$Create_Doc {
pload XDE OCAF MODELING VISUALIZATION
-catch { Close D }
+Close D -silent
# PBR requires OpenGL 3.0+ on macOS
if { $::tcl_platform(os) == "Darwin" } { vcaps -core }
pload XDE OCAF MODELING VISUALIZATION
-catch { Close D }
+Close D -silent
# PBR requires OpenGL 3.0+ on macOS
if { $::tcl_platform(os) == "Darwin" } { vcaps -core }
puts "Test case exporting glTF model into glTF file."
puts "========"
-catch { Close D1 }
+Close D1 -silent
ReadGltf D1 [locate_data_file bug30691_DamagedHelmet.gltf]
set aTmpGltfBase "${imagedir}/${casename}_tmp"
puts "Test case exporting glTF model into GLB file."
puts "========"
-catch { Close D1 }
+Close D1 -silent
ReadGltf D1 [locate_data_file bug30691_DamagedHelmet.gltf]
set aTmpGltfBase "${imagedir}/${casename}_tmp"
puts "0031816: Data Exchange - RWMesh_MaterialMap::CopyTexture() copies glb file instead of a texture inside it"
puts "========"
-catch { Close D1 }
+Close D1 -silent
ReadGltf D1 [locate_data_file bug30691_Lantern.glb]
set aTmpGltfBase "${imagedir}/${casename}_tmp"
puts "Test case exporting glTF model into GLB file."
puts "========"
-catch { Close D1 }
+Close D1 -silent
ReadGltf D1 [locate_data_file bug30691_Lantern.glb]
set aTmpGltfBase "${imagedir}/${casename}_tmp"
pload XDE OCAF MODELING VISUALIZATION
-catch { Close D }
+Close D -silent
# PBR requires OpenGL 3.0+ on macOS
if { $::tcl_platform(os) == "Darwin" } { vcaps -core }
puts "Info: Restore the document"
if [info exists DD] {
- catch {Close DD}; unset DD
+ Close DD -silent; unset DD
}
dchrono h restart
puts "Info: Restore the document"
if [info exists DD] {
- catch {Close DD}; unset DD
+ Close DD -silent; unset DD
}
dchrono h restart
box b 10 10 10
vclear
vinit View1
-catch { Close D }
+Close D -silent
NewDocument D BinXCAF
XAddShape D b
XSetColor D b BLUE
# PBR doesn't work with Compatible Profile on macOS
if { $::tcl_platform(os) == "Darwin" } { vcaps -core }
-catch { Close D }
+Close D -silent
vclear
vclose ALL
vlight -clear
vlight -add ambient
-catch { Close D }
+Close D -silent
ReadGltf D [locate_data_file bug31302_NormalTangentTest.gltf]
XDisplay -dispmode 1 D
ttranslate s1 1 0 0
ttranslate s2 2 0 0
ttranslate s3 3 0 0
-catch { Close D }
+Close D -silent
XNewDoc D
set l0 [XAddShape D b 0]
set l1 [XAddShape D s1 0]
pload XDE OCAF MODELING VISUALIZATION
-catch { Close D }
+Close D -silent
vclear
vinit View1
vaxo
puts "========"
pload XDE OCAF MODELING VISUALIZATION
-catch { Close D }
+Close D -silent
ReadGltf D [locate_data_file bug30691_DamagedHelmet.gltf]
vclear
puts "========"
pload XDE OCAF MODELING VISUALIZATION
-catch { Close D }
+Close D -silent
ReadGltf D [locate_data_file bug31275_SphereWithNormalMap.glb]
vclear
pload MODELING VISUALIZATION XDE OCAF
if { $::tcl_platform(os) == "Darwin" } { vcaps -core }
-catch {Close D}
+Close D -silent
ReadGltf D [locate_data_file bug30691_Buggy.glb]
vclear
vinit View1