ContourPlotter.h

00001 #ifndef _ContourPlotter_h
00002 #define _ContourPlotter_h
00003 
00004 #include "PlotControl.h"
00005 
00006 // Klasa zbierająca odcinki i łącząca je w poziomice.
00007 class ContourPlotter
00008 {
00009 public:
00010 // CONSTANTS
00011 
00013     const static unsigned   DASH_STYLE;
00015     const static unsigned   OUTLINE_DISTANCE;
00016 
00017 // LIFECYCLE
00018     ContourPlotter(unsigned   levelCount);
00019 
00020 // OPERATORS
00021 // OPERATIONS
00022     void            AddSegment(double   x1,
00023                                double   y1,
00024                                double   x2,
00025                                double   y2,
00026                                unsigned level);
00027 
00034     void            Draw(wxDC& dc, bool shading) const;
00035 
00039     void            Draw(wxDC&                  dc,
00040                          const FunctionBase&    function,
00041                          unsigned               variableIndexX,
00042                          unsigned               variableIndexY,
00043                          unsigned               variableCount,
00044                          const PlotControl&     plotControl,
00045                          bool                   greaterThanConstraint) const;
00046 
00047     // TODO: zmienić nazwę
00048     void            Collapse();
00049 // ACCESS
00050 
00051 
00052 // INQUIRY
00053 
00054 // DEBUG
00055     void            DumpStats() const;
00056 
00057 private:
00058     class Contour
00059     {
00060         public:
00061             Contour();
00062             Contour(const Contour& from);
00063             Contour(wxPoint a, wxPoint b);
00064 
00065             bool        AddSegment(wxPoint a, wxPoint b);
00066             bool        AddContour(const Contour& contour);
00067 
00068             void        ToPointArray(wxPoint points[]) const;
00069             // TODO: wyznaczyć stronę, w którą ma być przesunięty obrys
00070             // TODO: zmienić nieco nazwę (to nie jest proste przesunięcie).
00071             void        ShiftedToArray(wxPoint      points[],
00072                                        unsigned&    count,
00073                                        bool         counterClockwise) const;
00074 
00086             bool        FindOuterSide(const FunctionBase&   function,
00087                                       unsigned              variableIndexX,
00088                                       unsigned              variableIndexY,
00089                                       unsigned              variableCount,
00090                                       const PlotControl&    plotControl) const;
00091 
00092             unsigned    SegmentCount() const;
00093             bool        IsClosed() const;
00094 
00095         private:
00096             typedef list<wxPoint>     Polyline;
00097 
00098             Polyline    mPolyline;
00099 
00100             wxPoint     mBegin;     
00101             wxPoint     mEnd;       
00102 
00103             bool        mClosed;    
00104     };
00105 
00106     typedef vector<Contour>             ContourContainer;
00107     typedef vector<ContourContainer>    LevelContainer;
00108 
00109     void            DoDraw(wxDC&                dc,
00110                            const FunctionBase*  pFunction,
00111                            unsigned             variableIndexX,
00112                            unsigned             variableIndexY,
00113                            unsigned             variableCount,
00114                            const PlotControl*   pPlotControl,
00115                            bool                 greaterThanConstraint,
00116                            unsigned             shadeDistance) const;
00117     unsigned            MaxSegmentLength() const;
00118     ContourContainer    Collapse(const ContourContainer& contour);
00119 
00120     const static unsigned LIGHTEST_SHADE;
00121     const static unsigned DARKEST_SHADE;
00122 
00123     LevelContainer  mLevels;
00124 };
00125 
00126 #endif

Wygenerowano Fri Sep 29 21:04:48 2006 dla EduOptim2 programem  doxygen 1.4.6