* 3D viewer printing API *V3d_View::Print()* has been removed. This functionality was available on Windows platforms only.
Applications should use general image dump API *V3d_View::ToPixMap()* and manage printing using platform-specific API at application level.
Text resolution can be managed by rendering parameter *Graphic3d_RenderingParams::Resolution*, returned by *V3d_View::ChangeRenderingParams()*.
+
+@subsection upgrade_occt710_correction_of_TObj_Model Correction in TObj_Model class
+
+Methods *TObj_Model::SaveAs* and *TObj_Model::Load* receive *TCollection_ExtendedString* filename arguments instead of char*. This shows that the filename may be not-ASCII explicitly. Also it makes OCAF API related to this functionality more conform.
//=======================================================================
Standard_Boolean TObj_Application::SaveDocument
- (const Handle(TDocStd_Document)& theSourceDoc,
- const char* theTargetFile)
+ (const Handle(TDocStd_Document)& theSourceDoc,
+ const TCollection_ExtendedString theTargetFile)
{
myIsError = Standard_False;
- TCollection_ExtendedString aPath ((const Standard_CString)theTargetFile);
-
- PCDM_StoreStatus aStatus = SaveAs (theSourceDoc, aPath);
+ PCDM_StoreStatus aStatus = SaveAs (theSourceDoc, theTargetFile);
myIsError = aStatus != PCDM_SS_OK;
if (myIsError)
{
switch (aStatus)
{
case PCDM_SS_DriverFailure:
- ErrorMessage (Message_Msg("TObj_Appl_SDriverFailure") << aPath);
+ ErrorMessage (Message_Msg("TObj_Appl_SDriverFailure") << theTargetFile);
break;
case PCDM_SS_WriteFailure:
- ErrorMessage (Message_Msg("TObj_Appl_SWriteFailure") << aPath);
+ ErrorMessage (Message_Msg("TObj_Appl_SWriteFailure") << theTargetFile);
break;
case PCDM_SS_Failure:
- ErrorMessage (Message_Msg("TObj_Appl_SFailure") << aPath);
+ ErrorMessage (Message_Msg("TObj_Appl_SFailure") << theTargetFile);
break;
case PCDM_SS_Doc_IsNull:
- ErrorMessage (Message_Msg("TObj_Appl_SDocIsNull") << aPath);
+ ErrorMessage (Message_Msg("TObj_Appl_SDocIsNull") << theTargetFile);
break;
case PCDM_SS_No_Obj:
- ErrorMessage (Message_Msg("TObj_Appl_SNoObj") << aPath);
+ ErrorMessage (Message_Msg("TObj_Appl_SNoObj") << theTargetFile);
break;
case PCDM_SS_Info_Section_Error:
- ErrorMessage (Message_Msg("TObj_Appl_SInfoSectionError") << aPath);
+ ErrorMessage (Message_Msg("TObj_Appl_SInfoSectionError") << theTargetFile);
break;
default:
- ErrorMessage (Message_Msg("TObj_Appl_SUnknownFailure") << aPath);
+ ErrorMessage (Message_Msg("TObj_Appl_SUnknownFailure") << theTargetFile);
break;
}
}
//=======================================================================
Standard_Boolean TObj_Application::LoadDocument
- (const char* theSourceFile,
- Handle(TDocStd_Document)& theTargetDoc)
+ (const TCollection_ExtendedString theSourceFile,
+ Handle(TDocStd_Document)& theTargetDoc)
{
myIsError = Standard_False;
- TCollection_ExtendedString aPath ((const Standard_CString)theSourceFile);
-
PCDM_ReaderStatus aStatus = PCDM_RS_ReaderException;
{
try
{
- aStatus = Open (aPath, theTargetDoc);
+ aStatus = Open (theSourceFile, theTargetDoc);
}
catch (Standard_Failure)
{
switch (aStatus)
{
case PCDM_RS_UnknownDocument:
- ErrorMessage (Message_Msg("TObj_Appl_RUnknownDocument") << aPath);
+ ErrorMessage (Message_Msg("TObj_Appl_RUnknownDocument") << theSourceFile);
break;
case PCDM_RS_AlreadyRetrieved:
- ErrorMessage (Message_Msg("TObj_Appl_RAlreadyRetrieved") << aPath);
+ ErrorMessage (Message_Msg("TObj_Appl_RAlreadyRetrieved") << theSourceFile);
break;
case PCDM_RS_AlreadyRetrievedAndModified:
- ErrorMessage (Message_Msg("TObj_Appl_RAlreadyRetrievedAndModified") << aPath);
+ ErrorMessage (Message_Msg("TObj_Appl_RAlreadyRetrievedAndModified") << theSourceFile);
break;
case PCDM_RS_NoDriver:
- ErrorMessage (Message_Msg("TObj_Appl_RNoDriver") << aPath);
+ ErrorMessage (Message_Msg("TObj_Appl_RNoDriver") << theSourceFile);
break;
case PCDM_RS_UnknownFileDriver:
- ErrorMessage (Message_Msg("TObj_Appl_RNoDriver") << aPath);
+ ErrorMessage (Message_Msg("TObj_Appl_RNoDriver") << theSourceFile);
break;
case PCDM_RS_OpenError:
- ErrorMessage (Message_Msg("TObj_Appl_ROpenError") << aPath);
+ ErrorMessage (Message_Msg("TObj_Appl_ROpenError") << theSourceFile);
break;
case PCDM_RS_NoVersion:
- ErrorMessage (Message_Msg("TObj_Appl_RNoVersion") << aPath);
+ ErrorMessage (Message_Msg("TObj_Appl_RNoVersion") << theSourceFile);
break;
case PCDM_RS_NoModel:
- ErrorMessage (Message_Msg("TObj_Appl_RNoModel") << aPath);
+ ErrorMessage (Message_Msg("TObj_Appl_RNoModel") << theSourceFile);
break;
case PCDM_RS_NoDocument:
- ErrorMessage (Message_Msg("TObj_Appl_RNoDocument") << aPath);
+ ErrorMessage (Message_Msg("TObj_Appl_RNoDocument") << theSourceFile);
break;
case PCDM_RS_FormatFailure:
- ErrorMessage (Message_Msg("TObj_Appl_RFormatFailure") << aPath);
+ ErrorMessage (Message_Msg("TObj_Appl_RFormatFailure") << theSourceFile);
break;
case PCDM_RS_TypeNotFoundInSchema:
- ErrorMessage (Message_Msg("TObj_Appl_RTypeNotFound") << aPath);
+ ErrorMessage (Message_Msg("TObj_Appl_RTypeNotFound") << theSourceFile);
break;
case PCDM_RS_UnrecognizedFileFormat:
- ErrorMessage (Message_Msg("TObj_Appl_RBadFileFormat") << aPath);
+ ErrorMessage (Message_Msg("TObj_Appl_RBadFileFormat") << theSourceFile);
break;
case PCDM_RS_MakeFailure:
- ErrorMessage (Message_Msg("TObj_Appl_RMakeFailure") << aPath);
+ ErrorMessage (Message_Msg("TObj_Appl_RMakeFailure") << theSourceFile);
break;
case PCDM_RS_PermissionDenied:
- ErrorMessage (Message_Msg("TObj_Appl_RPermissionDenied") << aPath);
+ ErrorMessage (Message_Msg("TObj_Appl_RPermissionDenied") << theSourceFile);
break;
case PCDM_RS_DriverFailure:
- ErrorMessage (Message_Msg("TObj_Appl_RDriverFailure") << aPath);
+ ErrorMessage (Message_Msg("TObj_Appl_RDriverFailure") << theSourceFile);
break;
case PCDM_RS_ReaderException:
- ErrorMessage (Message_Msg("TObj_Appl_RException") << aPath);
+ ErrorMessage (Message_Msg("TObj_Appl_RException") << theSourceFile);
break;
default:
- ErrorMessage (Message_Msg("TObj_Appl_RUnknownFail") << aPath);
+ ErrorMessage (Message_Msg("TObj_Appl_RUnknownFail") << theSourceFile);
break;
}
}
//! Saving the OCAF document to a file
virtual Standard_EXPORT Standard_Boolean SaveDocument
- (const Handle(TDocStd_Document)& theSourceDoc,
- const char* theTargetFile);
+ (const Handle(TDocStd_Document)& theSourceDoc,
+ const TCollection_ExtendedString theTargetFile);
//! Loading the OCAF document from a file
virtual Standard_EXPORT Standard_Boolean LoadDocument
- (const char* theSourceFile,
- Handle(TDocStd_Document)& theTargetDoc);
+ (const TCollection_ExtendedString theSourceFile,
+ Handle(TDocStd_Document)& theTargetDoc);
//! Create the OCAF document from scratch
virtual Standard_EXPORT Standard_Boolean CreateNewDocument
//purpose : Loads the model from the file
//=======================================================================
-Standard_Boolean TObj_Model::Load (const char* theFile)
+Standard_Boolean TObj_Model::Load (const TCollection_ExtendedString theFile)
{
// Return status
Standard_Boolean aStatus = Standard_True;
else
{
// retrieve TDocStd_Document from <theFile>
- Messenger()->Send(Message_Msg("TObj_M_LoadDocument") << (Standard_CString)theFile,
+ Messenger()->Send(Message_Msg("TObj_M_LoadDocument") << theFile,
Message_Info);
aStatus = anApplication->LoadDocument(theFile,aDoc);
{
if (!aDoc.IsNull()) CloseDocument (aDoc);
myLabel.Nullify();
- Messenger()->Send(Message_Msg("TObj_M_WrongFile") << (Standard_CString)theFile,
+ Messenger()->Send(Message_Msg("TObj_M_WrongFile") << theFile,
Message_Alarm);
aStatus = Standard_False;
}
aString = aString + ": " + anExc->GetMessageString();
Messenger()->Send(Message_Msg("TObj_Appl_Exception") << aString);
#endif
- Messenger()->Send(Message_Msg("TObj_M_WrongFile") << (Standard_CString)theFile,
+ Messenger()->Send(Message_Msg("TObj_M_WrongFile") << theFile,
Message_Alarm);
}
}
// or null if the model was not saved yet
//=======================================================================
-Handle(TCollection_HAsciiString) TObj_Model::GetFile() const
+Handle(TCollection_HExtendedString) TObj_Model::GetFile() const
{
Handle(TDocStd_Document) aDoc = GetDocument();
if ( aDoc.IsNull()
|| !aDoc->IsStored())
{
- return Handle(TCollection_HAsciiString)();
+ return Handle(TCollection_HExtendedString)();
}
- TCollection_AsciiString aPath (aDoc->GetPath());
+ TCollection_ExtendedString aPath(aDoc->GetPath());
return !aPath.IsEmpty()
- ? new TCollection_HAsciiString (aPath)
- : Handle(TCollection_HAsciiString)();
+ ? new TCollection_HExtendedString(aPath)
+ : Handle(TCollection_HExtendedString)();
}
//=======================================================================
Standard_Boolean TObj_Model::Save ()
{
Handle(TDocStd_Document) aDoc = TDocStd_Document::Get(GetLabel());
- if ( aDoc.IsNull() )
+ if (aDoc.IsNull())
return Standard_False;
- TCollection_AsciiString anOldPath( aDoc->GetPath() );
- if ( !anOldPath.IsEmpty() )
- return SaveAs( anOldPath.ToCString() );
+
+ if (!aDoc->GetPath().IsEmpty() )
+ return SaveAs(aDoc->GetPath());
return Standard_True;
}
//purpose : Save the model to a file
//=======================================================================
-Standard_Boolean TObj_Model::SaveAs (const char* theFile)
+Standard_Boolean TObj_Model::SaveAs (const TCollection_ExtendedString theFile)
{
TObj_Assistant::ClearTypeMap();
// OCAF document
if ( aDoc.IsNull() )
return Standard_False;
- // checking that file is present on disk
- /* do not check, because could try to save as new document to existent file
- if(!access(theFile, 0))
- {
- // checking that document has not been changed from last save
- if(!aDoc->IsChanged())
- return Standard_True;
- }
- */
+ // checking that file is present on disk is not needed because could try to save as new
+ // document to existent file
// checking write access permission
FILE *aF = OSD_OpenFile (theFile, "w");
if (aF == NULL) {
- Messenger()->Send (Message_Msg("TObj_M_NoWriteAccess") << (Standard_CString)theFile,
+ Messenger()->Send (Message_Msg("TObj_M_NoWriteAccess") << theFile,
Message_Alarm);
return Standard_False;
}
//purpose : Check whether the document contains the Ocaf data
//=======================================================================
-Standard_Boolean TObj_Model::checkDocumentEmpty (const char* theFile)
+Standard_Boolean TObj_Model::checkDocumentEmpty (const TCollection_ExtendedString theFile)
{
- if (!theFile)
- return Standard_True;
-
- TCollection_AsciiString aFile ((Standard_CString) theFile);
- if (aFile.IsEmpty())
+ if (theFile.IsEmpty())
return Standard_True;
- OSD_Path aPath (aFile);
+ OSD_Path aPath (theFile);
OSD_File osdfile (aPath);
if ( !osdfile.Exists() )
return Standard_True;
Standard_EXPORT ~TObj_Model ();
//! Check whether the document contains the OCAF data.
- //! This implementation checks theFile on NULL only.
- Standard_EXPORT virtual Standard_Boolean checkDocumentEmpty (const char* theFile);
+ Standard_EXPORT virtual Standard_Boolean
+ checkDocumentEmpty(const TCollection_ExtendedString theFile);
public:
/**
* Implementation of Load/Save for OCAF based models
*/
- //! Load the OCAF model from a file
- virtual Standard_EXPORT Standard_Boolean Load (const char* theFile);
+ //! Load the OCAF model from a file. If the filename is empty or file does
+ //! not exists, it just initializes model by empty data.
+ virtual Standard_EXPORT Standard_Boolean Load (const TCollection_ExtendedString theFile);
//! Save the model to a file
- virtual Standard_EXPORT Standard_Boolean SaveAs (const char* theFile);
+ virtual Standard_EXPORT Standard_Boolean SaveAs (const TCollection_ExtendedString theFile);
//! Save the model to the same file
Standard_EXPORT Standard_Boolean Save ();
//! Returns the full file name this model is to be saved to,
//! or null if the model was not saved yet
- virtual Standard_EXPORT Handle(TCollection_HAsciiString) GetFile() const;
+ virtual Standard_EXPORT Handle(TCollection_HExtendedString) GetFile() const;
public:
/**
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]);