# SoVectorizeAction.h

    00001 #ifndef COIN_SOVECTORIZEACTION_H
    00002 #define COIN_SOVECTORIZEACTION_H
    00003
    00004 /**************************************************************************\
    00005  *
    00006  *  This file is part of the Coin 3D visualization library.
    00007  *  Copyright (C) 1998-2003 by Systems in Motion.  All rights reserved.
    00008  *
    00009  *  This library is free software; you can redistribute it and/or
    00010  *  modify it under the terms of the GNU General Public License
    00011  *  ("GPL") version 2 as published by the Free Software Foundation.
    00012  *  See the file LICENSE.GPL at the root directory of this source
    00013  *  distribution for additional information about the GNU GPL.
    00014  *
    00015  *  For using Coin with software that can not be combined with the GNU
    00016  *  GPL, and for taking advantage of the additional benefits of our
    00017  *  support services, please contact Systems in Motion about acquiring
    00018  *  a Coin Professional Edition License.
    00019  *
    00020  *  See <URL:http://www.coin3d.org> for  more information.
    00021  *
    00022  *  Systems in Motion, Teknobyen, Abels Gate 5, 7030 Trondheim, NORWAY.
    00023  *  <URL:http://www.sim.no>.
    00024  *
    00025 \**************************************************************************/
    00026
    00027 #include <Inventor/actions/SoCallbackAction.h>
    00028 #include <Inventor/actions/SoSubAction.h>
    00029 #include <Inventor/SbVec2f.h>
    00030 #include <Inventor/SbColor.h>
    00031
    00032 class SoVectorOutput;
    00033 class SbViewportRegion;
    00034 class SoVectorizeItem;
    00035 class SoVectorizeActionP;
    00036 class SbBSPTree;
    00037
    00038 // *************************************************************************
    00039
    00040 class COIN_DLL_API SoVectorizeAction : public SoCallbackAction {
    00041   typedef SoCallbackAction inherited;
    00042
    00043   SO_ACTION_HEADER(SoVectorizeAction);
    00044
    00045 public:
    00046   SoVectorizeAction(void);
    00047   virtual ~SoVectorizeAction();
    00048
    00049   SoVectorOutput * getOutput(void) const;
    00050
    00051   static void initClass(void);
    00052
    00053   enum DimensionUnit { INCH, MM, METER };
    00054   enum Orientation { PORTRAIT, LANDSCAPE };
    00055
    00056   enum PageSize {
    00057     A0 = 0,
    00058     A1,
    00059     A2,
    00060     A3,
    00061     A4,
    00062     A5,
    00063     A6,
    00064     A7,
    00065     A8,
    00066     A9,
    00067     A10
    00068   };
    00069
    00070   virtual void apply(SoNode * node);
    00071   virtual void apply(SoPath * path);
    00072   virtual void apply(const SoPathList & pathlist, SbBool obeysrules = FALSE);
    00073
    00074   void beginStandardPage(const PageSize & pagesize, const float border = 10.0f);
    00075
    00076   virtual void beginPage(const SbVec2f & startpagepos,
    00077                          const SbVec2f & pagesize,
    00078                          DimensionUnit u = MM);
    00079   virtual void endPage(void);
    00080
    00081   virtual void calibrate(const SbViewportRegion & vp);
    00082
    00083   virtual void beginViewport(const SbVec2f & startpos = SbVec2f(-1.0f, 1.0f),
    00084                              const SbVec2f & size = SbVec2f(-1.0f, -1.0f),
    00085                              DimensionUnit u = MM);
    00086   virtual void endViewport(void);
    00087
    00088   virtual void setOrientation(Orientation o);
    00089   virtual Orientation getOrientation(void) const;
    00090
    00091   virtual void setBackgroundColor(SbBool bg, const SbColor & col = SbColor(0.0f, 0.0f, 0.0f));
    00092   virtual SbBool getBackgroundColor(SbColor & col) const;
    00093
    00094   virtual void setNominalWidth(float w, DimensionUnit u = MM);
    00095   virtual float getNominalWidth(DimensionUnit u = MM) const;
    00096
    00097   virtual void setPixelImageSize(float w, DimensionUnit u = MM);
    00098   virtual float getPixelImageSize(DimensionUnit u = MM) const;
    00099
    00100   enum PointStyle {
    00101     CIRCLE,
    00102     SQUARE
    00103   };
    00104
    00105   virtual void setPointStyle(const PointStyle & style);
    00106   virtual PointStyle getPointStyle(void) const;
    00107
    00108   const SbVec2f & getPageStartpos(void) const;
    00109   const SbVec2f & getPageSize(void) const;
    00110
    00111 public:
    00112   // for TGS OIV compatibility. Might be implemented in the future
    00113   enum ColorTranslationMethod { REVERSE_ONLY_BLACK_AND_WHITE, AS_IS, REVERSE };
    00114
    00115   enum JoinLineStyle { NO_JOIN, MITERED_JOIN, MITERED_BEVELED_JOIN,
    00116                        BEVELED_JOIN, TRIANGULAR_JOIN, ROUNDED_JOIN } ;
    00117   enum EndLineStyle { BUTT_END, SQUARE_END, TRIANGULAR_END, ROUND_END };
    00118   enum HLHSRMode { NO_HLHSR, HLHSR_SIMPLE_PAINTER, HLHSR_PAINTER,
    00119                    HLHSR_PAINTER_SURFACE_REMOVAL, HIDDEN_LINES_REMOVAL };
    00120
    00121   virtual void setDrawingDimensions(const SbVec2f & d, DimensionUnit u = MM);
    00122   virtual SbVec2f getDrawingDimensions(DimensionUnit u = MM) const;
    00123
    00124   virtual void setStartPosition(const SbVec2f & p, DimensionUnit u = MM);
    00125   virtual SbVec2f getStartPosition(DimensionUnit u = MM) const;
    00126
    00127   virtual void setColorTranslationMethod(ColorTranslationMethod method);
    00128   virtual ColorTranslationMethod getColorTranslationMethod(void) const;
    00129
    00130   virtual void setLineEndStyle(EndLineStyle style);
    00131   virtual EndLineStyle getLineEndStyle(void) const;
    00132
    00133   virtual void setLineJoinsStyle(JoinLineStyle style);
    00134   virtual JoinLineStyle getLineJoinsStyle(void) const;
    00135
    00136   virtual void setHLHSRMode(HLHSRMode mode);
    00137   HLHSRMode getHLHSRMode(void) const;
    00138
    00139   virtual void setBorder(float width);
    00140   virtual void setBorder (float width, SbColor color);
    00141
    00142   virtual void setMiterLimit(float limit);
    00143   virtual float getMiterLimit(void) const;
    00144
    00145   virtual void setPenDescription(int num_pens,
    00146                                  const SbColor* colors = 0,
    00147                                  const float * widths = 0,
    00148                                  DimensionUnit u = MM);
    00149   virtual void getPenDescription(SbColor * colors,
    00150                                  float * widths,
    00151                                  DimensionUnit u = MM) const;
    00152   virtual int getPenNum(void) const;
    00153
    00154   virtual void setColorPriority(SbBool priority);
    00155   virtual SbBool getColorPriority(void) const;
    00156
    00157   virtual void enableLighting(SbBool flag);
    00158   SbBool isLightingEnabled(void) const;
    00159
    00160 protected:
    00161   void setOutput(SoVectorOutput * output);
    00162
    00163   virtual float pixelsToUnits(const int pixels);
    00164   virtual void printHeader(void) const = 0;
    00165   virtual void printFooter(void) const;
    00166   virtual void printBackground(void) const;
    00167   virtual void printItem(const SoVectorizeItem * item) const = 0;
    00168   virtual void printViewport(void) const;
    00169
    00170   SbVec2f getRotatedViewportStartpos(void) const;
    00171   SbVec2f getRotatedViewportSize(void) const;
    00172
    00173   const SbBSPTree & getBSPTree(void) const;
    00174
    00175 private:
    00176   SoVectorizeActionP * pimpl;
    00177   friend class SoVectorizeActionP;
    00178 };
    00179
    00180 // *************************************************************************
    00181
    00182 #endif