Changeset 1886 in Sophya for trunk/SophyaPI/PI/pigraphgen.h


Ignore:
Timestamp:
Jan 28, 2002, 12:33:12 AM (24 years ago)
Author:
ansari
Message:

Introduction de la classe PILineAtt a la place de l'enum PILineAtt - Reza 27/01/2002

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PI/pigraphgen.h

    r1851 r1886  
    1515#include "picolist.h"  // enum PIColors
    1616
    17 
    18 enum PILineAtt { PI_NotDefLineAtt = -1,
    19                  PI_NormalLine = 0, PI_ThinLine = 1, PI_ThickLine = 2 ,
    20                  PI_DashedLine = 64, PI_ThinDashedLine = 65, PI_ThickDashedLine = 66 ,
    21                  PI_DottedLine = 128, PI_ThinDottedLine = 129, PI_ThickDottedLine = 130 };
    22 
     17// Line drawing attributes
     18enum PILineJoin { PI_JoinMiter=0, PI_JoinRound=1, PI_JoinBevel=2};
     19enum PILineCap  { PI_CapButt=0, PI_CapRound=1, PI_CapProjecting=2};
     20enum PILineDash { PI_LineSolid, PI_LineDashed, PI_LineDotted,
     21                  PI_LineDashedDotted};
     22// Predefined line types
     23enum PILineTyp { PI_NotDefLineAtt = -1,
     24                 PI_NormalLine, PI_ThinLine, PI_ThickLine,
     25                 PI_DashedLine, PI_ThinDashedLine, PI_ThickDashedLine,
     26                 PI_DottedLine, PI_ThinDottedLine, PI_ThickDottedLine };
     27
     28// Marker types
    2329enum PIMarker  { PI_NotDefMarker = -1,
    2430                 PI_DotMarker = 0, PI_PlusMarker=1, PI_CrossMarker=2, 
     
    2834                 PI_StarMarker=9, PI_FStarMarker=10 };
    2935
    30 
     36// ArrowMarker types (oriented markers)
     37enum PIArrowMarker { PI_NotDefArrowMarker, PI_BasicArrowMarker,
     38                     PI_TriangleArrowMarker, PI_FTriangleArrowMarker,
     39                     PI_ArrowShapedArrowMarker, PI_FArrowShapedArrowMarker };
     40
     41// Flag de positionnement
    3142enum PIGrPosHorizontal // Flags de positionnement horizontal
    3243// PI_HorizontalPosition regroupe l'ensemble des bits utilisables
     
    6677};
    6778
     79// Classe pour gerer les attributs de lignes
     80class PILineAtt {
     81public:
     82  inline PILineAtt(int width=1, PILineDash dash=PI_LineSolid,
     83                   PILineJoin join=PI_JoinMiter, PILineCap cap=PI_CapButt)
     84  { _lwidth = width*8; _ldash=dash; _ljoincap=join+cap*256; }   
     85  inline PILineAtt(double width, PILineDash dash=PI_LineSolid,
     86                   PILineJoin join=PI_JoinMiter, PILineCap cap=PI_CapButt)
     87  { _lwidth = (unsigned short)(width*8.); _ldash=dash; _ljoincap=join+cap*256; }   
     88  inline PILineAtt(PILineAtt const& b)
     89  { _lwidth=b._lwidth; _ldash=b._ldash; _ljoincap=b._ljoincap; } 
     90 
     91  PILineAtt(PILineTyp ltyp);
     92
     93  inline ~PILineAtt() {}
     94
     95  inline PILineAtt& operator = (PILineAtt const& b)
     96  { _lwidth=b._lwidth; _ldash=b._ldash; _ljoincap=b._ljoincap; return(*this); }   
     97  inline bool operator == (PILineAtt const& b)
     98  { return ((_lwidth==b._lwidth)&&(_ldash==b._ldash)&&(_ljoincap==b._ljoincap)); }
     99  inline bool operator == (PILineTyp ltyp)
     100  { return ((*this) == PILineAtt(ltyp)); }
     101  inline bool operator != (PILineAtt const& b)
     102  { return (!(_lwidth==b._lwidth)&&(_ldash==b._ldash)&&(_ljoincap==b._ljoincap)); }
     103  inline bool operator != (PILineTyp ltyp)
     104  { return ((*this) != PILineAtt(ltyp)); }
     105
     106  inline int GetLineWidth() const { return (_lwidth/8); }
     107  inline int GetLineWidthx8() const { return (_lwidth); }
     108  inline double GetLineWidthD() const { return ((double)_lwidth/8.); }
     109  inline PILineDash GetLineDash() const { return _ldash; }
     110  inline PILineJoin GetLineJoin() const { return (PILineJoin)(_ljoincap%256); }
     111  inline PILineCap  GetLineCap() const { return (PILineCap)(_ljoincap/256); }
     112
     113  inline void SetLineWidth(int lw) { _lwidth = lw*8; }
     114  inline void SetLineWidth(double lw) { _lwidth = (unsigned short)(lw*8.); }
     115  inline void SetLineDash(PILineDash ld)  { _ldash = ld; }
     116  inline void SetLineJoin(PILineJoin lj)  { _ljoincap = lj+(_ljoincap&0xFF00); }
     117  inline void SetLineCap(PILineCap lc)  { _ljoincap = lc*256+(_ljoincap&0x00FF); }
     118
     119protected:
     120  unsigned short _lwidth;  // en 1/8 de pixels (ou points)
     121  unsigned short _ljoincap;
     122  PILineDash _ldash; 
     123};
     124
     125// Les differents types de classes PIGraphic
    68126enum PIGraphicsType { PI_UnknownGraphics = 0,
    69127                      PI_ScrWindowGraphics = 2, PI_ScrBufferGraphics = 3,
     
    88146//  Trace graphiques
    89147  virtual void       Erase(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)     = 0;
     148
    90149  virtual void       DrawString(PIGrCoord x, PIGrCoord y, const char* s, int pos = 0)        = 0;
    91150  virtual void       DrawOpaqueString(PIGrCoord x, PIGrCoord y, const char* s, int pos = 0)  = 0;
     151  virtual void       DrawCompString(PIGrCoord x, PIGrCoord y, const char* s,
     152                                    const char* s_up, const char* s_dn, int pos = 0);
     153
    92154  virtual void       DrawLine(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2)  = 0;
    93155  virtual void       DrawBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)   = 0;
     
    103165  virtual void       DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
    104166                              double degdeb, double degfin)                            = 0;
     167
    105168  virtual void       DrawMarker(PIGrCoord x0, PIGrCoord y0)                            = 0;
    106169  virtual void       DrawMarkers(PIGrCoord *x, PIGrCoord *y, int n)                    = 0;
     170  virtual void       DrawArrowMarker(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2);
     171
    107172  virtual void       DrawPixmap(PIGrCoord x, PIGrCoord y, unsigned char *pix,
    108173                                int sx, int sy, PIColorMap* cmap)              = 0;
     
    115180  virtual void       SelGOMode(PIGOMode mod=PI_GOCopy)                         = 0;
    116181  virtual void       SelLine(PILineAtt att=PI_NormalLine)                      = 0;
     182  inline  void       SelLine(PILineTyp lt) { SelLine(PILineAtt(lt)); }
    117183  virtual void       SelMarker(int msz=3, PIMarker mrk=PI_DotMarker)           = 0;
     184  virtual void       SelArrowMarker(int arrsz=5,
     185                                    PIArrowMarker arrmrk=PI_BasicArrowMarker);
    118186// Modifications de fonte
    119187  virtual void       SelFont(PIFont & fnt)                                     = 0;
     
    133201  virtual PIMarker   GetMarker()        = 0;
    134202  virtual int        GetMarkerSize()    = 0;
     203  virtual PIArrowMarker    GetArrowMarker();
     204  virtual int        GetArrowMarkerSize();
    135205
    136206// Acces a la fonte et ses attributs
     
    151221
    152222  PIFont myFont;
     223  PIArrowMarker myArrowMrk;
     224  int myArrowMrkSz;
    153225  PIColors  sFCol, sBCol;
    154226  PIGOMode sGOm;
     
    158230  PIMarker sMrk;
    159231  int sMrkSz;
     232  PIArrowMarker sArrowMrk;
     233  int sArrowMrkSz;
     234
    160235};
    161236
Note: See TracChangeset for help on using the changeset viewer.