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

/builddir/build/BUILD/liborigin2/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         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         ,   objectID(-1)
00144         ,   hidden(_hidden)
00145         ,   state(Normal)
00146         ,   title(Both)
00147         {};
00148     };
00149 
00150     typedef boost::variant<double, string> variant;
00151 
00152     struct SpreadColumn
00153     {
00154         enum ColumnType {X, Y, Z, XErr, YErr, Label, NONE};
00155 
00156         string name;
00157         ColumnType type;
00158         ValueType valueType;
00159         int valueTypeSpecification;
00160         int significantDigits;
00161         int decimalPlaces;
00162         NumericDisplayType numericDisplayType;
00163         string command;
00164         string comment;
00165         int width;
00166         unsigned int index;
00167         unsigned int sheet;
00168         vector<variant> data;
00169 
00170         SpreadColumn(const string& _name = "", unsigned int _index = 0)
00171         :   name(_name)
00172         ,   index(_index)
00173         ,   command("")
00174         ,   comment("")
00175         ,   valueType(Numeric)
00176         ,   valueTypeSpecification(0)
00177         ,   significantDigits(6)
00178         ,   decimalPlaces(6)
00179         ,   width(8)
00180         ,   numericDisplayType(DefaultDecimalDigits)
00181         ,   sheet(0)
00182         {};
00183     };
00184 
00185     struct SpreadSheet : public Window
00186     {
00187         unsigned int maxRows;
00188         bool loose;
00189         bool multisheet;
00190         unsigned int sheets;
00191         vector<SpreadColumn> columns;
00192 
00193         SpreadSheet(const string& _name = "")
00194         :   Window(_name)
00195         ,   loose(true)
00196         ,   multisheet(false)
00197         ,   sheets(1)
00198         {};
00199     };
00200 
00201     struct Excel : public Window
00202     {
00203         unsigned int maxRows;
00204         bool loose;
00205         vector<SpreadSheet> sheets;
00206 
00207         Excel(const string& _name = "", const string& _label = "", int _maxRows = 0, bool _hidden = false, bool _loose = true)
00208         :   Window(_name, _label, _hidden)
00209         ,   maxRows(_maxRows)
00210         ,   loose(_loose)
00211         {
00212         };
00213     };
00214 
00215     struct Matrix : public Window
00216     {
00217         enum ViewType {DataView, ImageView};
00218         enum HeaderViewType {ColumnRow, XY};
00219 
00220         unsigned short rowCount;
00221         unsigned short columnCount;
00222         int valueTypeSpecification;
00223         int significantDigits;
00224         int decimalPlaces;
00225         NumericDisplayType numericDisplayType;
00226         string command;
00227         int width;
00228         unsigned int index;
00229         unsigned int sheets;
00230         ViewType view;
00231         HeaderViewType header;
00232         ColorMap colorMap;
00233         vector<double> data;
00234         vector<double> coordinates;
00235 
00236         Matrix(const string& _name = "", unsigned int _index = 0)
00237         :   Window(_name)
00238         ,   index(_index)
00239         ,   sheets(1)
00240         ,   command("")
00241         ,   valueTypeSpecification(0)
00242         ,   significantDigits(6)
00243         ,   decimalPlaces(6)
00244         ,   width(8)
00245         ,   numericDisplayType(DefaultDecimalDigits)
00246         ,   view(DataView)
00247         ,   header(ColumnRow)
00248         {coordinates.push_back(10.0);coordinates.push_back(10.0);coordinates.push_back(1.0);coordinates.push_back(1.0);};
00249     };
00250 
00251     struct Function
00252     {
00253         enum FunctionType {Normal, Polar};
00254 
00255         string name;
00256         FunctionType type;
00257         string formula;
00258         double begin;
00259         double end;
00260         int totalPoints;
00261         unsigned int index;
00262 
00263         Function(const string& _name = "", unsigned int _index = 0)
00264         :   name(_name)
00265         ,   index(_index)
00266         ,   type(Normal)
00267         ,   formula("")
00268         ,   begin(0.0)
00269         ,   end(0.0)
00270         ,   totalPoints(0)
00271         {};
00272     };
00273 
00274 
00275     struct TextBox
00276     {
00277         string text;
00278         Rect clientRect;
00279         Color color;
00280         unsigned short fontSize;
00281         int rotation;
00282         int tab;
00283         BorderType borderType;
00284         Attach attach;
00285 
00286         TextBox(const string& _text = "")
00287         :   text(_text)
00288         {};
00289 
00290         TextBox(const string& _text, const Rect& _clientRect, const Color& _color, unsigned short _fontSize, int _rotation, int _tab, BorderType _borderType, Attach _attach)
00291         :   text(_text)
00292         ,   clientRect(_clientRect)
00293         ,   color(_color)
00294         ,   fontSize(_fontSize)
00295         ,   rotation(_rotation)
00296         ,   tab(_tab)
00297         ,   borderType(_borderType)
00298         ,   attach(_attach)
00299         {};
00300     };
00301 
00302     struct PieProperties
00303     {
00304         unsigned char viewAngle;
00305         unsigned char thickness;
00306         bool clockwiseRotation;
00307         short rotation;
00308         unsigned short radius;
00309         unsigned short horizontalOffset;
00310         unsigned long displacedSectionCount; // maximum - 32 sections
00311         unsigned short displacement;
00312         
00313         //labels
00314         bool formatAutomatic;
00315         bool formatValues;
00316         bool formatPercentages;
00317         bool formatCategories;
00318         bool positionAssociate;
00319         unsigned short distance;
00320 
00321         PieProperties()
00322         :   clockwiseRotation(false)
00323         ,   formatAutomatic(false)
00324         ,   formatValues(false)
00325         ,   formatPercentages(false)
00326         ,   formatCategories(false)
00327         ,   positionAssociate(false)
00328         {};
00329     };
00330 
00331     struct VectorProperties
00332     {
00333         enum VectorPosition {Tail, Midpoint, Head};
00334 
00335         Color color;
00336         double width;
00337         unsigned short arrowLenght;
00338         unsigned char arrowAngle;
00339         bool arrowClosed;
00340         string endXColumnName;
00341         string endYColumnName;
00342 
00343         VectorPosition position;
00344         string angleColumnName;
00345         string magnitudeColumnName;
00346         float multiplier;
00347         int constAngle;
00348         int constMagnitude;
00349 
00350         VectorProperties()
00351         :   arrowClosed(false)
00352         ,   position(Tail)
00353         ,   multiplier(1.0)
00354         ,   constAngle(0)
00355         ,   constMagnitude(0)
00356         {};
00357     };
00358 
00359     struct TextProperties
00360     {
00361         enum Justify {Left, Center, Right};
00362 
00363         Color color;
00364         bool fontBold;
00365         bool fontItalic;
00366         bool fontUnderline;
00367         bool whiteOut;
00368         Justify justify;
00369 
00370         short rotation;
00371         short xOffset;
00372         short yOffset;
00373         unsigned short fontSize;
00374     };
00375 
00376     struct SurfaceProperties
00377     {
00378         struct SurfaceColoration
00379         {
00380             bool fill;
00381             bool contour;
00382             Color lineColor;
00383             double lineWidth;
00384         };
00385 
00386         enum Type {ColorMap3D, ColorFill, WireFrame, Bars};
00387         enum Grids {None, X, Y, XY};
00388 
00389         unsigned char type;
00390         Grids grids;
00391         double gridLineWidth;
00392         Color gridColor;
00393 
00394         bool backColorEnabled;
00395         Color frontColor;
00396         Color backColor;
00397 
00398         bool sideWallEnabled;
00399         Color xSideWallColor;
00400         Color ySideWallColor;
00401 
00402         SurfaceColoration surface;
00403         SurfaceColoration topContour;
00404         SurfaceColoration bottomContour;
00405 
00406         ColorMap colorMap;
00407     };
00408 
00409     struct PercentileProperties
00410     {
00411         unsigned char maxSymbolType;
00412         unsigned char p99SymbolType;
00413         unsigned char meanSymbolType;
00414         unsigned char p1SymbolType;
00415         unsigned char minSymbolType;
00416         Color symbolColor;
00417         Color symbolFillColor;
00418         unsigned short symbolSize;
00419         unsigned char boxRange;
00420         unsigned char whiskersRange;
00421         double boxCoeff;
00422         double whiskersCoeff;
00423         bool diamondBox;
00424     };
00425 
00426     struct GraphCurve
00427     {
00428         enum Plot {Line = 200, Scatter=201, LineSymbol=202, Column = 203, Area = 204, HiLoClose = 205, Box = 206,
00429             ColumnFloat = 207, Vector = 208, PlotDot = 209, Wall3D = 210, Ribbon3D = 211, Bar3D = 212, ColumnStack = 213,
00430             AreaStack = 214, Bar = 215, BarStack = 216, FlowVector = 218, Histogram = 219, MatrixImage = 220, Pie = 225,
00431             Contour = 226, Unknown = 230, ErrorBar = 231, TextPlot = 232, XErrorBar = 233, SurfaceColorMap = 236,
00432             SurfaceColorFill = 237, SurfaceWireframe = 238, SurfaceBars = 239, Line3D = 240, Text3D = 241, Mesh3D = 242,
00433             XYZTriangular = 245, LineSeries = 246, YErrorBar = 254, XYErrorBar = 255, GraphScatter3D = 0x8AF0,
00434             GraphTrajectory3D = 0x8AF1, Polar = 0x00020000, SmithChart = 0x00040000, FillArea = 0x00800000};
00435         enum LineStyle {Solid = 0, Dash = 1, Dot = 2, DashDot = 3, DashDotDot = 4, ShortDash = 5, ShortDot = 6, ShortDashDot = 7};
00436         enum LineConnect {NoLine = 0, Straight = 1, TwoPointSegment = 2, ThreePointSegment = 3, BSpline = 8, Spline = 9, StepHorizontal = 11, StepVertical = 12, StepHCenter = 13, StepVCenter = 14, Bezier = 15};
00437 
00438         unsigned char type;
00439         string dataName;
00440         string xColumnName;
00441         string yColumnName;
00442         string zColumnName;
00443         Color lineColor;
00444         unsigned char lineStyle;
00445         unsigned char lineConnect;
00446         unsigned char boxWidth;
00447         double lineWidth;
00448 
00449         bool fillArea;
00450         unsigned char fillAreaType;
00451         unsigned char fillAreaPattern;
00452         Color fillAreaColor;
00453         Color fillAreaPatternColor;
00454         double fillAreaPatternWidth;
00455         unsigned char fillAreaPatternBorderStyle;
00456         Color fillAreaPatternBorderColor;
00457         double fillAreaPatternBorderWidth;
00458 
00459         unsigned short symbolType;
00460         Color symbolColor;
00461         Color symbolFillColor;
00462         double symbolSize;
00463         unsigned char symbolThickness;
00464         unsigned char pointOffset;
00465 
00466         bool connectSymbols;
00467 
00468         //pie
00469         PieProperties pie;
00470 
00471         //vector
00472         VectorProperties vector;
00473 
00474         //text
00475         TextProperties text;
00476 
00477         //surface
00478         SurfaceProperties surface;
00479 
00480         //contour
00481         ColorMap colorMap;
00482     };
00483 
00484     struct GraphAxisBreak
00485     {
00486         bool show;
00487 
00488         bool log10;
00489         double from;
00490         double to;
00491         double position;
00492 
00493         double scaleIncrementBefore;
00494         double scaleIncrementAfter;
00495 
00496         unsigned char minorTicksBefore;
00497         unsigned char minorTicksAfter;
00498 
00499         GraphAxisBreak()
00500         :   show(false)
00501         {};
00502     };
00503 
00504     struct GraphGrid
00505     {
00506         bool hidden;
00507         unsigned char color;
00508         unsigned char style;
00509         double width;
00510     };
00511 
00512     struct GraphAxisFormat
00513     {
00514         bool hidden;
00515         unsigned char color;
00516         double thickness;
00517         double majorTickLength;
00518         int majorTicksType;
00519         int minorTicksType;
00520         int axisPosition;
00521         double axisPositionValue;
00522         TextBox label;
00523         string prefix;
00524         string suffix;
00525     };
00526 
00527     struct GraphAxisTick
00528     {
00529         bool hidden;
00530         unsigned char color;
00531         ValueType valueType;
00532         int valueTypeSpecification; 
00533         int decimalPlaces;
00534         unsigned short fontSize;
00535         bool fontBold;
00536         string dataName;
00537         string columnName;
00538         int rotation;
00539     };
00540 
00541     struct GraphAxis
00542     {
00543         enum AxisPosition {Left = 0, Bottom, Right, Top, Front, Back};
00544         enum Scale {Linear = 0, Log10 = 1, Probability = 2, Probit = 3, Reciprocal = 4, OffsetReciprocal = 5, Logit = 6, Ln = 7, Log2 = 8};
00545 
00546         AxisPosition position;
00547         double min;
00548         double max;
00549         double step;
00550         unsigned char majorTicks;
00551         unsigned char minorTicks;
00552         unsigned char scale;
00553         GraphGrid majorGrid;
00554         GraphGrid minorGrid;
00555         GraphAxisFormat formatAxis[2];
00556         GraphAxisTick tickAxis[2]; //bottom-top, left-right
00557     };
00558 
00559     struct Figure
00560     {
00561         enum FigureType {Rectangle, Circle};
00562 
00563         FigureType type;
00564         Rect clientRect;
00565         Attach attach;
00566         Color color;
00567         unsigned char style;
00568         double width;
00569         Color fillAreaColor;
00570         unsigned char fillAreaPattern;
00571         Color fillAreaPatternColor;
00572         double fillAreaPatternWidth;
00573         bool useBorderColor;
00574 
00575         Figure(FigureType _type = Rectangle)
00576         :   type(_type)
00577         {
00578         };
00579     };
00580 
00581     struct LineVertex
00582     {
00583         unsigned char shapeType;
00584         double shapeWidth;
00585         double shapeLength;
00586         double x;
00587         double y;
00588 
00589         LineVertex()
00590         :   shapeType(0)
00591         ,   shapeWidth(0.0)
00592         ,   shapeLength(0.0)
00593         ,   x(0.0)
00594         ,   y(0.0)
00595         {};
00596     };
00597 
00598     struct Line
00599     {
00600         Rect clientRect;
00601         Color color;
00602         Attach attach;
00603         double width;
00604         unsigned char style;
00605         LineVertex begin;
00606         LineVertex end;
00607     };
00608 
00609     struct Bitmap
00610     {
00611         Rect clientRect;
00612         Attach attach;
00613         unsigned long size;
00614         string windowName;
00615         BorderType borderType;
00616         unsigned char* data;
00617 
00618         Bitmap(const string& _name = "")
00619         :   size(0)
00620         ,   data(0)
00621         ,   windowName(_name)
00622         ,   borderType(Origin::None)
00623         {
00624         };
00625 
00626         Bitmap(const Bitmap& bitmap)
00627         :   clientRect(bitmap.clientRect)
00628         ,   attach(bitmap.attach)
00629         ,   size(bitmap.size)
00630         ,   windowName(bitmap.windowName)
00631         ,   borderType(bitmap.borderType)
00632         {
00633             if(size > 0)
00634             {
00635                 data = new unsigned char[size];
00636                 memcpy(data, bitmap.data, size);
00637             }
00638         };
00639 
00640         ~Bitmap()
00641         {
00642             if(size > 0)
00643                 delete data;
00644         };
00645     };
00646 
00647     struct ColorScale
00648     {
00649         bool reverseOrder;
00650         unsigned short labelGap;
00651         unsigned short colorBarThickness;
00652         Color labelsColor;
00653     };
00654 
00655     struct GraphLayer
00656     {
00657         Rect clientRect;
00658         TextBox legend;
00659         Color backgroundColor;
00660         BorderType borderType;
00661 
00662         GraphAxis xAxis;
00663         GraphAxis yAxis;
00664         GraphAxis zAxis;
00665 
00666         GraphAxisBreak xAxisBreak;
00667         GraphAxisBreak yAxisBreak;
00668         GraphAxisBreak zAxisBreak;
00669 
00670         double histogramBin;
00671         double histogramBegin;
00672         double histogramEnd;
00673 
00674         PercentileProperties percentile;
00675         ColorScale colorScale;
00676 
00677         vector<TextBox> texts;
00678         vector<TextBox> pieTexts;
00679         vector<Line> lines;
00680         vector<Figure> figures;
00681         vector<Bitmap> bitmaps;
00682         vector<GraphCurve> curves;
00683 
00684         float xLength;
00685         float yLength;
00686         float zLength;
00687 
00688         bool imageProfileTool;
00689         double vLine;
00690         double hLine;
00691 
00692         bool isXYY3D;
00693 
00694         GraphLayer()
00695         :   imageProfileTool(false)
00696         ,   isXYY3D(false)
00697         {};
00698 
00699         //bool threeDimensional;
00700         bool is3D() const
00701         {
00702             return curves.end() != find_if(curves.begin(), curves.end(),
00703                                             boost::bind(logical_or<bool>(), boost::bind(&GraphCurve::type, _1) == GraphCurve::Line3D,  
00704                                             boost::bind(&GraphCurve::type, _1) == GraphCurve::Mesh3D));
00705         }
00706     };
00707 
00708     struct GraphLayerRange
00709     {
00710         double min;
00711         double max;
00712         double step;
00713 
00714         GraphLayerRange(double _min = 0.0, double _max = 0.0, double _step = 0.0)
00715         :   min(_min)
00716         ,   max(_max)
00717         ,   step(_step)
00718         {};
00719     };
00720 
00721     struct Graph : public Window
00722     {
00723         vector<GraphLayer> layers;
00724         unsigned short width;
00725         unsigned short height;
00726         bool is3D;
00727         bool isLayout;
00728 
00729         Graph(const string& _name = "")
00730         :   Window(_name)
00731         ,   is3D(false)
00732         ,   isLayout(false)
00733         {};
00734     };
00735 
00736     struct Note : public Window
00737     {
00738         string text;
00739         Note(const string& _name = "")
00740         :   Window(_name)
00741         {};
00742     };
00743 
00744     struct ProjectNode
00745     {
00746         enum NodeType {SpreadSheet, Matrix, Excel, Graph, Graph3D, Note, Folder};
00747 
00748         NodeType type;
00749         string name;
00750         boost::posix_time::ptime creationDate;
00751         boost::posix_time::ptime modificationDate;
00752 
00753         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())
00754         :   name(_name)
00755         ,   type(_type)
00756         ,   creationDate(_creationDate)
00757         ,   modificationDate(_modificationDate)
00758         {};
00759     };
00760 }
00761 
00762 
00763 
00764 #endif // ORIGIN_OBJ_H

Generated on Fri Aug 12 2011 for liborigin2 by  doxygen 1.7.1