Debian Codegraph @

apps/converters/ivdowngrade/SoFontStyleV2.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 | Classes:
44 | SoFontStyleV2
45 |
46 | Authors: David Mott
47 |
48 ______________ S I L I C O N G R A P H I C S I N C . ____________
49 _______________________________________________________________________
50 */
51
52 #include <Inventor/actions/SoWriteAction.h>
53 #include <Inventor/nodes/SoFont.h>
54 #include "SoFontStyleV2.h"
55 #include "Util.h"
56
57 SO_NODE_SOURCE(SoFontStyleV2);
58
59 ////////////////////////////////////////////////////////////////////////
60 //
61 // Description:
62 // init that class!
63 //
64 void
65 SoFontStyleV2::initClass()
66 //
67 ////////////////////////////////////////////////////////////////////////
68 {
69 SO__NODE_INIT_CLASS(SoFontStyleV2, "FontStyle", SoFontStyle);
70
71 // Tell the type system whenever it wants to create something
72 // of type SoFontStyle to create a SoFontStyleV2
73 SoType::overrideType(
74 SoFontStyle::getClassTypeId(), &SoFontStyleV2::createInstance);
75 }
76
77 ////////////////////////////////////////////////////////////////////////
78 //
79 // Description:
80 // Constructor
81 //
82 SoFontStyleV2::SoFontStyleV2()
83 //
84 ////////////////////////////////////////////////////////////////////////
85 {
86 SO_NODE_CONSTRUCTOR(SoFontStyleV2);
87 SO_NODE_ADD_FIELD(alternateRep, (NULL));
88 }
89
90 ////////////////////////////////////////////////////////////////////////
91 //
92 // Description:
93 // Destructor
94 //
95 SoFontStyleV2::~SoFontStyleV2()
96 //
97 ////////////////////////////////////////////////////////////////////////
98 {
99
100 }
101
102 ////////////////////////////////////////////////////////////////////////
103 //
104 // Description:
105 // write the alternate rep for this node
106 //
107 void
108 SoFontStyleV2::write(SoWriteAction *action)
109 //
110 ////////////////////////////////////////////////////////////////////////
111 {
112 SoOutput *out = action->getOutput();
113
114 // In write-reference counting phase
115 if (out->getStage() == SoOutput::COUNT_REFS) {
116 // Only do this once!
117 if (alternateRep.isDefault()) {
118 SoFont *font = new SoFont;
119 alternateRep = font;
120
121 // Set the Font name based on the FontStyle family and style
122 font->name = getFontName();
123
124 COPY_FIELD(font, this, size);
125
126 // Inventor V2.0 cannot read unknown nodes with SoSFEnum or SoSFBitMask fields.
127 // Don't let any enums get written out.
128 // NOTE: a better solution might be to write the enum as a string,
129 // and have the upgrader for this node convert that string back
130 // to an enum value. But this bug was found too close to the 2.1 MR date
131 // to do that more complicated fix. Instead, just don't write the enum.
132 family.setDefault(TRUE);
133 style.setDefault(TRUE);
134 }
135 }
136
137 SoFontStyle::write(action);
138 }
139