Debian Codegraph @

lib/database/src/so/upgraders/SoV2FontStyle.c++

raw
1 /*
2 *
3 * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
27 * Mountain View, CA 94043, or:
28 *
29 * http://www.sgi.com
30 *
31 * For further information regarding this notice, see:
32 *
33 * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
34 *
35 */
36
37 /*
38 * Copyright (C) 1995-96 Silicon Graphics, Inc.
39 *
40 _______________________________________________________________________
41 ______________ S I L I C O N G R A P H I C S I N C . ____________
42 |
43 | $Revision: 1.1.1.1 $
44 |
45 | Classes:
46 | SoV2FontStyle
47 |
48 | Author(s) : David Mott
49 |
50 ______________ S I L I C O N G R A P H I C S I N C . ____________
51 _______________________________________________________________________
52 */
53
54 #include "SoV2FontStyle.h"
55 #include <Inventor/nodes/SoFontStyle.h>
56 #include <Inventor/elements/SoFontNameElement.h>
57 #include <Inventor/elements/SoFontSizeElement.h>
58 #include <Inventor/errors/SoReadError.h>
59
60 SO_NODE_SOURCE(SoV2FontStyle);
61
62 ////////////////////////////////////////////////////////////////////////
63 //
64 // Description:
65 // Default constructor
66 //
67 // Use: public
68
69 SoV2FontStyle::SoV2FontStyle()
70 //
71 ////////////////////////////////////////////////////////////////////////
72 {
73 SO_NODE_CONSTRUCTOR(SoV2FontStyle);
74
75 SO_NODE_ADD_FIELD(family, (SERIF));
76 SO_NODE_ADD_FIELD(style, (NONE));
77 SO_NODE_ADD_FIELD(name, (SoFontNameElement::getDefault()));
78 SO_NODE_ADD_FIELD(size, (SoFontSizeElement::getDefault()));
79 SO_NODE_ADD_FIELD(alternateRep, (NULL));
80
81 // Set up static info for enumerated type field
82 SO_NODE_DEFINE_ENUM_VALUE(Family, SERIF);
83 SO_NODE_DEFINE_ENUM_VALUE(Family, SANS);
84 SO_NODE_DEFINE_ENUM_VALUE(Family, TYPEWRITER);
85
86 SO_NODE_DEFINE_ENUM_VALUE(Style, NONE);
87 SO_NODE_DEFINE_ENUM_VALUE(Style, BOLD);
88 SO_NODE_DEFINE_ENUM_VALUE(Style, ITALIC);
89
90 // Set up info in enumerated type field
91 SO_NODE_SET_SF_ENUM_TYPE(family, Family);
92 SO_NODE_SET_SF_ENUM_TYPE(style, Style);
93 }
94
95 ////////////////////////////////////////////////////////////////////////
96 //
97 // Description:
98 // Destructor.
99 //
100 // Use: private
101
102 SoV2FontStyle::~SoV2FontStyle()
103 //
104 ////////////////////////////////////////////////////////////////////////
105 {
106 }
107
108 ////////////////////////////////////////////////////////////////////////
109 //
110 // Description:
111 // Create a version 2.1 FontStyle.
112 //
113 // Use: private
114
115 SoNode *
116 SoV2FontStyle::createNewNode()
117 //
118 ////////////////////////////////////////////////////////////////////////
119 {
120 SoFontStyle *result = SO_UPGRADER_CREATE_NEW(SoFontStyle);
121
122 //
123 // Inventor 2.0 did not have FontStyle. When we convert 2.1 to 2.0 files,
124 // the FontStyle gets written with an alternateRep. When we read that 2.0
125 // file back into 2.1, we can discard the alternateRep. Programs written
126 // with 2.0 will gladly use the alternateRep.
127 //
128
129 // Copy all fields as is (except alternateRep which is ignored)
130 SO_UPGRADER_COPY_FIELD(name, result);
131 SO_UPGRADER_COPY_FIELD(size, result);
132 SO_UPGRADER_COPY_FIELD(family, result);
133 SO_UPGRADER_COPY_FIELD(style, result);
134
135 return result;
136 }
137 ////////////////////////////////////////////////////////////////////////
138 //
139 // Description:
140 // special upgrade method to read field description
141 //
142 // Use: public, internal, virtual
143 SbBool
144 SoV2FontStyle::upgrade(SoInput *in, const SbName &refName, SoBase *&result)
145 //
146 ////////////////////////////////////////////////////////////////////////
147 {
148 SbBool isBinary = in->isBinary();
149 if (in->isBinary()){
150 SbString unknownString;
151 SbBool readOK = in->read(unknownString);
152 if (!readOK || (unknownString != "fields" )) {
153 SoReadError::post(in, "Problem upgrading vertex property ") ;
154 return FALSE;
155 }
156 }
157 SbBool ret = SoUpgrader::upgrade(in, refName, result);
158
159 if (in->isBinary()){
160 // Read a zero, which represents the number of children here
161 int dummy;
162 in->read(dummy);
163 }
164
165 return ret;
166 }