Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | Related Pages | Examples

linestyle.h

00001 //  Copyright (c) 2001 by Autodesk, Inc.
00002 //
00003 //  By using this code, you are agreeing to the terms and conditions of
00004 //  the License Agreement included in the documentation for this code.
00005 //
00006 //  AUTODESK MAKES NO WARRANTIES, EXPRESS OR IMPLIED, AS TO THE CORRECTNESS
00007 //  OF THIS CODE OR ANY DERIVATIVE WORKS WHICH INCORPORATE IT. AUTODESK
00008 //  PROVIDES THE CODE ON AN "AS-IS" BASIS AND EXPLICITLY DISCLAIMS ANY
00009 //  LIABILITY, INCLUDING CONSEQUENTIAL AND INCIDENTAL DAMAGES FOR ERRORS,
00010 //  OMISSIONS, AND OTHER PROBLEMS IN THE CODE.
00011 //
00012 //  Use, duplication, or disclosure by the U.S. Government is subject to
00013 //  restrictions set forth in FAR 52.227-19 (Commercial Computer Software
00014 //  Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) (Rights in Technical
00015 //  Data and Computer Software), as applicable.
00016 //
00017 
00018 #if !defined LINESTYLE_HEADER
00019 #define LINESTYLE_HEADER
00020 
00021 #include "whiptk/pattern_scale.h"
00022 
00023 
00024 #define WHIP_LINE_STYLE_LIST\
00025     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.)\
00026     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")\
00027     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")\
00028     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")\
00029     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")\
00030     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")\
00031     WHIP_LINE_STYLE_OPTION(Miter_Angle,miter_angle,MITER_ANGLE,WT_Unsigned_Integer16,10/*fix this value*/,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 )\
00032     WHIP_LINE_STYLE_OPTION(Miter_Length,miter_length,MITER_LENGTH,WT_Unsigned_Integer16,(6.0f/32.0f)/*fix this value*/,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 )
00033 
00043 
00044 
00045 #define WHIP_LINE_STYLE_CLASS( class_type, class_lower, class_upper, data_type, default_value, hex_bit, brief_description, full_description ) \
00046  \
00047  \
00048     class WHIPTK_API WT_##class_type : public WT_Option \
00049     {\
00050     public:\
00051         friend class WT_Line_Style; \
00052  WT_##class_type() \
00053         : m_stage( Eating_Initial_Whitespace ) \
00054         , m_value( ( data_type ) default_value ) {} \
00055  inline operator data_type () const { return m_value; } \
00056  inline WT_##class_type & operator= ( data_type value ) { m_value = value; return *this; } \
00057  inline WT_Boolean operator== ( WT_##class_type const & option ) const { return m_value == option.m_value; } \
00058  inline WT_Boolean operator!= ( WT_##class_type const & option ) const { return m_value != option.m_value; } \
00059  inline WT_Boolean operator== ( data_type const & value ) const { return m_value == value; } \
00060  inline WT_Boolean operator!= ( data_type const & value ) const { return m_value != value; } \
00061         WT_Result serialize( WT_Object const & parent, WT_File& file) const; \
00062         WT_Result materialize( WT_Object& parent, WT_Optioncode const & optioncode, WT_File & file); \
00063     private: \
00064         WT_ID     object_id() const { return Option_ID; } \
00065         enum WT_Materialize_Stage \
00066         {   Eating_Initial_Whitespace, \
00067             Getting_Value, \
00068             Eating_End_Whitespace \
00069         } m_stage; \
00070         data_type m_value; \
00071     };
00072 
00074 
00079 class WHIPTK_API WT_Line_Style
00080 : public WT_Attribute
00081 {
00082     friend class WT_Pattern_Scale;
00083     #define WHIP_LINE_STYLE_OPTION( class_type, __A, __B, __C, __D, __E, __F, __G) \
00084         friend class WT_##class_type;
00085         WHIP_LINE_STYLE_LIST
00086     #undef WHIP_LINE_STYLE_OPTION
00087 public:
00088 
00090     enum WT_Capstyle_ID
00091     {
00092         Butt_Cap,
00093         Square_Cap,
00094         Round_Cap,
00095         Diamond_Cap,
00096         // Not Styles:
00097         Capstyle_Count,
00098         Undefined_Capstyle = -1
00099     };
00100 
00102     enum WT_Joinstyle_ID
00103     {
00104         Miter_Join,
00105         Bevel_Join,
00106         Round_Join,
00107         Diamond_Join,
00108         // Not Styles:
00109         Joinstyle_Count,
00110         Undefined_Joinstyle = -1
00111     };
00112 
00113     #define WHIP_LINE_STYLE_OPTION( class_type, class_lower, class_upper, data_type, default_value, hex_bit, brief_description, full_description ) \
00114         WHIP_LINE_STYLE_CLASS( class_type, class_lower, class_upper, data_type, default_value, hex_bit, brief_description, full_description )
00115     // Define the option classes
00116     WHIP_LINE_STYLE_LIST
00117 
00119 
00120     class WHIPTK_API WT_Line_Style_Option_Code
00121     : public WT_Optioncode
00122     {
00123     public:
00125         enum WT_Line_Style_Option_ID
00126         {   Unknown_Option,
00127             Adapt_Patterns_Option,
00128             Pattern_Scale_Option,
00129             Line_Join_Option,
00130             Dash_Start_Cap_Option,
00131             Dash_End_Cap_Option,
00132             Line_Start_Cap_Option,
00133             Line_End_Cap_Option,
00134             Miter_Angle_Option,
00135             Miter_Length_Option
00136         };
00138         int option_id_from_optioncode();
00139     };
00140     #undef WHIP_LINE_STYLE_OPTION
00141 
00143 
00144     WT_Line_Style()
00145     : m_stage(Eating_Initial_Whitespace)
00146     , m_fields_defined(0)
00147     {}
00149 
00151     void merge( WT_Line_Style const &style );
00153     #define WHIP_LINE_STYLE_OPTION( class_type, class_lower, __A, __B, __C, __D, __E, __F) \
00154         WT_##class_type const & class_lower() const {  return m_##class_lower; }
00155         WHIP_LINE_STYLE_LIST
00156     #undef WHIP_LINE_STYLE_OPTION
00157     WT_Pattern_Scale const & pattern_scale() const {  return m_pattern_scale; }
00159 
00161     #define WHIP_LINE_STYLE_OPTION( class_type, class_lower, class_upper, __A, __B, __C, __D, __E ) \
00162         WT_##class_type & class_lower() {  m_fields_defined |= class_upper##_BIT; return m_##class_lower; }
00163         WHIP_LINE_STYLE_LIST
00164     #undef WHIP_LINE_STYLE_OPTION
00165     WT_Pattern_Scale& pattern_scale() {  m_fields_defined |= PATTERN_SCALE_BIT;  return m_pattern_scale; }
00167 
00169     WT_ID            object_id() const { return Line_Style_ID; }
00170     WT_Result        materialize(WT_Opcode const & opcode, WT_File & file);
00171     WT_Result        process(WT_File & file);
00172     WT_Result        skip_operand(WT_Opcode const & opcode, WT_File & file);
00173     WT_Result        serialize (WT_File & file) const;
00174     WT_Result        sync (WT_File & file) const;
00175     WT_Boolean       operator== (WT_Attribute const & attrib) const;
00177 
00179 
00181     static WT_Result default_process(
00182         WT_Line_Style & item, 
00183         WT_File & file 
00184         );
00185 
00186     #ifndef DOXYGEN_IGNORE
00187     static WT_Result interpret_joinstyle( const char *, WT_Joinstyle_ID& );
00188     static WT_Result interpret_capstyle( const char *, WT_Capstyle_ID& );
00189     static WT_Result serialize_capstyle_ascii( WT_Capstyle_ID, WT_File& );
00190 
00192     enum
00193     {
00194         #define WHIP_LINE_STYLE_OPTION( __A, __B, class_upper, __C, __D, hex_bit, __E, __F ) \
00195             class_upper##_BIT = hex_bit,
00196             WHIP_LINE_STYLE_LIST
00197         #undef WHIP_LINE_STYLE_OPTION
00198         PATTERN_SCALE_BIT = 0x0100
00199     };
00200     #endif
00201 
00202 private:
00203 
00204     WT_Line_Style_Option_Code m_optioncode;
00205     WT_Pattern_Scale m_pattern_scale;
00206     #define WHIP_LINE_STYLE_OPTION( class_type, class_lower, __A, __B, __C, __D, __E, __F) \
00207         private: WT_##class_type m_##class_lower;
00208         WHIP_LINE_STYLE_LIST
00209     #undef WHIP_LINE_STYLE_OPTION
00210 
00211 
00212     WT_Result materialize_ascii( WT_Opcode const&, WT_File& );
00213 
00214     enum WT_Materialize_Stage
00215     {   Eating_Initial_Whitespace,
00216         Getting_Pattern_Number,
00217         Checking_For_Attribute_End,
00218         Getting_Optioncode,
00219         Materializing_Option,
00220         // extended binary :
00221         Getting_Adapt_Patterns,
00222         Getting_Pattern_Scale,
00223         Getting_Line_Join,
00224         Getting_Dash_Start_Cap,
00225         Getting_Dash_End_Cap,
00226         Getting_Line_Start_Cap,
00227         Getting_Line_End_Cap,
00228         Getting_Miter_Length,
00229         Getting_Miter_Angle,
00230         Eating_End_Whitespace
00231     } m_stage;
00232 
00233 public:
00234     WT_Unsigned_Integer16 m_fields_defined;
00235 };
00236 
00237 #endif // LINESTYLE_HEADER

Generated on Tue May 17 12:07:44 2005 for Autodesk DWF Whip 2D Toolkit by  doxygen 1.4.1