#include <TDF_Tool.hxx>
#include <OSD_Path.hxx>
+#include <OSD_OpenFile.hxx>
#include <TDocStd_PathParser.hxx>
+#include <XmlLDrivers.hxx>
#include <AIS_InteractiveContext.hxx>
#include <TPrsStd_AISViewer.hxx>
const char** /*a*/)
{
if (nb == 1) {
- Handle(TDocStd_Application) A;
- if (!DDocStd::Find(A)) return 1;
+ Handle(TDocStd_Application) A = DDocStd::GetApplication();
Handle(TDocStd_Document) D;
Standard_Integer nbdoc = A->NbDocuments();
for (Standard_Integer i = 1; i <= nbdoc; i++) {
if (D->IsSaved()) {
TCollection_AsciiString GetNameAsciiString(D->GetName().ToExtString(),'?');
TCollection_AsciiString GetPathAsciiString(D->GetPath().ToExtString(),'?');
- //cout << " name : " << D->GetName();
- //cout << " path : " << D->GetPath();
+ //std::cout << " name : " << D->GetName();
+ //std::cout << " path : " << D->GetPath();
di << " name : " << GetNameAsciiString.ToCString();
di << " path : " << GetPathAsciiString.ToCString();
}
}
if (nb == 3) {
if (!DDocStd::GetDocument(a[1],D,Standard_False)) {
- Handle(TDocStd_Application) A;
- if (!DDocStd::Find(A)) return 1;
+ Handle(TDocStd_Application) A = DDocStd::GetApplication();
A->NewDocument(a[2],D);
DD = new DDocStd_DrawDocument(D);
TDataStd_Name::Set(D->GetData()->Root(),a[1]);
Standard_Integer nb,
const char** a)
{
- if (nb == 3) {
+ if (nb >= 3) {
TCollection_ExtendedString path (a[1]);
- Handle(TDocStd_Application) A;
- if (!DDocStd::Find(A)) return 1;
+ Handle(TDocStd_Application) A = DDocStd::GetApplication();
Handle(TDocStd_Document) D;
Standard_Integer insession = A->IsInSession(path);
if (insession > 0) {
di <<"document " << insession << " is already in session\n";
return 0;
}
- PCDM_ReaderStatus theStatus = A->Open(path,D);
+ PCDM_ReaderStatus theStatus;
+
+ Standard_Boolean anUseStream = Standard_False;
+ for ( Standard_Integer i = 3; i < nb; i++ )
+ {
+ if (!strcmp (a[i], "-stream"))
+ {
+ di << "standard SEEKABLE stream is used\n";
+ anUseStream = Standard_True;
+ break;
+ }
+ }
+
+ if (anUseStream)
+ {
+ std::ifstream aFileStream;
+ OSD_OpenStream (aFileStream, path, std::ios::in | std::ios::binary);
+
+ theStatus = A->Open (aFileStream, D);
+ }
+ else
+ {
+ theStatus = A->Open(path,D);
+ }
if (theStatus == PCDM_RS_OK && !D.IsNull()) {
Handle(DDocStd_DrawDocument) DD = new DDocStd_DrawDocument(D);
TDataStd_Name::Set(D->GetData()->Root(),a[2]);
if (nb == 2) {
Handle(TDocStd_Document) D;
if (!DDocStd::GetDocument(a[1],D)) return 1;
- Handle(TDocStd_Application) A;
- if (!DDocStd::Find(A)) return 1;
+ Handle(TDocStd_Application) A = DDocStd::GetApplication();
if (!D->IsSaved()) {
di << "this document has never been saved\n";
return 0;
//=======================================================================
static Standard_Integer DDocStd_SaveAs (Draw_Interpretor& di,
- Standard_Integer nb,
- const char** a)
-{
- if (nb == 3) {
+ Standard_Integer nb,
+ const char** a)
+{
+ if (nb >= 3) {
Handle(TDocStd_Document) D;
if (!DDocStd::GetDocument(a[1],D)) return 1;
TCollection_ExtendedString path (a[2]);
- Handle(TDocStd_Application) A;
- if (!DDocStd::Find(A)) return 1;
- PCDM_StoreStatus theStatus = A->SaveAs(D,path);
+ Handle(TDocStd_Application) A = DDocStd::GetApplication();
+ PCDM_StoreStatus theStatus;
+
+ Standard_Boolean anUseStream(Standard_False), isSaveEmptyLabels(Standard_False);
+ for ( Standard_Integer i = 3; i < nb; i++ )
+ {
+ if (!strcmp (a[i], "-stream"))
+ {
+ di << "standard SEEKABLE stream is used\n";
+ anUseStream = Standard_True;
+ break;
+ } else {
+ isSaveEmptyLabels = ((atoi (a[3])) != 0);
+ D->SetEmptyLabelsSavingMode(isSaveEmptyLabels);
+ }
+ }
+ if (anUseStream)
+ {
+ std::ofstream aFileStream;
+ OSD_OpenStream (aFileStream, path, std::ios::out | std::ios::binary);
+ theStatus = A->SaveAs (D, aFileStream);
+ }
+ else
+ {
+ theStatus = A->SaveAs(D,path);
+ }
+
if (theStatus != PCDM_SS_OK ) {
switch ( theStatus ) {
- case PCDM_SS_DriverFailure: {
- di << "Error saving document: Could not store , no driver found to make it\n";
- break ;
- }
- case PCDM_SS_WriteFailure: {
- di << "Error saving document: Write access failure\n";
- break;
- }
- case PCDM_SS_Failure: {
- di << "Error saving document: Write failure\n" ;
- break;
- }
- case PCDM_SS_Doc_IsNull: {
- di << "Error saving document: No document to save\n";
- break ;
- }
- case PCDM_SS_No_Obj: {
- di << "Error saving document: No objects written\n";
- break;
- }
- case PCDM_SS_Info_Section_Error: {
- di << "Error saving document: Write info section failure\n" ;
- break;
- }
- default:
- break;
+ case PCDM_SS_DriverFailure: {
+ di << "Error saving document: Could not store , no driver found to make it\n";
+ break ;
+ }
+ case PCDM_SS_WriteFailure: {
+ di << "Error saving document: Write access failure\n";
+ break;
+ }
+ case PCDM_SS_Failure: {
+ di << "Error saving document: Write failure\n" ;
+ break;
+ }
+ case PCDM_SS_Doc_IsNull: {
+ di << "Error saving document: No document to save\n";
+ break ;
+ }
+ case PCDM_SS_No_Obj: {
+ di << "Error saving document: No objects written\n";
+ break;
+ }
+ case PCDM_SS_Info_Section_Error: {
+ di << "Error saving document: Write info section failure\n" ;
+ break;
+ }
+ default:
+ break;
}
return 1;
} else {
&& !aDocViewer->GetInteractiveContext().IsNull())
{
Handle(V3d_Viewer) aViewer = aDocViewer->GetInteractiveContext()->CurrentViewer();
- for (aViewer->InitDefinedViews(); aViewer->MoreDefinedViews(); aViewer->NextDefinedViews())
+ V3d_ListOfView aViews;
+ for (V3d_ListOfViewIterator aViewIter (aDocViewer->GetInteractiveContext()->CurrentViewer()->DefinedViewIterator()); aViewIter.More(); aViewIter.Next())
{
- Handle(V3d_View) aView = aViewer->DefinedView();
+ aViews.Append (aViewIter.Value());
+ }
+ for (V3d_ListOfViewIterator aViewIter (aViews); aViewIter.More(); aViewIter.Next())
+ {
+ Handle(V3d_View) aView = aViewIter.Value();
ViewerTest::RemoveView (aView);
}
}
- Handle(TDocStd_Application) aDocApp;
- if (!DDocStd::Find (aDocApp))
- {
- return 1;
- }
+ Handle(TDocStd_Application) aDocApp = DDocStd::GetApplication();
aDocApp->Close (aDoc);
- Handle(Draw_Drawable3D) aDrawable = Draw::Get (aDocName, Standard_False);
- dout.RemoveDrawable (aDrawable);
+ if (Handle(Draw_Drawable3D) aDrawable = Draw::GetExisting (aDocName))
+ {
+ dout.RemoveDrawable (aDrawable);
+ }
Draw::Set (theArgVec[1], Handle(Draw_Drawable3D)());
return 0;
}
const char** a)
{
if (nb == 2) {
- Handle(TDocStd_Application) A;
- if (!DDocStd::Find(A)) return 1;
+ Handle(TDocStd_Application) A = DDocStd::GetApplication();
di << A->IsInSession(a[1]);
return 0;
}
{
if (nb == 2) {
TDocStd_PathParser path (a[1]);
- //cout << "Trek : " << path.Trek() << endl;
- //cout << "Name : " << path.Name() << endl;
- //cout << "Extension : " << path.Extension() << endl;
- //cout << "Path : " << path.Path() << endl;
+ //std::cout << "Trek : " << path.Trek() << std::endl;
+ //std::cout << "Name : " << path.Name() << std::endl;
+ //std::cout << "Extension : " << path.Extension() << std::endl;
+ //std::cout << "Path : " << path.Path() << std::endl;
TCollection_AsciiString TrekAsciiString(path.Trek().ToExtString(),'?');
TCollection_AsciiString NameAsciiString(path.Name().ToExtString(),'?');
TCollection_AsciiString ExtensionAsciiString(path.Extension().ToExtString(),'?');
Handle(TDocStd_Document) D;
if (!DDocStd::GetDocument(a[1],D)) return 1;
TCollection_ExtendedString comment (a[2]);
-// Handle(TDocStd_Application) A;
-// if (!DDocStd::Find(A)) return 1;
+// Handle(TDocStd_Application) A = DDocStd::GetApplication();
// A->AddComment(D,comment);
D->AddComment(comment);
return 0;
for (int i = 1; i <= comments.Length(); i++)
{
- //cout << comments(i) << endl;
+ //std::cout << comments(i) << std::endl;
TCollection_AsciiString commentAsciiString(comments(i).ToExtString(),'?');
di << commentAsciiString.ToCString() << "\n";
}
return 1;
}
+//=======================================================================
+//function : SetStorageVerison
+//purpose :
+//=======================================================================
+static Standard_Integer DDocStd_SetStorageVersion (Draw_Interpretor& ,
+ Standard_Integer nb,
+ const char** a)
+{
+ if (nb == 3)
+ {
+ Handle(TDocStd_Document) D;
+ if (!DDocStd::GetDocument(a[1], D)) return 1;
+ const int version = atoi(a[2]);
+ D->ChangeStorageFormatVersion(version);
+ return 0;
+ }
+ return 1;
+}
+
+//=======================================================================
+//function : GetStorageVerison
+//purpose :
+//=======================================================================
+static Standard_Integer DDocStd_GetStorageVersion (Draw_Interpretor& di,
+ Standard_Integer nb,
+ const char** a)
+{
+ if (nb == 2) {
+ Handle(TDocStd_Document) D;
+ if (!DDocStd::GetDocument(a[1], D)) return 1;
+ di << D->StorageFormatVersion() << "\n";
+ return 0;
+ }
+ return 1;
+}
+
//=======================================================================
//function : ApplicationCommands
//purpose :
__FILE__, DDocStd_NewDocument, g);
theCommands.Add("Open",
- "Open path docname",
+ "Open path docname [-stream]",
__FILE__, DDocStd_Open, g);
theCommands.Add("SaveAs",
- "SaveAs DOC path",
+ "SaveAs DOC path [saveEmptyLabels: 0|1] [-stream]",
__FILE__, DDocStd_SaveAs, g);
theCommands.Add("Save",
theCommands.Add("PrintComments",
"PrintComments Doc",
__FILE__, DDocStd_PrintComments, g);
+
+ theCommands.Add("GetStorageVersion",
+ "GetStorageVersion Doc",
+ __FILE__, DDocStd_GetStorageVersion, g);
+ theCommands.Add("SetStorageVersion",
+ "SetStorageVersion Doc Version",
+ __FILE__, DDocStd_SetStorageVersion, g);
}