usrhatchpat.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 
00020 #if !defined USER_HATCH_PATTERN_HEADER
00021 #define USER_HATCH_PATTERN_HEADER
00022 
00026 
00027 #include "whiptk/whipcore.h"
00028 #include "dwfcore/CountedObject.h"
00029 #include "dwfcore/STL.h"
00030 
00057 
00058 class WHIPTK_API WT_User_Hatch_Pattern : public WT_Attribute
00059 {
00060         friend class WT_Rendition;
00061         friend class WT_W2D_Class_Factory;
00062         friend class WT_Opcode;
00063 
00064 public:
00066 
00067 
00068 
00069 
00070 
00071 
00072 
00073 
00074 
00075     class Hatch_Pattern : public DWFCore::DWFCountedObject
00076     {
00077     public:
00079         static Hatch_Pattern* Construct(const double & x,  
00080                                         const double & y,  
00081                                         const double & angle, 
00082                                         const double & spacing,
00083                                         const double & skew = 0, 
00084                                         WT_Unsigned_Integer32 data_size = 0, 
00085                                         const double * data = NULL 
00086                                         )
00087         {
00088             return DWFCORE_ALLOC_OBJECT (Hatch_Pattern(x,y,angle,spacing,skew,data_size,data));
00089         }
00090         
00091     public:
00092         
00093         WHIPTK_API double const & x() const { return m_x; }
00094 
00095         WHIPTK_API double const & y() const { return m_y; }
00096 
00097         WHIPTK_API double const & angle() const { return m_angle; }
00098 
00099         WHIPTK_API double const & spacing() const { return m_spacing; }
00100 
00101         WHIPTK_API double const & skew() const { return m_skew; }
00102         
00103         WHIPTK_API WT_Unsigned_Integer32 data_size() const { return m_data_size; }
00104 
00105         WHIPTK_API double const * data() const { return m_data; } 
00106 
00107         WHIPTK_API WT_Boolean operator == ( Hatch_Pattern const & pattern ) const;
00108 
00109         WHIPTK_API WT_Boolean operator != ( Hatch_Pattern const & pattern )
00110         {
00111             return ! (operator==(pattern));
00112         }
00113     protected:
00114         WHIPTK_API Hatch_Pattern(const double & x, 
00115                       const double & y,
00116                       const double & angle,
00117                       const double & spacing,
00118                       const double & skew,
00119                       WT_Unsigned_Integer32 patsize,
00120                       const double * patdata
00121                       )throw();
00122 
00123         WHIPTK_API virtual ~Hatch_Pattern() throw()
00124         { 
00125             if (m_data != WD_Null)
00126                 delete [] m_data;
00127         }
00128 
00129     private:
00131         Hatch_Pattern( Hatch_Pattern const &);
00132         Hatch_Pattern const & operator=(Hatch_Pattern const &);
00133         double m_x;
00134         double m_y;
00135         double m_angle;
00136         double m_spacing;
00137         double m_skew;
00138         WT_Unsigned_Integer32 m_data_size;
00139         double * m_data;
00140     };
00142 // data Members for WT_User_Hatch_Pattern()
00143 private:
00144     WT_Integer16 m_hashpatnum;
00145     WT_Unsigned_Integer16 m_xsize;
00146     WT_Unsigned_Integer16 m_ysize;
00147     std::vector<Hatch_Pattern*> m_patterns;
00148 public:
00150 
00151     WT_User_Hatch_Pattern()
00152         : m_hashpatnum(-1)  // important: -1 means "does not exist", which is the default state
00153         , m_xsize(0)
00154         , m_ysize(0)
00155     {;}
00159     WT_User_Hatch_Pattern(WT_Integer16 hashpatnum)
00160         : m_hashpatnum(hashpatnum)
00161         , m_xsize(0)
00162         , m_ysize(0)
00163     {;}  
00169     WT_User_Hatch_Pattern(WT_Integer16 hashpatnum,
00170                          WT_Unsigned_Integer16 xsize,
00171                          WT_Unsigned_Integer16 ysize)
00172         : m_hashpatnum(hashpatnum)
00173         , m_xsize(xsize)
00174         , m_ysize(ysize)
00175     {;}  
00176 
00178     WT_User_Hatch_Pattern(WT_User_Hatch_Pattern const & pattern);
00179        
00180    
00181     virtual ~WT_User_Hatch_Pattern();
00182 
00183     
00185 public:
00187     WT_Integer16 const& pattern_number() const {return m_hashpatnum;}
00188     WT_Integer16& pattern_number() {return m_hashpatnum;}
00189 
00190 
00192     WT_Unsigned_Integer16 const& xsize() const {return m_xsize;}
00193     WT_Unsigned_Integer16& xsize() {return m_xsize;}
00194     
00196     WT_Unsigned_Integer16 const& ysize() const {return m_ysize;}
00197     WT_Unsigned_Integer16& ysize() {return m_ysize;}
00198 
00201     WT_Integer16 add_pattern(Hatch_Pattern & pattern);
00202     
00205     WT_Unsigned_Integer32 pattern_count() const { 
00206             return (WT_Unsigned_Integer32)m_patterns.size();
00207     }
00208     
00211     const Hatch_Pattern * pattern(WT_Unsigned_Integer32 index) const;
00212 
00214     WT_ID            object_id() const;
00215     WT_Result        materialize(WT_Opcode const & opcode, WT_File & file);
00216     WT_Result        process(WT_File & file);
00217     WT_Result        skip_operand(WT_Opcode const & opcode, WT_File & file);
00218     WT_Result        serialize (WT_File & file) const;
00219     WT_Result        sync (WT_File & file) const;
00220     WT_Boolean       operator== (WT_Attribute const & attrib) const;
00222     
00223         WT_User_Hatch_Pattern const & operator= (WT_User_Hatch_Pattern const & pattern);
00224 
00226 
00227     WT_Boolean operator== (WT_User_Hatch_Pattern const & pattern) const;
00229     WT_Boolean operator!= (WT_User_Hatch_Pattern const & pattern) const;
00231     
00233 
00235     static WT_Result default_process(
00236         WT_User_Hatch_Pattern & item, 
00237         WT_File & file 
00238         );
00239 
00240 private:
00241     WT_Result serialize_ascii     (WT_File & file) const;
00242     WT_Result serialize_binary    (WT_File & file) const; 
00243     WT_Result materialize_ascii   (WT_Opcode const & opcode, WT_File & file);
00244     WT_Result materialize_binary  (WT_Opcode const & opcode, WT_File & file);
00245 
00246 };
00247 
00249 
00250 #endif // USER_HATCH_PATTERN_HEADER

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