DrawPalette.h

Go to the documentation of this file.
00001 //DrawPalette.h
00002 
00003 /*************************************************************/
00004 //
00005 // DrawPaletteDialog
00006 //
00007 // Object drawing palette
00008 //
00009 //-------------------------------------------------------------
00010 //
00011 // v 1.3 - 2007/02/17 - Added distance display
00012 // v 1.2 - 2007/02/08 - Save draw directory
00013 // v 1.1 - 2007/02/07 - Fixed positioning of elements
00014 // v 1.0 - 2007/01/06 - Initial release
00015 //
00016 // See LICENSE.txt for distribution and usage restrictions
00017 // Copyright (c) 2006-2007 Simon Chorley
00018 // www.mylaboratory.co.uk - greylab@mylaboratory.co.uk
00019 //
00020 /*************************************************************/
00021 
00022 
00023 ///Drawing palette (Definition)
00024 /**
00025  * Provides DrawPaletteDialog window class to manage creation of drawing primatives on the colourscale and linescan graphs.
00026  * @file DrawPalette.h
00027  * @version 1.3 - 2007/02/17
00028  */
00029 
00030 
00031 #ifndef _DRAWPALETTE_H_
00032 #define _DRAWPALETTE_H_
00033 
00034 #include <fx.h>
00035 
00036 
00037 #include "DataFunc.h"
00038 
00039 
00040 ///Drawing palette dialog class
00041 /**
00042  * Maintains the list of drawing primatives, saving and loading lists and setting of parameters.
00043  */
00044 class DrawPaletteDialog : public FXDialogBox
00045 {
00046         FXDECLARE(DrawPaletteDialog)
00047 private:
00048         FXColorWell             *drawfgColourwell;
00049         FXColorWell             *drawbgColourwell;
00050         FXTextField             *drawstrokeTextfield;
00051 
00052         FXTextField             *drawxposTextfield;
00053         FXTextField             *drawyposTextfield;
00054         FXPopup                 *drawbasisPopup;
00055         FXOption                *drawaxisOption;
00056         FXOption                *drawfractionalOption;
00057         FXOption                *drawabsoluteOption;
00058         FXOption                *drawaxisfractionalOption;
00059         FXOption                *drawborderOption;
00060         FXOptionMenu    *drawbasisOptionmenu;
00061 
00062         FXSwitcher              *drawobjectSwitcher;
00063 
00064         FXTextField             *drawxsizeTextfield;
00065         FXTextField             *drawysizeTextfield;
00066         FXPopup                 *drawsizebasisPopup;
00067         FXOption                *drawsizeaxisOption;
00068         FXOption                *drawsizefractionalOption;
00069         FXOption                *drawsizeabsoluteOption;
00070         FXOption                *drawsizeaxisfractionalOption;
00071         FXOption                *drawsizeborderOption;
00072         FXOptionMenu    *drawsizebasisOptionmenu;
00073 
00074         FXTextField             *drawtextTextfield;
00075         FXPopup                 *drawjustifyPopup;
00076         FXOption                *drawtljustifyOption;
00077         FXOption                *drawtrjustifyOption;
00078         FXOption                *drawbljustifyOption;
00079         FXOption                *drawbrjustifyOption;
00080         FXOption                *drawcjustifyOption;
00081         FXOptionMenu    *drawjustifyOptionmenu;
00082 
00083         FXTextField             *drawimageTextfield;
00084 
00085         FXTextField             *drawfunctionTextfield;
00086         FXCheckButton   *draw2dCheckbutton;
00087 //      FXTextField             *drawscaleTextfield;
00088 
00089         FXCheckButton   *drawstartarrowCheckbutton;
00090         FXCheckButton   *drawendarrowCheckbutton;
00091         FXTextField             *drawarrowlengthTextfield;
00092         FXTextField             *drawarrowwidthTextfield;
00093 
00094         FXCheckButton   *drawstartlCheckbutton;
00095         FXCheckButton   *drawendlCheckbutton;
00096         FXCheckButton   *drawgradlCheckbutton;
00097         FXCheckButton   *drawdistlCheckbutton;
00098 
00099         FXColorList             *drawitemsColourlist;
00100 
00101         DrawPaletteDialog(){}
00102 
00103         int startpx, startpy;           ///<Start positions
00104         int currentpx, currentpy;       ///<Current positons
00105         double startax, startay;        ///<Start axis space values
00106 
00107         int totalwidth, totalheight;    ///<Total image sizes
00108         int xpixels, ypixels;                   ///<Data image sizes
00109         int borderleft, borderbottom, bordertop, borderright;   ///<Border sizes
00110 
00111         bool drawing;           ///<Drawing mode is on?
00112 
00113         FXString drawfile;      ///<File containing the list of primatives
00114 
00115         int updatetarget;       ///<Graph the primative list is attached to
00116 
00117 #ifndef WIN32
00118         void coordSort(int &xmin, int &xmax, int &ymin, int &ymax, int spx, int epx, int spy, int epy);
00119 #endif
00120         void constructItemLine(int idx);
00121         void ImageLoad(void);
00122 
00123 public:
00124         void setImageCoords(int tw, int th, int xp, int yp, int bl, int bb);
00125         void drawPrimative(FXDCWindow *dcw, double x, double y, int mx, int my, int xpx, int ypx);
00126         void startDraw(double x, double y, int mx, int my, int xpx, int ypx);
00127         void endDraw(FXDCWindow *dcw, double x, double y, int mx, int my, int xpx, int ypx);
00128 
00129         long cmdUpdateData(FXObject*, FXSelector, void*);
00130         long cmdUpdatePositionData(FXObject*, FXSelector, void*);
00131         long cmdUpdateAllData(FXObject*, FXSelector, void*);
00132         long cmdItemDelete(FXObject*, FXSelector, void*);
00133         long cmdItemSelect(FXObject*, FXSelector, void*);
00134 
00135         long cmdNewLine(FXObject*, FXSelector, void*);
00136         long cmdNewText(FXObject*, FXSelector, void*);
00137         long cmdNewRect(FXObject*, FXSelector, void*);
00138         long cmdNewEllipse(FXObject*, FXSelector, void*);
00139         long cmdNewImage(FXObject*, FXSelector, void*);
00140         long cmdNewFunction(FXObject*, FXSelector, void*);
00141 
00142         long cmdItemUp(FXObject*, FXSelector, void*);
00143         long cmdItemDown(FXObject*, FXSelector, void*);
00144 
00145         long cmdImageBrowse(FXObject*, FXSelector, void*);
00146 
00147         long cmdNew(FXObject*, FXSelector, void*);
00148         long cmdLoad(FXObject*, FXSelector, void*);
00149         long cmdAppend(FXObject*, FXSelector, void*);
00150         long cmdSave(FXObject*, FXSelector, void*);
00151         long cmdSaveAs(FXObject*, FXSelector, void*);
00152 
00153         enum { ID_DRAW_NEWLINE = FXDialogBox::ID_LAST, ID_DRAW_NEWTEXT, ID_DRAW_NEWRECT, ID_DRAW_NEWELLIPSE, ID_DRAW_NEWIMAGE, ID_DRAW_NEWFUNCTION,
00154                 ID_DRAW_IMAGEBROWSE,
00155                 ID_DRAW_ITEMUP, ID_DRAW_ITEMDN, ID_DRAW_CHANGED, ID_DRAW_ITEMSEL,
00156                 ID_DRAW_NEW, ID_DRAW_LOAD, ID_DRAW_APPEND, ID_DRAW_SAVE, ID_DRAW_SAVEAS };
00157 
00158         DrawPaletteDialog(FXWindow *owner, int target);
00159         virtual ~DrawPaletteDialog();
00160         void hide(void);
00161 
00162         FXString drawdirectory; ///<Directory of the file dialog box
00163 //      float width, height;
00164 
00165         ///Drawing primative
00166         struct primative
00167         {
00168                 enum typemode { LINE, TEXT, RECT, ELLIPSE, IMAGE, FUNCTION } type;      ///<Primative type
00169                 FXColor fg;             ///<Foreground colour
00170                 FXColor bg;             ///<Background colour
00171                 int stroke;             ///<Line thickness
00172                 float position[2];              ///<Primative position
00173                 enum axismode { AXISABS, IMAGEFRAC, IMAGEABS, AXISFRAC, BORDERFRAC } posmode;   ///<Position coordinate interpretation mode
00174                 float dimensions[2];    ///<Primative dimension or end coordinate
00175                 enum axismode dimmode;  ///<Dimension interpretation mode
00176                 FXString *text;                 ///<Primative text
00177                 enum justification { TL, TR, BL, BR, C } justify;       ///<Text justification mode
00178                 bool arrow[2];                  ///<Use start/end arrow?
00179                 float arrowsize[2];             ///<Arrow width and length
00180                 FXString *file;                 ///<Image file name
00181                 unsigned int imageid;   ///<DevIL image ID
00182                 bool validimage;                ///<Is a valid image?
00183                 FXString *func;                 ///<Data function to plot
00184                 CDataFunc *datafunc;    ///<Data function execution unit
00185                 bool twod;                              ///<Two-dimensional function?
00186                 bool startendgrad[4];   ///<Draw start, end, gradient or size text?
00187         } *primatives;          ///<List of primatives
00188         int nPrimatives;        ///<Number of primatives
00189 
00190 private:
00191         void createPrimative(primative::typemode p);
00192         void newPrimative(primative::typemode p);
00193         void deletePrimative(int idx);
00194 
00195 };
00196 
00197 #endif

Generated on Mon Mar 10 13:55:44 2008 for GreyLab by  doxygen 1.5.3