djv_mapareas.h

Go to the documentation of this file.
00001 //----------------------------------------------------------------------------
00004 //
00005 // (C) 2005-2006 Celartem Technology Inc. All rights reserved.
00006 //----------------------------------------------------------------------------
00007 
00008 #ifndef _djv_mapareas_h_
00009 #define _djv_mapareas_h_
00010 
00011 #include "cel_string.h"
00012 #include "cel_geom.h"
00013 #include "djv_common.h"
00014 #include "djv_links.h"
00015 #include "djv_utils.h"
00016 
00017 namespace Celartem
00018 {
00019     namespace DjVu
00020     {
00025         enum BorderType
00026         {
00027             btNone = 0, 
00028             btXor = 1, 
00029             btSolid = 2, 
00030             btShadowIn = 3, 
00031             btShadowOut = 4, 
00032             btShadowEIn = 5, 
00033             btShadowEOut = 6 
00034         };
00035         
00039         enum MapAreaType
00040         {
00041             matRect = 0, 
00042             matOval = 1, 
00043             matPoly = 2, 
00044             matLine = 3, 
00045             matText = 4, 
00046         };
00047         
00048         //--------------------------------------------------------------------
00052         class MapArea : public Referable
00053         {
00054         public:
00055             Link link; 
00056         
00070             String target; 
00071 
00077             String text; 
00078             
00086             BorderType borderType; 
00087             
00092             Color lineColor; 
00093 
00102             size_t lineWidth; 
00103 
00111             bool borderAlwaysVisible; 
00112             
00118             virtual MapAreaType getType() const = 0;
00119             
00128             virtual Rect getRect() const = 0;
00129             
00138             virtual bool isPointInsideArea(const Point& inPoint) const = 0;
00139             
00151             virtual size_t isPointOnLine(
00152                 const Point& inPoint, size_t inRadius = 1) const = 0;
00153             
00166             virtual String getANTString(
00167                 const PageInfo& inPageInfo,
00168                 Rotation inCurrentRotation) const = 0;
00169             
00175             virtual AutoPtr<MapArea> duplicate() const = 0;
00176 
00177         protected:
00182             MapArea() :
00183                 borderType(btNone),
00184                 lineWidth(1),
00185                 borderAlwaysVisible(false)
00186             {
00187             }
00188         };
00189 
00190         //--------------------------------------------------------------------
00194         class MapRect : public MapArea
00195         {
00196         public:
00200             static AutoPtr<MapRect> create()
00201             {
00202                 return new MapRect();
00203             }
00204             
00208             Rect rect;
00209 
00217             Color bgColor;
00218             
00224             size_t opacity;
00225         
00226             virtual MapAreaType getType() const {return matRect;}
00227             virtual Rect getRect() const {return rect;}
00228 
00237             virtual bool isPointInsideArea(const Point& inPoint) const
00238             {
00239                 return inPoint.isInside(rect);
00240             }
00241 
00257             virtual size_t isPointOnLine(
00258                 const Point& inPoint, size_t inRadius = 1) const;
00259             
00260             virtual String getANTString(
00261                 const PageInfo& inPageInfo, Rotation inCurrentRotation) const;
00262 
00263             virtual AutoPtr<MapArea> duplicate() const;
00264         
00265         private:
00266             MapRect() : opacity(50) {}
00267             MapRect(const MapRect&);
00268             MapRect& operator=(const MapRect&);
00269         };
00270         
00271         //--------------------------------------------------------------------
00275         class MapOval : public MapArea
00276         {
00277         public:
00281             static AutoPtr<MapOval> create()
00282             {
00283                 return new MapOval();
00284             }
00285             
00289             Rect rect;
00290 
00291             virtual MapAreaType getType() const {return matOval;}
00292             virtual Rect getRect() const {return rect;}
00293             
00302             virtual bool isPointInsideArea(const Point& inPoint) const;
00303             
00316             virtual size_t isPointOnLine(
00317                 const Point& inPoint, size_t inRadius = 1) const;
00318             
00319             virtual String getANTString(
00320                 const PageInfo& inPageInfo, Rotation inCurrentRotation) const;
00321 
00322             virtual AutoPtr<MapArea> duplicate() const;
00323         
00324         private:
00325             MapOval() {}
00326             MapOval(const MapOval&);
00327             MapOval& operator=(const MapOval&);
00328         };
00329         
00330         //--------------------------------------------------------------------
00334         class MapPoly : public MapArea
00335         {
00336         public:
00340             static AutoPtr<MapPoly> create()
00341             {
00342                 return new MapPoly();
00343             }
00344             
00348             SimpleArray<Point> points;
00349         
00350             virtual MapAreaType getType() const {return matPoly;}
00351             
00352             virtual Rect getRect() const
00353             {
00354                 ssize_t l = SSIZE_MAX, t = SSIZE_MAX;
00355                 ssize_t r = SSIZE_MIN, b = SSIZE_MIN;
00356                 const size_t count = points.getSize();
00357                 for(size_t i = 0; i < count; i++)
00358                 {
00359                     const Point& pt = points[i];
00360                     if(pt.x < l) l = pt.x; else if(pt.x > r) r = pt.x;
00361                     if(pt.y < t) t = pt.y; else if(pt.y > b) b = pt.y;
00362                 }
00363                 return Rect(l, t, r - l, b - t);
00364             }
00365             
00374             virtual bool isPointInsideArea(const Point& inPoint) const;
00375 
00389             virtual size_t isPointOnLine(
00390                 const Point& inPoint, size_t inRadius = 1) const;
00391             
00392             virtual String getANTString(
00393                 const PageInfo& inPageInfo, Rotation inCurrentRotation) const;
00394 
00395             virtual AutoPtr<MapArea> duplicate() const;
00396         
00397         private:
00398             MapPoly() {}
00399             MapPoly(const MapPoly&);
00400             MapPoly& operator=(const MapPoly&);
00401         };
00402         
00403         //--------------------------------------------------------------------
00407         class MapLine : public MapArea
00408         {
00409         public:
00413             static AutoPtr<MapLine> create()
00414             {
00415                 return new MapLine();
00416             }
00417             
00421             Point p0;
00422             
00426             Point p1;
00427             
00431             bool isArrow;
00432         
00433             virtual MapAreaType getType() const {return matLine;}
00434             
00435             virtual Rect getRect() const
00436             {
00437                 size_t l, t, r, b;
00438                 if(p0.x < p1.x)
00439                 {
00440                     l = p0.x;
00441                     r = p1.x;
00442                 }
00443                 else
00444                 {
00445                     l = p1.x;
00446                     r = p0.x;
00447                 }
00448                 if(p0.y < p1.y)
00449                 {
00450                     t = p0.y;
00451                     b = p1.y;
00452                 }
00453                 else
00454                 {
00455                     t = p1.y;
00456                     b = p0.y;
00457                 }
00458                 return Rect(l, t, r - l, b - t);
00459             }
00460             
00471             virtual bool isPointInsideArea(const Point& inPoint) const
00472             {
00473                 return isPointOnLine(inPoint) ? true : false;
00474             }
00475             
00488             virtual size_t isPointOnLine(
00489                 const Point& inPoint, size_t inRadius = 1) const;
00490             
00491             virtual String getANTString(
00492                 const PageInfo& inPageInfo, Rotation inCurrentRotation) const;
00493 
00494             virtual AutoPtr<MapArea> duplicate() const;
00495         
00496         private:
00497             MapLine() : isArrow(false)
00498             {
00499                 lineColor = 0;
00500             }
00501             
00502             MapLine(const MapLine&);
00503             MapLine& operator=(const MapLine&);
00504         };
00505 
00506         //--------------------------------------------------------------------
00510         class MapText : public MapArea
00511         {
00512         public:
00516             static AutoPtr<MapText> create()
00517             {
00518                 return new MapText();
00519             }
00520             
00524             Rect rect;
00525 
00529             bool pushpin;
00530             
00534             Color textColor;
00535 
00543             Color bgColor;
00544         
00545             virtual MapAreaType getType() const {return matText;}
00546             virtual Rect getRect() const {return rect;}
00547             
00548             virtual bool isPointInsideArea(const Point& inPoint) const
00549             {
00550                 return inPoint.isInside(rect);
00551             }
00552 
00568             virtual size_t isPointOnLine(
00569                 const Point& inPoint, size_t inRadius = 1) const;
00570             
00571             virtual String getANTString(
00572                 const PageInfo& inPageInfo, Rotation inCurrentRotation) const;
00573 
00574             virtual AutoPtr<MapArea> duplicate() const;
00575 
00576         private:
00577             MapText() : pushpin(false), textColor(0) {}
00578             MapText(const MapText&);
00579             MapText& operator=(const MapText&);
00580         };
00581     }
00582 }
00583 
00584 #endif // _djv_mapareas_h_

This document is automatically generated using doxygen 1.5.4 at Fri Jun 27 18:21:55 2008.