linestyle.h

Go to the documentation of this file.
00001 //
00002 //  Copyright (c) 1996-2006 by Autodesk, Inc.
00003 //
00004 //  By using this code, you are agreeing to the terms and conditions of
00005 //  the License Agreement included in the documentation for this code.
00006 //
00007 //  AUTODESK MAKES NO WARRANTIES, EXPRESS OR IMPLIED, AS TO THE CORRECTNESS
00008 //  OF THIS CODE OR ANY DERIVATIVE WORKS WHICH INCORPORATE IT. AUTODESK
00009 //  PROVIDES THE CODE ON AN "AS-IS" BASIS AND EXPLICITLY DISCLAIMS ANY
00010 //  LIABILITY, INCLUDING CONSEQUENTIAL AND INCIDENTAL DAMAGES FOR ERRORS,
00011 //  OMISSIONS, AND OTHER PROBLEMS IN THE CODE.
00012 //
00013 //  Use, duplication, or disclosure by the U.S. Government is subject to
00014 //  restrictions set forth in FAR 52.227-19 (Commercial Computer Software
00015 //  Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) (Rights in Technical
00016 //  Data and Computer Software), as applicable.
00017 //
00018 
00019 #if !defined LINESTYLE_HEADER
00020 #define LINESTYLE_HEADER
00021 
00025 
00026 #include "whiptk/pattern_scale.h"
00027 
00028 
00029 #define WHIP_LINE_STYLE_LIST\
00030     WHIP_LINE_STYLE_OPTION(Adapt_Patterns,adapt_patterns,ADAPT_PATTERNS,WT_Boolean,WD_False,0x0001, A WT_Line_Style option which specifies that a rendering application should adjust a line pattern length so that each line contains one or more complete pattern., The adaptive pattern setting also applies to user-defined dash patterns. \sa WT_Line_Style \sa WT_Dash_Pattern \note Do not use an adaptive line type when drawing circles; arcs or the edges of wedges or polygons. The rendering application will likely attempt to draw the complete pattern in every chord as there are typically 72 chords in a circle using the default chord angle.)\
00031     WHIP_LINE_STYLE_OPTION(Dash_End_Cap,dash_end_cap,DASH_END_CAP,WT_Capstyle_ID,Butt_Cap,0x0002, A WT_Line_Style option which describes the type of line caps for the ending points of interior pattern segments., This attribute applies to lines and ellipses / arcs. \sa WT_Line_Style \sa WT_Line_Style::WT_Line_End_Cap \image html StartAndEndCaps.png "Line and dash start and end caps details")\
00032     WHIP_LINE_STYLE_OPTION(Dash_Start_Cap,dash_start_cap,DASH_START_CAP,WT_Capstyle_ID,Butt_Cap,0x0004, A WT_Line_Style option which describes the type of line caps for the starting points of interior pattern segments., This attribute applies to lines and ellipses / arcs. \sa WT_Line_Style \sa WT_Line_Style::WT_Line_Start_Cap \image html StartAndEndCaps.png "Line and dash start and end caps details")\
00033     WHIP_LINE_STYLE_OPTION(Line_End_Cap,line_end_cap,LINE_END_CAP,WT_Capstyle_ID,Butt_Cap,0x0008, A WT_Line_Style option which describes the type of line caps for the ending points of lines., This attribute applies lines and ellipses / arcs.  \sa WT_Line_Style \sa WT_Line_Style::WT_Dash_End_Cap \image html CapsAndJoins.png "Line style caps and joins details")\
00034     WHIP_LINE_STYLE_OPTION(Line_Join,line_join,LINE_JOIN,WT_Joinstyle_ID,Miter_Join,0x0010, A WT_Line_Style option which describes how the joints of subsequent thickened multi-segment polylines are rendered., \sa WT_Line_Style \image html CapsAndJoins.png "Line style caps and joins details")\
00035     WHIP_LINE_STYLE_OPTION(Line_Start_Cap,line_start_cap,LINE_START_CAP,WT_Capstyle_ID,Butt_Cap,0x0020, A WT_Line_Style option which describes the type of line caps for the starting points of lines., The attribute applies to lines and ellipses / arcs. \sa WT_Line_Style \sa WT_Line_Style::WT_Dash_Start_Cap \image html CapsAndJoins.png "Line style caps and joins details")\
00036     WHIP_LINE_STYLE_OPTION(Miter_Angle,miter_angle,MITER_ANGLE,WT_Unsigned_Integer16,10,0x0040, A WT_Line_Style option which describes an inside angle formed by extending two intersecting line segments past the join., \sa WT_Line_Style \sa WT_Line_Style::WT_Line_Join )\
00037     WHIP_LINE_STYLE_OPTION(Miter_Length,miter_length,MITER_LENGTH,WT_Unsigned_Integer16,6,0x0080, A WT_Line_Style option which describes a distance from the intersection of two line segments to the furtherest point of the boundary formed by the extended edges of these line segments., \sa WT_Line_Style \sa WT_Line_Style::WT_Line_Join )
00038 
00048 
00049 
00050 #define WHIP_LINE_STYLE_CLASS( class_type, class_lower, class_upper, data_type, default_value, hex_bit, brief_description, full_description ) \
00051  \
00052  \
00053     class WHIPTK_API WT_##class_type : public WT_Option \
00054     {\
00055     public:\
00056         friend class WT_Line_Style; \
00057  WT_##class_type() \
00058         : m_stage( Eating_Initial_Whitespace ) \
00059         , m_value( ( data_type ) default_value ) {} \
00060  inline operator data_type () const { return m_value; } \
00061  inline WT_##class_type & operator= ( data_type value ) { m_value = value; return *this; } \
00062  inline WT_Boolean operator== ( WT_##class_type const & option ) const { return m_value == option.m_value; } \
00063  inline WT_Boolean operator!= ( WT_##class_type const & option ) const { return m_value != option.m_value; } \
00064  inline WT_Boolean operator== ( data_type const & value ) const { return m_value == value; } \
00065  inline WT_Boolean operator!= ( data_type const & value ) const { return m_value != value; } \
00066         WT_Result serialize( WT_Object const & parent, WT_File& file) const; \
00067         WT_Result materialize( WT_Object& parent, WT_Optioncode const & optioncode, WT_File & file); \
00068     private: \
00069         WT_ID     object_id() const { return Option_ID; } \
00070         enum WT_Materialize_Stage \
00071         {   Eating_Initial_Whitespace, \
00072             Getting_Value, \
00073             Eating_End_Whitespace \
00074         } m_stage; \
00075         data_type m_value; \
00076     };
00077 
00079 
00083 class WHIPTK_API WT_Line_Style
00084 : public WT_Attribute
00085 {
00086     friend class WT_Pattern_Scale;
00087         friend class WT_Rendition;
00088         friend class WT_W2D_Class_Factory;
00089         friend class WT_Opcode;
00090 
00091 
00092     #define WHIP_LINE_STYLE_OPTION( class_type, __A, __B, __C, __D, __E, __F, __G) \
00093         friend class WT_##class_type;
00094         WHIP_LINE_STYLE_LIST
00095     #undef WHIP_LINE_STYLE_OPTION
00096 public:
00097 
00099     enum WT_Capstyle_ID
00100     {
00101         Butt_Cap,
00102         Square_Cap,
00103         Round_Cap,
00104         Diamond_Cap,
00105         // Not Styles:
00106         Capstyle_Count,
00107         Undefined_Capstyle = -1
00108     };
00109 
00111     enum WT_Joinstyle_ID
00112     {
00113         Miter_Join,
00114         Bevel_Join,
00115         Round_Join,
00116         Diamond_Join,
00117         // Not Styles:
00118         Joinstyle_Count,
00119         Undefined_Joinstyle = -1
00120     };
00121 
00122     #define WHIP_LINE_STYLE_OPTION( class_type, class_lower, class_upper, data_type, default_value, hex_bit, brief_description, full_description ) \
00123         WHIP_LINE_STYLE_CLASS( class_type, class_lower, class_upper, data_type, default_value, hex_bit, brief_description, full_description )
00124     // Define the option classes
00125     WHIP_LINE_STYLE_LIST
00126 
00128 
00129     class WHIPTK_API WT_Line_Style_Option_Code
00130     : public WT_Optioncode
00131     {
00132     public:
00134         enum WT_Line_Style_Option_ID
00135         {   Unknown_Option,
00136             Adapt_Patterns_Option,
00137             Pattern_Scale_Option,
00138             Line_Join_Option,
00139             Dash_Start_Cap_Option,
00140             Dash_End_Cap_Option,
00141             Line_Start_Cap_Option,
00142             Line_End_Cap_Option,
00143             Miter_Angle_Option,
00144             Miter_Length_Option
00145         };
00147         int option_id_from_optioncode();
00148     };
00149     #undef WHIP_LINE_STYLE_OPTION
00150 public:
00152 
00153     WT_Line_Style()
00154     : m_stage(Eating_Initial_Whitespace)
00155     , m_fields_defined(0)
00156     {}
00157     
00158     WT_Line_Style( WT_Line_Style const & copy )
00159     {
00160         operator=( copy );
00161     }
00162 
00163         virtual ~WT_Line_Style()
00164         {}
00166 public:
00168     virtual WT_Line_Style &operator= ( WT_Line_Style const &copy )
00169     {
00170         m_stage = copy.m_stage;
00171         m_fields_defined = copy.m_fields_defined;
00172         m_pattern_scale = copy.m_pattern_scale;
00173         #define WHIP_LINE_STYLE_OPTION( class_type, class_lower, class_upper, __A, __B, __C, __D, __E ) \
00174             m_##class_lower = copy.m_##class_lower;
00175             WHIP_LINE_STYLE_LIST
00176         #undef WHIP_LINE_STYLE_OPTION
00177         return *this;
00178     }
00180     void merge( WT_Line_Style const &style );
00182     #define WHIP_LINE_STYLE_OPTION( class_type, class_lower, __A, __B, __C, __D, __E, __F) \
00183         WT_##class_type const & class_lower() const {  return m_##class_lower; }
00184         WHIP_LINE_STYLE_LIST
00185     #undef WHIP_LINE_STYLE_OPTION
00186     WT_Pattern_Scale const & pattern_scale() const {  return m_pattern_scale; }
00188 
00190     #define WHIP_LINE_STYLE_OPTION( class_type, class_lower, class_upper, __A, __B, __C, __D, __E ) \
00191         WT_##class_type & class_lower() {  m_fields_defined |= class_upper##_BIT; return m_##class_lower; }
00192         WHIP_LINE_STYLE_LIST
00193     #undef WHIP_LINE_STYLE_OPTION
00194     WT_Pattern_Scale& pattern_scale() {  m_fields_defined |= PATTERN_SCALE_BIT;  return m_pattern_scale; }
00196 
00198     WT_ID            object_id() const { return Line_Style_ID; }
00199     WT_Result        materialize(WT_Opcode const & opcode, WT_File & file);
00200     WT_Result        process(WT_File & file);
00201     WT_Result        skip_operand(WT_Opcode const & opcode, WT_File & file);
00202     WT_Result        serialize (WT_File & file) const;
00203     WT_Result        sync (WT_File & file) const;
00204     WT_Boolean       operator== (WT_Attribute const & attrib) const;
00206 
00208 
00210     static WT_Result default_process(
00211         WT_Line_Style & item, 
00212         WT_File & file 
00213         );
00214 
00215     #ifndef DOXYGEN_IGNORE
00216     static WT_Result interpret_joinstyle( const char *, WT_Joinstyle_ID& );
00217     static WT_Result interpret_capstyle( const char *, WT_Capstyle_ID& );
00218     static WT_Result serialize_capstyle_ascii( WT_Capstyle_ID, WT_File& );
00219 
00221     enum
00222     {
00223         #define WHIP_LINE_STYLE_OPTION( __A, __B, class_upper, __C, __D, hex_bit, __E, __F ) \
00224             class_upper##_BIT = hex_bit,
00225             WHIP_LINE_STYLE_LIST
00226         #undef WHIP_LINE_STYLE_OPTION
00227         PATTERN_SCALE_BIT = 0x0100
00228     };
00229     #endif
00230 
00231 protected:
00232 
00233     WT_Line_Style_Option_Code m_optioncode;
00234     WT_Pattern_Scale m_pattern_scale;
00235     #define WHIP_LINE_STYLE_OPTION( class_type, class_lower, __A, __B, __C, __D, __E, __F) \
00236         protected: WT_##class_type m_##class_lower;
00237         WHIP_LINE_STYLE_LIST
00238     #undef WHIP_LINE_STYLE_OPTION
00239 
00240 
00241     WT_Result materialize_ascii( WT_Opcode const&, WT_File& );
00242 
00243     enum WT_Materialize_Stage
00244     {   Eating_Initial_Whitespace,
00245         Getting_Pattern_Number,
00246         Checking_For_Attribute_End,
00247         Getting_Optioncode,
00248         Materializing_Option,
00249         // extended binary :
00250         Getting_Adapt_Patterns,
00251         Getting_Pattern_Scale,
00252         Getting_Line_Join,
00253         Getting_Dash_Start_Cap,
00254         Getting_Dash_End_Cap,
00255         Getting_Line_Start_Cap,
00256         Getting_Line_End_Cap,
00257         Getting_Miter_Length,
00258         Getting_Miter_Angle,
00259         Eating_End_Whitespace
00260     } m_stage;
00261 
00262 public:
00263     WT_Unsigned_Integer16 m_fields_defined;
00264 };
00265 
00266 #endif // LINESTYLE_HEADER

Generated on Tue Jan 6 22:41:13 2009 for Autodesk DWF Whip 2D Toolkit by  doxygen 1.4.5