// Created on: 2008-06-07
// Created by: Pavel TELKOV
-// Copyright (c) 2008-2012 OPEN CASCADE SAS
+// Copyright (c) 2008-2014 OPEN CASCADE SAS
//
-// The content of this file is subject to the Open CASCADE Technology Public
-// License Version 6.5 (the "License"). You may not use the content of this file
-// except in compliance with the License. Please obtain a copy of the License
-// at http://www.opencascade.org and read it completely before using this file.
+// This file is part of Open CASCADE Technology software library.
//
-// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License 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.
//
-// The Original Code and all software distributed under the License is
-// distributed on an "AS IS" basis, without warranty of any kind, and the
-// Initial Developer hereby disclaims all such warranties, including without
-// limitation, any warranties of merchantability, fitness for a particular
-// purpose or non-infringement. Please see the License for the specific terms
-// and conditions governing the rights and limitations under the License.
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
-
-#include <TObjDRAW.ixx>
-#include <stdio.h>
-
-#include <TObj_Model.hxx>
-#include <TObj_TModel.hxx>
-#include <TObj_Object.hxx>
-#include <TObj_ObjectIterator.hxx>
-#include <TObj_TNameContainer.hxx>
-
-#include <Message_MsgFile.hxx>
-#include <Standard_DefineHandle.hxx>
-#include <TColStd_HArray1OfReal.hxx>
-#include <TCollection_ExtendedString.hxx>
-
-#include <Draw.hxx>
-
#include <DDocStd.hxx>
#include <DDocStd_DrawDocument.hxx>
-
-#include <TDF_Tool.hxx>
-#include <TDF_Data.hxx>
+#include <Draw.hxx>
+#include <Draw_PluginMacro.hxx>
+#include <Message_MsgFile.hxx>
+#include <Standard_Type.hxx>
+#include <TCollection_ExtendedString.hxx>
+#include <TColStd_HArray1OfReal.hxx>
#include <TDataStd_Name.hxx>
+#include <TDF_Data.hxx>
+#include <TDF_Tool.hxx>
#include <TDocStd_Document.hxx>
+#include <TObj_Application.hxx>
+#include <TObj_Model.hxx>
+#include <TObj_Object.hxx>
+#include <TObj_ObjectIterator.hxx>
+#include <TObj_TModel.hxx>
+#include <TObj_TNameContainer.hxx>
+#include <TObjDRAW.hxx>
-#include <Draw_PluginMacro.hxx>
+#include <BinTObjDrivers.hxx>
+#include <XmlTObjDrivers.hxx>
-// avoid warnings on 'extern "C"' functions returning C++ classes
-#ifdef WNT
-#pragma warning(4:4190)
-#endif
+#include <stdio.h>
//=======================================================================
// Section: General commands
//=======================================================================
-class Handle(TObjDRAW_Model);
//! simple model with redefined pure virtual method
class TObjDRAW_Model : public TObj_Model
Standard_EXPORT TObjDRAW_Model()
: TObj_Model() {}
- virtual Standard_EXPORT Handle(TObj_Model) NewEmpty()
+ virtual Standard_EXPORT Handle(TObj_Model) NewEmpty() Standard_OVERRIDE
{
return new TObjDRAW_Model();
}
public:
//! CASCADE RTTI
- DEFINE_STANDARD_RTTI(TObjDRAW_Model)
+ DEFINE_STANDARD_RTTI_INLINE(TObjDRAW_Model,TObj_Model)
};
DEFINE_STANDARD_HANDLE (TObjDRAW_Model,TObj_Model)
-
-IMPLEMENT_STANDARD_HANDLE(TObjDRAW_Model,TObj_Model)
-IMPLEMENT_STANDARD_RTTIEXT(TObjDRAW_Model,TObj_Model)
-class Handle(TObjDRAW_Object);
+
//! simple object to check API and features of TObj_Object
class TObjDRAW_Object : public TObj_Object
public:
// Declaration of CASCADE RTTI
- DEFINE_STANDARD_RTTI (TObjDRAW_Object)
+ DEFINE_STANDARD_RTTI_INLINE(TObjDRAW_Object,TObj_Object)
};
// Definition of HANDLE object using Standard_DefineHandle.hxx
DEFINE_STANDARD_HANDLE (TObjDRAW_Object,TObj_Object)
-IMPLEMENT_STANDARD_HANDLE (TObjDRAW_Object,TObj_Object)
-IMPLEMENT_STANDARD_RTTIEXT(TObjDRAW_Object,TObj_Object)
+
IMPLEMENT_TOBJOCAF_PERSISTENCE(TObjDRAW_Object)
//=======================================================================
if (!DDocStd::GetDocument(argv[1],D,Standard_False)) {
Handle(TObjDRAW_Model) aModel = new TObjDRAW_Model();
- aModel->Load(0);
+ // initializes the new model: filename is empty
+ aModel->Load("");
D = aModel->GetDocument();
DD = new DDocStd_DrawDocument(D);
TDataStd_Name::Set(D->GetData()->Root(),argv[1]);
Draw::Set(argv[1],DD);
- di << "document " << argv[1] << " created" << "\n";
+ di << "document " << argv[1] << " created\n";
}
- else di << argv[1] << " is already a document" << "\n";
+ else di << argv[1] << " is already a document\n";
return 0;
}
isSaved = aModel->Save();
if (!isSaved) {
- di << "Error: Document not saved" << "\n";
+ di << "Error: Document not saved\n";
return 1;
}
return 0;
if (!isLoaded) {
- di << "Error: Document not loaded" << "\n";
+ di << "Error: Document not loaded\n";
return 1;
}
return 0;
new TObjDRAW_Object( aModel->GetMainPartition()->NewLabel() );
if ( tObj.IsNull() )
{
- di << "Error: Object not created" << "\n";
+ di << "Error: Object not created\n";
return 1;
}
tObj->SetName( argv[2] );
Handle(TObjDRAW_Object) tObj = getObjByName( argv[1], argv[2] );
if ( tObj.IsNull() )
{
- di << "Error: Object " << argv[2] << " not found" << "\n";
+ di << "Error: Object " << argv[2] << " not found\n";
return 1;
}
if ( !strcmp(argv[3],"-r") )
Handle(TObjDRAW_Object) tObj = getObjByName( argv[1], argv[2] );
if ( tObj.IsNull() )
{
- di << "Error: Object " << argv[2] << " not found" << "\n";
+ di << "Error: Object " << argv[2] << " not found\n";
return 1;
}
if ( !strcmp(argv[3],"-i") )
Handle(TObjDRAW_Object) tObj2 = getObjByName( argv[1], argv[3] );
if ( tObj1.IsNull() || tObj2.IsNull() )
{
- di << "Error: Object " << argv[2] << " or object " << argv[3] << " not found" << "\n";
+ di << "Error: Object " << argv[2] << " or object " << argv[3] << " not found\n";
return 1;
}
tObj1->SetRef( tObj2 );
Handle(TObjDRAW_Object) tObj = getObjByName( argv[1], argv[2] );
if ( tObj.IsNull() )
{
- di << "Error: Object " << argv[2] << " not found" << "\n";
+ di << "Error: Object " << argv[2] << " not found\n";
return 1;
}
Handle(TObj_Object) aRefObj = tObj->GetRef();
Handle(TObjDRAW_Object) tObj = getObjByName( argv[1], argv[2] );
if ( tObj.IsNull() )
{
- di << "Error: Object " << argv[2] << " not found" << "\n";
+ di << "Error: Object " << argv[2] << " not found\n";
return 1;
}
Handle(TObj_Object) chldObj = tObj->AddChild();
if ( chldObj.IsNull() )
{
- di << "Error: No child object created" << "\n";
+ di << "Error: No child object created\n";
return 1;
}
chldObj->SetName( new TCollection_HExtendedString( argv[3] ) );
Handle(TObjDRAW_Object) tObj = getObjByName( argv[1], argv[2] );
if ( tObj.IsNull() )
{
- di << "Error: Object " << argv[2] << " not found" << "\n";
+ di << "Error: Object " << argv[2] << " not found\n";
return 1;
}
Handle(TObj_ObjectIterator) anItr = tObj->GetChildren();
void TObjDRAW::Init(Draw_Interpretor& di)
{
-
static Standard_Boolean initactor = Standard_False;
- if (initactor) return; initactor = Standard_True;
+ if (initactor)
+ {
+ return;
+ }
+ initactor = Standard_True;
- // load TObjOcaf base data model messages
- Message_MsgFile::Load( ::getenv( "CSF_TObjResources" ), "TObj.msg" );
-
//=====================================
// General commands
//=====================================
//==============================================================================
void TObjDRAW::Factory(Draw_Interpretor& theDI)
{
+ // Initialize TObj OCAF formats
+ Handle(TDocStd_Application) anApp = DDocStd::GetApplication();
+ BinTObjDrivers::DefineFormat(anApp);
+ XmlTObjDrivers::DefineFormat(anApp);
+
+ // define formats for TObj specific application
+ anApp = TObj_Application::GetInstance();
+ BinTObjDrivers::DefineFormat(anApp);
+ XmlTObjDrivers::DefineFormat(anApp);
+
TObjDRAW::Init(theDI);
-#ifdef DEB
- theDI << "Draw Plugin : All TKTObjDRAW commands are loaded" << "\n";
+#ifdef OCCT_DEBUG
+ theDI << "Draw Plugin : All TKTObjDRAW commands are loaded\n";
#endif
}