0024166: Unable to create file with "Save" menu of voxeldemo Qt sample
[occt.git] / src / XSControl / XSControl_Writer.cxx
CommitLineData
b311480e 1// Copyright (c) 1999-2012 OPEN CASCADE SAS
2//
3// The content of this file is subject to the Open CASCADE Technology Public
4// License Version 6.5 (the "License"). You may not use the content of this file
5// except in compliance with the License. Please obtain a copy of the License
6// at http://www.opencascade.org and read it completely before using this file.
7//
8// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
10//
11// The Original Code and all software distributed under the License is
12// distributed on an "AS IS" basis, without warranty of any kind, and the
13// Initial Developer hereby disclaims all such warranties, including without
14// limitation, any warranties of merchantability, fitness for a particular
15// purpose or non-infringement. Please see the License for the specific terms
16// and conditions governing the rights and limitations under the License.
17
7fd59977 18//:i1 gka 03.04.99 BUC60301
19
20#include <XSControl_Writer.ixx>
21#include <XSControl_Controller.hxx>
22#include <XSControl_TransferWriter.hxx>
23#include <Interface_InterfaceModel.hxx>
24#include <Interface_Macros.hxx>
25
26
b311480e 27XSControl_Writer::XSControl_Writer ()
7fd59977 28{
29 SetWS (new XSControl_WorkSession);
30}
31
32 XSControl_Writer::XSControl_Writer (const Standard_CString norm)
33{
34 SetNorm (norm);
35}
36
37 XSControl_Writer::XSControl_Writer
38 (const Handle(XSControl_WorkSession)& WS, const Standard_Boolean scratch)
39{
40 SetWS (WS,scratch);
41}
42
43 Standard_Boolean XSControl_Writer::SetNorm (const Standard_CString norm)
44{
45 if (thesession.IsNull()) SetWS (new XSControl_WorkSession);
46 Standard_Boolean sess = thesession->SelectNorm (norm);
47 Handle(Interface_InterfaceModel) model = Model (); //:i1 gka 03.04.99 BUC60301
48 return sess;
49}
50
51 void XSControl_Writer::SetWS
52 (const Handle(XSControl_WorkSession)& WS, const Standard_Boolean scratch)
53{
54 thesession = WS;
55// Un controller doit etre defini ...
56 thesession->InitTransferReader(0);
57 Handle(Interface_InterfaceModel) model = Model (scratch);
58}
59
60 Handle(XSControl_WorkSession) XSControl_Writer::WS () const
61 { return thesession; }
62
63 Handle(Interface_InterfaceModel) XSControl_Writer::Model
64 (const Standard_Boolean newone)
65{
66 Handle(Interface_InterfaceModel) model = thesession->Model();
67 if (newone || model.IsNull()) model = thesession->NewModel();
68 return model;
69}
70
71 IFSelect_ReturnStatus XSControl_Writer::TransferShape
72 (const TopoDS_Shape& sh, const Standard_Integer mode)
73{
74 thesession->SetModeWriteShape (mode);
75 return thesession->TransferWriteShape (sh);
76}
77
78 IFSelect_ReturnStatus XSControl_Writer::WriteFile
79 (const Standard_CString filename)
80 { return thesession->SendAll(filename); }
81
82 void XSControl_Writer::PrintStatsTransfer
83 (const Standard_Integer what, const Standard_Integer mode) const
84 { thesession->TransferWriter()->PrintStats (what,mode); }