Coin Logo Coin3D is Free Software,
published under the BSD 3-clause license.
https://bitbucket.org/Coin3D/
http://www.kongsberg.com/kogt/
SoVectorizeAction.h
1 #ifndef COIN_SOVECTORIZEACTION_H
2 #define COIN_SOVECTORIZEACTION_H
3 
4 /**************************************************************************\
5  * Copyright (c) Kongsberg Oil & Gas Technologies AS
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are
10  * met:
11  *
12  * Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  *
15  * Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in the
17  * documentation and/or other materials provided with the distribution.
18  *
19  * Neither the name of the copyright holder nor the names of its
20  * contributors may be used to endorse or promote products derived from
21  * this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 \**************************************************************************/
35 
37 #include <Inventor/actions/SoSubAction.h>
38 #include <Inventor/SbVec2f.h>
39 #include <Inventor/SbColor.h>
40 
41 class SoVectorOutput;
42 class SbViewportRegion;
43 class SoVectorizeItem;
44 class SoVectorizeActionP;
45 class SbBSPTree;
46 
47 // *************************************************************************
48 
49 class COIN_DLL_API SoVectorizeAction : public SoCallbackAction {
51 
52  SO_ACTION_HEADER(SoVectorizeAction);
53 
54 public:
55  SoVectorizeAction(void);
56  virtual ~SoVectorizeAction();
57 
58  SoVectorOutput * getOutput(void) const;
59 
60  static void initClass(void);
61 
62  enum DimensionUnit { INCH, MM, METER };
63  enum Orientation { PORTRAIT, LANDSCAPE };
64 
65  enum PageSize {
66  A0 = 0,
67  A1,
68  A2,
69  A3,
70  A4,
71  A5,
72  A6,
73  A7,
74  A8,
75  A9,
76  A10
77  };
78 
79  virtual void apply(SoNode * node);
80  virtual void apply(SoPath * path);
81  virtual void apply(const SoPathList & pathlist, SbBool obeysrules = FALSE);
82 
83  void beginStandardPage(const PageSize & pagesize, const float border = 10.0f);
84 
85  virtual void beginPage(const SbVec2f & startpagepos,
86  const SbVec2f & pagesize,
87  DimensionUnit u = MM);
88  virtual void endPage(void);
89 
90  virtual void calibrate(const SbViewportRegion & vp);
91 
92  virtual void beginViewport(const SbVec2f & startpos = SbVec2f(-1.0f, 1.0f),
93  const SbVec2f & size = SbVec2f(-1.0f, -1.0f),
94  DimensionUnit u = MM);
95  virtual void endViewport(void);
96 
97  virtual void setOrientation(Orientation o);
98  virtual Orientation getOrientation(void) const;
99 
100  virtual void setBackgroundColor(SbBool bg, const SbColor & col = SbColor(0.0f, 0.0f, 0.0f));
101  virtual SbBool getBackgroundColor(SbColor & col) const;
102 
103  virtual void setNominalWidth(float w, DimensionUnit u = MM);
104  virtual float getNominalWidth(DimensionUnit u = MM) const;
105 
106  virtual void setPixelImageSize(float w, DimensionUnit u = MM);
107  virtual float getPixelImageSize(DimensionUnit u = MM) const;
108 
109  enum PointStyle {
111  SQUARE
112  };
113 
114  virtual void setPointStyle(const PointStyle & style);
115  virtual PointStyle getPointStyle(void) const;
116 
117  const SbVec2f & getPageStartpos(void) const;
118  const SbVec2f & getPageSize(void) const;
119 
120 public:
121  // for TGS OIV compatibility. Might be implemented in the future
122  enum ColorTranslationMethod { REVERSE_ONLY_BLACK_AND_WHITE, AS_IS, REVERSE };
123 
124  enum JoinLineStyle { NO_JOIN, MITERED_JOIN, MITERED_BEVELED_JOIN,
125  BEVELED_JOIN, TRIANGULAR_JOIN, ROUNDED_JOIN } ;
126  enum EndLineStyle { BUTT_END, SQUARE_END, TRIANGULAR_END, ROUND_END };
127  enum HLHSRMode { NO_HLHSR, HLHSR_SIMPLE_PAINTER, HLHSR_PAINTER,
128  HLHSR_PAINTER_SURFACE_REMOVAL, HIDDEN_LINES_REMOVAL };
129 
130  virtual void setDrawingDimensions(const SbVec2f & d, DimensionUnit u = MM);
131  virtual void setDrawingDimensions(float w, float h, DimensionUnit u = MM) { this->setDrawingDimensions(SbVec2f(w, h), u); }
132  virtual SbVec2f getDrawingDimensions(DimensionUnit u = MM) const;
133 
134  virtual void setStartPosition(const SbVec2f & p, DimensionUnit u = MM);
135  virtual void setStartPosition(float x, float y, DimensionUnit u = MM) { this->setStartPosition(SbVec2f(x, y), u); }
136  virtual SbVec2f getStartPosition(DimensionUnit u = MM) const;
137 
138  virtual void setColorTranslationMethod(ColorTranslationMethod method);
139  virtual ColorTranslationMethod getColorTranslationMethod(void) const;
140 
141  virtual void setLineEndStyle(EndLineStyle style);
142  virtual EndLineStyle getLineEndStyle(void) const;
143 
144  virtual void setLineJoinsStyle(JoinLineStyle style);
145  virtual JoinLineStyle getLineJoinsStyle(void) const;
146 
147  virtual void setHLHSRMode(HLHSRMode mode);
148  HLHSRMode getHLHSRMode(void) const;
149 
150  virtual void setBorder(float width);
151  virtual void setBorder (float width, SbColor color);
152 
153  virtual void setMiterLimit(float limit);
154  virtual float getMiterLimit(void) const;
155 
156  virtual void setPenDescription(int num_pens,
157  const SbColor* colors = 0,
158  const float * widths = 0,
159  DimensionUnit u = MM);
160  virtual void getPenDescription(SbColor * colors,
161  float * widths,
162  DimensionUnit u = MM) const;
163  virtual int getPenNum(void) const;
164 
165  virtual void setColorPriority(SbBool priority);
166  virtual SbBool getColorPriority(void) const;
167 
168  virtual void enableLighting(SbBool flag);
169  SbBool isLightingEnabled(void) const;
170 
171 protected:
172  void setOutput(SoVectorOutput * output);
173 
174  virtual float pixelsToUnits(const int pixels);
175  virtual void printHeader(void) const = 0;
176  virtual void printFooter(void) const;
177  virtual void printBackground(void) const;
178  virtual void printItem(const SoVectorizeItem * item) const = 0;
179  virtual void printViewport(void) const;
180 
181  SbVec2f getRotatedViewportStartpos(void) const;
182  SbVec2f getRotatedViewportSize(void) const;
183 
184  const SbBSPTree & getBSPTree(void) const;
185 
186 private:
187  SoVectorizeActionP * pimpl;
188  friend class SoVectorizeActionP;
189 };
190 
191 // *************************************************************************
192 
193 #ifndef COIN_INTERNAL
194 // For SGI / TGS Open Inventor compile-time compatibility.
195 #include <Inventor/nodes/SoImage.h>
196 #endif // COIN_INTERNAL
197 
198 // *************************************************************************
199 
200 #endif // !COIN_SOVECTORIZEACTION_H
The SbVec2f class is a 2 dimensional vector with floating point coordinates.
Definition: SbVec2f.h:49
The SbColor class contains the red, green and blue components which make up a color value...
Definition: SbColor.h:39
Definition: SoVectorizeAction.h:110
The SoVectorizeAction class is the base class for vectorizing Coin scene graphs.
Definition: SoVectorizeAction.h:49
The SoPathList class is a container for pointers to SoPath objects.
Definition: SoPathList.h:40
Definition: SoVectorizeAction.h:67
The SoNode class is the base class for nodes used in scene graphs.
Definition: SoNode.h:56
Definition: SoVectorizeAction.h:75
DimensionUnit
Definition: SoVectorizeAction.h:62
The SbBSPTree class provides a binary space partitioning container.
Definition: SbBSPTree.h:54
The SoVectorOutput class is used for setting vector output file.
Definition: SoVectorOutput.h:43
The SoPath class is a container class for traversal path descriptions.
Definition: SoPath.h:52
Definition: SoVectorizeAction.h:73
PointStyle
Definition: SoVectorizeAction.h:109
The SoAction class is the base class for all traversal actions.
Definition: SoAction.h:77
Orientation
Definition: SoVectorizeAction.h:63
Definition: SoVectorizeAction.h:72
Definition: SoVectorizeAction.h:68
Definition: SoVectorizeAction.h:74
Definition: SoVectorizeAction.h:71
The SoCallbackAction class invokes callbacks at specific nodes.
Definition: SoCallbackAction.h:80
The SbViewportRegion class is a viewport within a full window.
Definition: SbViewportRegion.h:40
PageSize
Definition: SoVectorizeAction.h:65
virtual void apply(SoNode *root)
Definition: SoAction.cpp:463
Definition: SoVectorizeAction.h:69
Definition: SoVectorizeAction.h:70