• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

/builddir/build/BUILD/liborigin2-20100422/OriginObj.h

Go to the documentation of this file.
00001 /***************************************************************************
00002     File                 : OriginObj.h
00003     --------------------------------------------------------------------
00004     Copyright            : (C) 2005-2007 Stefan Gerlach
00005                            (C) 2007-2008 Alex Kargovsky, Ion Vasilief
00006     Email (use @ for *)  : kargovsky*yumr.phys.msu.su, ion_vasilief*yahoo.fr
00007     Description          : Origin internal object classes
00008 
00009  ***************************************************************************/
00010 
00011 /***************************************************************************
00012  *                                                                         *
00013  *  This program is free software; you can redistribute it and/or modify   *
00014  *  it under the terms of the GNU General Public License as published by   *
00015  *  the Free Software Foundation; either version 2 of the License, or      *
00016  *  (at your option) any later version.                                    *
00017  *                                                                         *
00018  *  This program is distributed in the hope that it will be useful,        *
00019  *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
00020  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
00021  *  GNU General Public License for more details.                           *
00022  *                                                                         *
00023  *   You should have received a copy of the GNU General Public License     *
00024  *   along with this program; if not, write to the Free Software           *
00025  *   Foundation, Inc., 51 Franklin Street, Fifth Floor,                    *
00026  *   Boston, MA  02110-1301  USA                                           *
00027  *                                                                         *
00028  ***************************************************************************/
00029 
00030 
00031 #ifndef ORIGIN_OBJ_H
00032 #define ORIGIN_OBJ_H
00033 
00034 #include <string.h>
00035 #include <vector>
00036 #include "boost/variant.hpp"
00037 #include "boost/bind.hpp"
00038 #include "boost/date_time/posix_time/ptime.hpp"
00039 
00040 using namespace std;
00041 
00042 #define _ONAN       (-1.23456789E-300)
00043 
00044 namespace Origin
00045 {
00046     enum ValueType {Numeric = 0, Text = 1, Time = 2, Date = 3,  Month = 4, Day = 5, ColumnHeading = 6, TickIndexedDataset = 7, TextNumeric = 9, Categorical = 10};
00047     enum NumericDisplayType {DefaultDecimalDigits = 0, DecimalPlaces = 1, SignificantDigits = 2};
00048     enum Attach {Frame = 0, Page = 1, Scale = 2};
00049     enum BorderType {BlackLine = 0, Shadow = 1, DarkMarble = 2, WhiteOut = 3, BlackOut = 4, None = -1};
00050     enum FillPattern {NoFill, BDiagDense, BDiagMedium, BDiagSparse, FDiagDense, FDiagMedium, FDiagSparse, 
00051         DiagCrossDense, DiagCrossMedium, DiagCrossSparse, HorizontalDense, HorizontalMedium, HorizontalSparse, 
00052         VerticalDense, VerticalMedium, VerticalSparse, CrossDense, CrossMedium, CrossSparse};
00053 
00054     struct Color
00055     {
00056         enum ColorType {None, Automatic, Regular, Custom, Increment, Indexing, RGB, Mapping};
00057         enum RegularColor {Black = 0, Red = 1, Green = 2, Blue = 3, Cyan = 4, Magenta = 5, Yellow = 6, DarkYellow = 7, Navy = 8,
00058             Purple = 9, Wine = 10, Olive = 11, DarkCyan = 12, Royal=  13, Orange = 14, Violet = 15, Pink = 16, White = 17,
00059             LightGray = 18, Gray = 19, LTYellow = 20, LTCyan = 21, LTMagenta = 22, DarkGray = 23/*, Custom = 255*/};
00060 
00061         ColorType type;
00062         union
00063         {
00064             unsigned char regular;
00065             unsigned char custom[3];
00066             unsigned char starting;
00067             unsigned char column;
00068         };
00069     };
00070 
00071     struct Rect
00072     {
00073         short left;
00074         short top;
00075         short right;
00076         short bottom;
00077 
00078         Rect(short width = 0, short height = 0)
00079         :   left(0)
00080         ,   top(0)
00081         ,   right(width)
00082         ,   bottom(height)
00083         {
00084         };
00085 
00086         int height() const
00087         {
00088             return bottom - top;
00089         };
00090 
00091         int width() const
00092         {
00093             return right - left;
00094         };
00095 
00096         bool isValid() const
00097         {
00098             return height() > 0 && width() > 0;
00099         }
00100     };
00101 
00102     struct ColorMapLevel
00103     {
00104         Color fillColor;
00105         unsigned char fillPattern;
00106         Color fillPatternColor;
00107         double fillPatternLineWidth;
00108 
00109         bool lineVisible;
00110         Color lineColor;
00111         unsigned char lineStyle;
00112         double lineWidth;
00113 
00114         bool labelVisible;
00115     };
00116 
00117     typedef vector<pair<double, ColorMapLevel> > ColorMapVector;
00118 
00119     struct ColorMap
00120     {
00121         bool fillEnabled;
00122         ColorMapVector levels;
00123     };
00124 
00125     struct Window
00126     {
00127         enum State {Normal, Minimized, Maximized};
00128         enum Title {Name, Label, Both};
00129 
00130         string name;
00131         string label;
00132         unsigned int objectID;
00133         bool hidden;
00134         State state;
00135         Title title;
00136         Rect frameRect;
00137         boost::posix_time::ptime creationDate;
00138         boost::posix_time::ptime modificationDate;
00139 
00140         Window(const string& _name= "", const string& _label = "", bool _hidden = false)
00141         :   name(_name)
00142         ,   label(_label)
00143         ,   hidden(_hidden)
00144         ,   state(Normal)
00145         ,   title(Both)
00146         {};
00147     };
00148 
00149     typedef boost::variant<double, string> variant;
00150 
00151     struct SpreadColumn
00152     {
00153         enum ColumnType {X, Y, Z, XErr, YErr, Label, NONE};
00154 
00155         string name;
00156         ColumnType type;
00157         ValueType valueType;
00158         int valueTypeSpecification;
00159         int significantDigits;
00160         int decimalPlaces;
00161         NumericDisplayType numericDisplayType;
00162         string command;
00163         string comment;
00164         int width;
00165         unsigned int index;
00166         unsigned int sheet;
00167         vector<variant> data;
00168 
00169         SpreadColumn(const string& _name = "", unsigned int _index = 0)
00170         :   name(_name)
00171         ,   index(_index)
00172         ,   command("")
00173         ,   comment("")
00174         ,   valueType(Numeric)
00175         ,   valueTypeSpecification(0)
00176         ,   significantDigits(6)
00177         ,   decimalPlaces(6)
00178         ,   width(8)
00179         ,   numericDisplayType(DefaultDecimalDigits)
00180         ,   sheet(0)
00181         {};
00182     };
00183 
00184     struct SpreadSheet : public Window
00185     {
00186         unsigned int maxRows;
00187         bool loose;
00188         bool multisheet;
00189         unsigned int sheets;
00190         vector<SpreadColumn> columns;
00191 
00192         SpreadSheet(const string& _name = "")
00193         :   Window(_name)
00194         ,   loose(true)
00195         ,   multisheet(false)
00196         ,   sheets(1)
00197         {};
00198     };
00199 
00200     struct Excel : public Window
00201     {
00202         unsigned int maxRows;
00203         bool loose;
00204         vector<SpreadSheet> sheets;
00205 
00206         Excel(const string& _name = "", const string& _label = "", int _maxRows = 0, bool _hidden = false, bool _loose = true)
00207         :   Window(_name, _label, _hidden)
00208         ,   maxRows(_maxRows)
00209         ,   loose(_loose)
00210         {
00211         };
00212     };
00213 
00214     struct Matrix : public Window
00215     {
00216         enum ViewType {DataView, ImageView};
00217         enum HeaderViewType {ColumnRow, XY};
00218 
00219         unsigned short rowCount;
00220         unsigned short columnCount;
00221         int valueTypeSpecification;
00222         int significantDigits;
00223         int decimalPlaces;
00224         NumericDisplayType numericDisplayType;
00225         string command;
00226         int width;
00227         unsigned int index;
00228         unsigned int sheets;
00229         ViewType view;
00230         HeaderViewType header;
00231         ColorMap colorMap;
00232         vector<double> data;
00233         vector<double> coordinates;
00234 
00235         Matrix(const string& _name = "", unsigned int _index = 0)
00236         :   Window(_name)
00237         ,   index(_index)
00238         ,   sheets(1)
00239         ,   command("")
00240         ,   valueTypeSpecification(0)
00241         ,   significantDigits(6)
00242         ,   decimalPlaces(6)
00243         ,   width(8)
00244         ,   numericDisplayType(DefaultDecimalDigits)
00245         ,   view(DataView)
00246         ,   header(ColumnRow)
00247         {coordinates.push_back(10.0);coordinates.push_back(10.0);coordinates.push_back(1.0);coordinates.push_back(1.0);};
00248     };
00249 
00250     struct Function
00251     {
00252         enum FunctionType {Normal, Polar};
00253 
00254         string name;
00255         FunctionType type;
00256         string formula;
00257         double begin;
00258         double end;
00259         int totalPoints;
00260         unsigned int index;
00261 
00262         Function(const string& _name = "", unsigned int _index = 0)
00263         :   name(_name)
00264         ,   index(_index)
00265         ,   type(Normal)
00266         ,   formula("")
00267         ,   begin(0.0)
00268         ,   end(0.0)
00269         ,   totalPoints(0)
00270         {};
00271     };
00272 
00273 
00274     struct TextBox
00275     {
00276         string text;
00277         Rect clientRect;
00278         Color color;
00279         unsigned short fontSize;
00280         int rotation;
00281         int tab;
00282         BorderType borderType;
00283         Attach attach;
00284 
00285         TextBox(const string& _text = "")
00286         :   text(_text)
00287         {};
00288 
00289         TextBox(const string& _text, const Rect& _clientRect, const Color& _color, unsigned short _fontSize, int _rotation, int _tab, BorderType _borderType, Attach _attach)
00290         :   text(_text)
00291         ,   clientRect(_clientRect)
00292         ,   color(_color)
00293         ,   fontSize(_fontSize)
00294         ,   rotation(_rotation)
00295         ,   tab(_tab)
00296         ,   borderType(_borderType)
00297         ,   attach(_attach)
00298         {};
00299     };
00300 
00301     struct PieProperties
00302     {
00303         unsigned char viewAngle;
00304         unsigned char thickness;
00305         bool clockwiseRotation;
00306         short rotation;
00307         unsigned short radius;
00308         unsigned short horizontalOffset;
00309         unsigned long displacedSectionCount; // maximum - 32 sections
00310         unsigned short displacement;
00311         
00312         //labels
00313         bool formatAutomatic;
00314         bool formatValues;
00315         bool formatPercentages;
00316         bool formatCategories;
00317         bool positionAssociate;
00318         unsigned short distance;
00319 
00320         PieProperties()
00321         :   clockwiseRotation(false)
00322         ,   formatAutomatic(false)
00323         ,   formatValues(false)
00324         ,   formatPercentages(false)
00325         ,   formatCategories(false)
00326         ,   positionAssociate(false)
00327         {};
00328     };
00329 
00330     struct VectorProperties
00331     {
00332         enum VectorPosition {Tail, Midpoint, Head};
00333 
00334         Color color;
00335         double width;
00336         unsigned short arrowLenght;
00337         unsigned char arrowAngle;
00338         bool arrowClosed;
00339         string endXColumnName;
00340         string endYColumnName;
00341 
00342         VectorPosition position;
00343         string angleColumnName;
00344         string magnitudeColumnName;
00345         float multiplier;
00346         int constAngle;
00347         int constMagnitude;
00348 
00349         VectorProperties()
00350         :   arrowClosed(false)
00351         ,   position(Tail)
00352         ,   multiplier(1.0)
00353         ,   constAngle(0)
00354         ,   constMagnitude(0)
00355         {};
00356     };
00357 
00358     struct TextProperties
00359     {
00360         enum Justify {Left, Center, Right};
00361 
00362         Color color;
00363         bool fontBold;
00364         bool fontItalic;
00365         bool fontUnderline;
00366         bool whiteOut;
00367         Justify justify;
00368 
00369         short rotation;
00370         short xOffset;
00371         short yOffset;
00372         unsigned short fontSize;
00373     };
00374 
00375     struct SurfaceProperties
00376     {
00377         struct SurfaceColoration
00378         {
00379             bool fill;
00380             bool contour;
00381             Color lineColor;
00382             double lineWidth;
00383         };
00384 
00385         enum Type {ColorMap3D, ColorFill, WireFrame, Bars};
00386         enum Grids {None, X, Y, XY};
00387 
00388         unsigned char type;
00389         Grids grids;
00390         double gridLineWidth;
00391         Color gridColor;
00392 
00393         bool backColorEnabled;
00394         Color frontColor;
00395         Color backColor;
00396 
00397         bool sideWallEnabled;
00398         Color xSideWallColor;
00399         Color ySideWallColor;
00400 
00401         SurfaceColoration surface;
00402         SurfaceColoration topContour;
00403         SurfaceColoration bottomContour;
00404 
00405         ColorMap colorMap;
00406     };
00407 
00408     struct PercentileProperties
00409     {
00410         unsigned char maxSymbolType;
00411         unsigned char p99SymbolType;
00412         unsigned char meanSymbolType;
00413         unsigned char p1SymbolType;
00414         unsigned char minSymbolType;
00415         Color symbolColor;
00416         Color symbolFillColor;
00417         unsigned short symbolSize;
00418         unsigned char boxRange;
00419         unsigned char whiskersRange;
00420         double boxCoeff;
00421         double whiskersCoeff;
00422         bool diamondBox;
00423     };
00424 
00425     struct GraphCurve
00426     {
00427         enum Plot {Line = 200, Scatter=201, LineSymbol=202, Column = 203, Area = 204, HiLoClose = 205, Box = 206,
00428             ColumnFloat = 207, Vector = 208, PlotDot = 209, Wall3D = 210, Ribbon3D = 211, Bar3D = 212, ColumnStack = 213,
00429             AreaStack = 214, Bar = 215, BarStack = 216, FlowVector = 218, Histogram = 219, MatrixImage = 220, Pie = 225,
00430             Contour = 226, Unknown = 230, ErrorBar = 231, TextPlot = 232, XErrorBar = 233, SurfaceColorMap = 236,
00431             SurfaceColorFill = 237, SurfaceWireframe = 238, SurfaceBars = 239, Line3D = 240, Text3D = 241, Mesh3D = 242,
00432             XYZTriangular = 245, LineSeries = 246, YErrorBar = 254, XYErrorBar = 255, GraphScatter3D = 0x8AF0,
00433             GraphTrajectory3D = 0x8AF1, Polar = 0x00020000, SmithChart = 0x00040000, FillArea = 0x00800000};
00434         enum LineStyle {Solid = 0, Dash = 1, Dot = 2, DashDot = 3, DashDotDot = 4, ShortDash = 5, ShortDot = 6, ShortDashDot = 7};
00435         enum LineConnect {NoLine = 0, Straight = 1, TwoPointSegment = 2, ThreePointSegment = 3, BSpline = 8, Spline = 9, StepHorizontal = 11, StepVertical = 12, StepHCenter = 13, StepVCenter = 14, Bezier = 15};
00436 
00437         unsigned char type;
00438         string dataName;
00439         string xColumnName;
00440         string yColumnName;
00441         string zColumnName;
00442         Color lineColor;
00443         unsigned char lineStyle;
00444         unsigned char lineConnect;
00445         unsigned char boxWidth;
00446         double lineWidth;
00447 
00448         bool fillArea;
00449         unsigned char fillAreaType;
00450         unsigned char fillAreaPattern;
00451         Color fillAreaColor;
00452         Color fillAreaPatternColor;
00453         double fillAreaPatternWidth;
00454         unsigned char fillAreaPatternBorderStyle;
00455         Color fillAreaPatternBorderColor;
00456         double fillAreaPatternBorderWidth;
00457 
00458         unsigned short symbolType;
00459         Color symbolColor;
00460         Color symbolFillColor;
00461         double symbolSize;
00462         unsigned char symbolThickness;
00463         unsigned char pointOffset;
00464 
00465         bool connectSymbols;
00466 
00467         //pie
00468         PieProperties pie;
00469 
00470         //vector
00471         VectorProperties vector;
00472 
00473         //text
00474         TextProperties text;
00475 
00476         //surface
00477         SurfaceProperties surface;
00478 
00479         //contour
00480         ColorMap colorMap;
00481     };
00482 
00483     struct GraphAxisBreak
00484     {
00485         bool show;
00486 
00487         bool log10;
00488         double from;
00489         double to;
00490         double position;
00491 
00492         double scaleIncrementBefore;
00493         double scaleIncrementAfter;
00494 
00495         unsigned char minorTicksBefore;
00496         unsigned char minorTicksAfter;
00497 
00498         GraphAxisBreak()
00499         :   show(false)
00500         {};
00501     };
00502 
00503     struct GraphGrid
00504     {
00505         bool hidden;
00506         unsigned char color;
00507         unsigned char style;
00508         double width;
00509     };
00510 
00511     struct GraphAxisFormat
00512     {
00513         bool hidden;
00514         unsigned char color;
00515         double thickness;
00516         double majorTickLength;
00517         int majorTicksType;
00518         int minorTicksType;
00519         int axisPosition;
00520         double axisPositionValue;
00521         TextBox label;
00522     };
00523 
00524     struct GraphAxisTick
00525     {
00526         bool hidden;
00527         unsigned char color;
00528         ValueType valueType;
00529         int valueTypeSpecification; 
00530         int decimalPlaces;
00531         unsigned short fontSize;
00532         bool fontBold;
00533         string dataName;
00534         string columnName;
00535         int rotation;
00536     };
00537 
00538     struct GraphAxis
00539     {
00540         enum AxisPosition {Left = 0, Bottom, Right, Top, Front, Back};
00541         enum Scale {Linear = 0, Log10 = 1, Probability = 2, Probit = 3, Reciprocal = 4, OffsetReciprocal = 5, Logit = 6, Ln = 7, Log2 = 8};
00542 
00543         AxisPosition position;
00544         double min;
00545         double max;
00546         double step;
00547         unsigned char majorTicks;
00548         unsigned char minorTicks;
00549         unsigned char scale;
00550         GraphGrid majorGrid;
00551         GraphGrid minorGrid;
00552         GraphAxisFormat formatAxis[2];
00553         GraphAxisTick tickAxis[2]; //bottom-top, left-right
00554     };
00555 
00556     struct Figure
00557     {
00558         enum FigureType {Rectangle, Circle};
00559 
00560         FigureType type;
00561         Rect clientRect;
00562         Attach attach;
00563         Color color;
00564         unsigned char style;
00565         double width;
00566         Color fillAreaColor;
00567         unsigned char fillAreaPattern;
00568         Color fillAreaPatternColor;
00569         double fillAreaPatternWidth;
00570         bool useBorderColor;
00571 
00572         Figure(FigureType _type = Rectangle)
00573         :   type(_type)
00574         {
00575         };
00576     };
00577 
00578     struct LineVertex
00579     {
00580         unsigned char shapeType;
00581         double shapeWidth;
00582         double shapeLength;
00583         double x;
00584         double y;
00585 
00586         LineVertex()
00587         :   shapeType(0)
00588         ,   shapeWidth(0.0)
00589         ,   shapeLength(0.0)
00590         ,   x(0.0)
00591         ,   y(0.0)
00592         {};
00593     };
00594 
00595     struct Line
00596     {
00597         Rect clientRect;
00598         Color color;
00599         Attach attach;
00600         double width;
00601         unsigned char style;
00602         LineVertex begin;
00603         LineVertex end;
00604     };
00605 
00606     struct Bitmap
00607     {
00608         Rect clientRect;
00609         Attach attach;
00610         unsigned long size;
00611         string windowName;
00612         BorderType borderType;
00613         unsigned char* data;
00614 
00615         Bitmap(const string& _name = "")
00616         :   size(0)
00617         ,   data(0)
00618         ,   windowName(_name)
00619         ,   borderType(Origin::None)
00620         {
00621         };
00622 
00623         Bitmap(const Bitmap& bitmap)
00624         :   clientRect(bitmap.clientRect)
00625         ,   attach(bitmap.attach)
00626         ,   size(bitmap.size)
00627         ,   windowName(bitmap.windowName)
00628         ,   borderType(bitmap.borderType)
00629         {
00630             if(size > 0)
00631             {
00632                 data = new unsigned char[size];
00633                 memcpy(data, bitmap.data, size);
00634             }
00635         };
00636 
00637         ~Bitmap()
00638         {
00639             if(size > 0)
00640                 delete data;
00641         };
00642     };
00643 
00644     struct GraphLayer
00645     {
00646         Rect clientRect;
00647         TextBox legend;
00648         Color backgroundColor;
00649         BorderType borderType;
00650 
00651         GraphAxis xAxis;
00652         GraphAxis yAxis;
00653         GraphAxis zAxis;
00654 
00655         GraphAxisBreak xAxisBreak;
00656         GraphAxisBreak yAxisBreak;
00657         GraphAxisBreak zAxisBreak;
00658 
00659         double histogramBin;
00660         double histogramBegin;
00661         double histogramEnd;
00662 
00663         PercentileProperties percentile;
00664 
00665         vector<TextBox> texts;
00666         vector<Line> lines;
00667         vector<Figure> figures;
00668         vector<Bitmap> bitmaps;
00669         vector<GraphCurve> curves;
00670 
00671         float xLength;
00672         float yLength;
00673         float zLength;
00674 
00675         bool imageProfileTool;
00676         double vLine;
00677         double hLine;
00678 
00679         bool isXYY3D;
00680 
00681         GraphLayer()
00682         :   imageProfileTool(false)
00683         ,   isXYY3D(false)
00684         {};
00685 
00686         //bool threeDimensional;
00687         bool is3D() const
00688         {
00689             return curves.end() != find_if(curves.begin(), curves.end(),
00690                                             boost::bind(logical_or<bool>(), boost::bind(&GraphCurve::type, _1) == GraphCurve::Line3D,  
00691                                             boost::bind(&GraphCurve::type, _1) == GraphCurve::Mesh3D));
00692         }
00693     };
00694 
00695     struct GraphLayerRange
00696     {
00697         double min;
00698         double max;
00699         double step;
00700 
00701         GraphLayerRange(double _min = 0.0, double _max = 0.0, double _step = 0.0)
00702         :   min(_min)
00703         ,   max(_max)
00704         ,   step(_step)
00705         {};
00706     };
00707 
00708     struct Graph : public Window
00709     {
00710         vector<GraphLayer> layers;
00711         unsigned short width;
00712         unsigned short height;
00713         bool is3D;
00714         bool isLayout;
00715 
00716         Graph(const string& _name = "")
00717         :   Window(_name)
00718         ,   is3D(false)
00719         ,   isLayout(false)
00720         {};
00721     };
00722 
00723     struct Note : public Window
00724     {
00725         string text;
00726         Note(const string& _name = "")
00727         :   Window(_name)
00728         {};
00729     };
00730 
00731     struct ProjectNode
00732     {
00733         enum NodeType {SpreadSheet, Matrix, Excel, Graph, Graph3D, Note, Folder};
00734 
00735         NodeType type;
00736         string name;
00737         boost::posix_time::ptime creationDate;
00738         boost::posix_time::ptime modificationDate;
00739 
00740         ProjectNode(const string& _name = "", NodeType _type = Folder, const boost::posix_time::ptime& _creationDate = boost::posix_time::ptime(), const boost::posix_time::ptime& _modificationDate = boost::posix_time::ptime())
00741         :   name(_name)
00742         ,   type(_type)
00743         ,   creationDate(_creationDate)
00744         ,   modificationDate(_modificationDate)
00745         {};
00746     };
00747 }
00748 
00749 
00750 
00751 #endif // ORIGIN_OBJ_H

Generated on Thu Jan 20 2011 for liborigin2 by  doxygen 1.7.1