File indexing completed on 2024-03-24 15:18:47

0001 /***************************************************************************
0002     File                 : OriginObj.h
0003     --------------------------------------------------------------------
0004     Copyright            : (C) 2005-2007, 2017 Stefan Gerlach
0005                            (C) 2007-2008 Alex Kargovsky, Ion Vasilief
0006     Email (use @ for *)  : kargovsky*yumr.phys.msu.su, ion_vasilief*yahoo.fr
0007     Description          : Origin internal object classes
0008 
0009  ***************************************************************************/
0010 
0011 /***************************************************************************
0012  *                                                                         *
0013  *  This program is free software; you can redistribute it and/or modify   *
0014  *  it under the terms of the GNU General Public License as published by   *
0015  *  the Free Software Foundation; either version 2 of the License, or      *
0016  *  (at your option) any later version.                                    *
0017  *                                                                         *
0018  *  This program is distributed in the hope that it will be useful,        *
0019  *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
0020  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
0021  *  GNU General Public License for more details.                           *
0022  *                                                                         *
0023  *   You should have received a copy of the GNU General Public License     *
0024  *   along with this program; if not, write to the Free Software           *
0025  *   Foundation, Inc., 51 Franklin Street, Fifth Floor,                    *
0026  *   Boston, MA  02110-1301  USA                                           *
0027  *                                                                         *
0028  ***************************************************************************/
0029 
0030 
0031 #ifndef ORIGIN_OBJ_H
0032 #define ORIGIN_OBJ_H
0033 
0034 #include <cstring>
0035 #include <ctime>
0036 #include <vector>
0037 #include <string>
0038 
0039 using namespace std;
0040 
0041 #define _ONAN       (-1.23456789E-300)
0042 
0043 namespace Origin
0044 {
0045     enum ValueType {Numeric = 0, Text = 1, Time = 2, Date = 3,  Month = 4, Day = 5, ColumnHeading = 6, TickIndexedDataset = 7, TextNumeric = 9, Categorical = 10};
0046     // Numeric Format:
0047     // 1000 | 1E3 | 1k | 1,000
0048     enum NumericFormat {Decimal = 0, Scientific = 1, Engineering = 2, DecimalWithMarks = 3};
0049     // Time Format:
0050     // hh:mm | hh | hh:mm:ss | hh:mm:ss.zz | hh ap | hh:mm ap | mm:ss
0051     // mm:ss.zz | hhmm | hhmmss | hh:mm:ss.zzz
0052     enum TimeFormat {TIME_HH_MM = 0, TIME_HH = 1, TIME_HH_MM_SS = 2, TIME_HH_MM_SS_ZZ = 3, TIME_HH_AP = 4, TIME_HH_MM_AP = 5, TIME_MM_SS = 6,
0053         TIME_MM_SS_ZZ = 7, TIME_HHMM = 8, TIME_HHMMSS = 9, TIME_HH_MM_SS_ZZZ = 10};
0054     // Date Format:
0055     // dd/MM/yyyy | dd/MM/yyyy HH:mm | dd/MM/yyyy HH:mm:ss | dd.MM.yyyy | y. (year abbreviation) | MMM d
0056     // M/d | d | ddd | First letter of day | yyyy | yy | dd.MM.yyyy hh:mm | dd.MM.yyyy hh:mm:ss
0057     // yyMMdd | yyMMdd hh:mm | yyMMdd hh:mm:ss | yyMMdd hhmm | yyMMdd hhmmss | MMM
0058     // First letter of month | Quartal | M-d-yyyy (Custom1) | hh:mm:ss.zzzz (Custom2)
0059     enum DateFormat {DATE_DD_MM_YYYY = -128, DATE_DD_MM_YYYY_HH_MM = -119, DATE_DD_MM_YYYY_HH_MM_SS = -118, DATE_DDMMYYYY = 0, DATE_Y = 1, DATE_MMM_D = 2,
0060         DATE_M_D = 3, DATE_D = 4, DATE_DDD = 5, DATE_DAY_LETTER = 6, DATE_YYYY = 7, DATE_YY = 8, DATE_DDMMYYYY_HH_MM = 9, DATE_DDMMYYYY_HH_MM_SS = 10,
0061         DATE_YYMMDD = 11, DATE_YYMMDD_HH_MM = 12, DATE_YYMMDD_HH_MM_SS = 13, DATE_YYMMDD_HHMM = 14, DATE_YYMMDD_HHMMSS = 15, DATE_MMM = 16,
0062         DATE_MONTH_LETTER = 17, DATE_Q = 18, DATE_M_D_YYYY = 19, DATE_HH_MM_SS_ZZZZ = 20};
0063     // Month Format:
0064     //  MMM | MMMM | First letter of month
0065     enum MonthFormat {MONTH_MMM = 0, MONTH_MMMM = 1, MONTH_LETTER = 2};
0066     // ddd | dddd | First letter of day
0067     enum DayOfWeekFormat {DAY_DDD = 0, DAY_DDDD = 1, DAY_LETTER = 2};
0068 
0069     enum NumericDisplayType {DefaultDecimalDigits = 0, DecimalPlaces = 1, SignificantDigits = 2};
0070     enum Attach {Frame = 0, Page = 1, Scale = 2, End_};
0071     enum BorderType {BlackLine = 0, Shadow = 1, DarkMarble = 2, WhiteOut = 3, BlackOut = 4, None = -1};
0072     enum FillPattern {NoFill = 0, BDiagDense = 1, BDiagMedium = 2, BDiagSparse = 3, FDiagDense = 4, FDiagMedium = 5, FDiagSparse = 6,
0073         DiagCrossDense = 7, DiagCrossMedium = 8, DiagCrossSparse = 9, HorizontalDense = 10, HorizontalMedium = 11, HorizontalSparse = 12,
0074         VerticalDense = 13, VerticalMedium = 14, VerticalSparse = 15, CrossDense = 16, CrossMedium = 17, CrossSparse = 18};
0075     enum ColorGradientDirection {NoGradient = 0, TopLeft = 1, Left = 2, BottomLeft = 3, Top = 4, Center = 5, Bottom = 6, TopRight = 7, Right = 8, BottomRight = 9};
0076 
0077     struct Color
0078     {
0079         enum ColorType {None = 0, Automatic = 1, Regular = 2, Custom = 3, Increment = 4, Indexing = 5, RGB = 6, Mapping = 7};
0080         enum RegularColor {Black = 0, Red = 1, Green = 2, Blue = 3, Cyan = 4, Magenta = 5, Yellow = 6, DarkYellow = 7, Navy = 8,
0081             Purple = 9, Wine = 10, Olive = 11, DarkCyan = 12, Royal=  13, Orange = 14, Violet = 15, Pink = 16, White = 17,
0082             LightGray = 18, Gray = 19, LTYellow = 20, LTCyan = 21, LTMagenta = 22, DarkGray = 23, SpecialV7Axis = 0xF7/*, Custom = 255*/};
0083 
0084         ColorType type;
0085         union
0086         {
0087             unsigned char regular;
0088             unsigned char custom[3];
0089             unsigned char starting;
0090             unsigned char column;
0091         };
0092     };
0093 
0094     struct Rect
0095     {
0096         short left;
0097         short top;
0098         short right;
0099         short bottom;
0100 
0101         Rect(short width = 0, short height = 0)
0102         :   left(0)
0103         ,   top(0)
0104         ,   right(width)
0105         ,   bottom(height)
0106         {
0107         };
0108 
0109         int height() const
0110         {
0111             return bottom - top;
0112         };
0113 
0114         int width() const
0115         {
0116             return right - left;
0117         };
0118 
0119         bool isValid() const
0120         {
0121             return height() > 0 && width() > 0;
0122         }
0123     };
0124 
0125     struct ColorMapLevel
0126     {
0127         Color fillColor;
0128         unsigned char fillPattern;
0129         Color fillPatternColor;
0130         double fillPatternLineWidth;
0131 
0132         bool lineVisible;
0133         Color lineColor;
0134         unsigned char lineStyle;
0135         double lineWidth;
0136 
0137         bool labelVisible;
0138     };
0139 
0140     typedef vector<pair<double, ColorMapLevel> > ColorMapVector;
0141 
0142     struct ColorMap
0143     {
0144         bool fillEnabled;
0145         ColorMapVector levels;
0146     };
0147 
0148     struct Window
0149     {
0150         enum State {Normal, Minimized, Maximized};
0151         enum Title {Name, Label, Both};
0152 
0153         string name;
0154         string label;
0155         int objectID;
0156         bool hidden;
0157         State state;
0158         Title title;
0159         Rect frameRect;
0160         time_t creationDate;
0161         time_t modificationDate;
0162         ColorGradientDirection windowBackgroundColorGradient;
0163         Color windowBackgroundColorBase;
0164         Color windowBackgroundColorEnd;
0165 
0166         Window(const string& _name = string(), const string& _label = string(), bool _hidden = false)
0167         :   name(_name)
0168         ,   label(_label)
0169         ,   objectID(-1)
0170         ,   hidden(_hidden)
0171         ,   state(Normal)
0172         ,   title(Both)
0173         ,   creationDate(0)
0174         ,   modificationDate(0)
0175         ,   windowBackgroundColorGradient(NoGradient)
0176         ,   windowBackgroundColorBase({Color::Regular, {Color::White}})
0177         ,   windowBackgroundColorEnd({Color::Regular, {Color::White}})
0178         {};
0179     };
0180 
0181     // Variant type with boost-free functions
0182     // see https://github.com/highperformancecoder/scidavis/commit/7c6e07dfad80dbe190af29ffa8a56c82a8aa9180
0183     // see https://www.ojdip.net/2013/10/implementing-a-variant-type-in-cpp/
0184     // https://stackoverflow.com/questions/35648390/tagged-union-c
0185     // https://books.google.de/books?id=PSUNAAAAQBAJ&pg=PA217&lpg=PA217&dq=c%2B%2B+tagged+union+string&source=bl&ots=DqArIieZ8H&sig=k2a6okxxgUuEkLw48hFJChkIG9o&hl=en&sa=X&ved=0ahUKEwjylreR08DUAhWBVRoKHWPSBqE4ChDoAQhUMAg#v=onepage&q=c%2B%2B%20tagged%20union%20string&f=false
0186     typedef class Variant {
0187     public:
0188         enum vtype {V_DOUBLE, V_STRING};
0189         vtype type() const {return m_type;}
0190         double as_double() const {return m_double;}
0191         const char* as_string() const {return m_string;}
0192 
0193         Variant() {}
0194         Variant(const double d): m_double(d) {}
0195         Variant(const string& s): m_type(V_STRING)
0196         {
0197             asgString(s.c_str());
0198         }
0199 
0200         Variant(const Variant& v): m_type(v.m_type) {
0201             switch (v.m_type) {
0202             case V_DOUBLE:
0203                 m_double = v.m_double;
0204                 break;
0205             case V_STRING:
0206                 asgString(v.m_string);
0207                 break;
0208             }
0209         }
0210 
0211         Origin::Variant& operator=(const Origin::Variant& v) {
0212             if (m_type == V_STRING)
0213                 delete [] m_string;
0214 
0215             switch (v.m_type) {
0216             case V_DOUBLE:
0217                 m_double = v.m_double;
0218                 break;
0219             case V_STRING:
0220                 asgString(v.m_string);
0221                 break;
0222             }
0223             m_type = v.m_type;
0224             return *this;
0225         }
0226 
0227         ~Variant() {
0228             //printf("~Variant()\n");
0229             if (m_type == V_STRING)
0230                 delete [] m_string;
0231         }
0232     private:
0233         vtype m_type=V_DOUBLE;
0234         union {
0235             double m_double=0.;
0236             char* m_string;
0237         };
0238         void asgString(const char* x)
0239         {
0240             m_string=new char[strlen(x)+1];
0241             strcpy(m_string,x);
0242         }
0243     } variant;
0244 
0245     struct SpreadColumn
0246     {
0247         enum ColumnType {X, Y, Z, XErr, YErr, Label, NONE};
0248 
0249         string name;
0250         string dataset_name;
0251         ColumnType type;
0252         ValueType valueType;
0253         int valueTypeSpecification;
0254         int significantDigits;
0255         int decimalPlaces;
0256         NumericDisplayType numericDisplayType;
0257         string command;
0258         string comment;
0259         int width;
0260         unsigned int index;
0261         unsigned int colIndex;
0262         unsigned int sheet;
0263         unsigned int numRows;
0264         unsigned int beginRow;
0265         unsigned int endRow;
0266         vector<variant> data;
0267 
0268         SpreadColumn(const string& _name = string(), unsigned int _index = 0)
0269         :   name(_name)
0270         ,   type(ColumnType::Y)
0271         ,   valueType(Numeric)
0272         ,   valueTypeSpecification(0)
0273         ,   significantDigits(6)
0274         ,   decimalPlaces(6)
0275         ,   numericDisplayType(DefaultDecimalDigits)
0276         ,   width(8)
0277         ,   index(_index)
0278         ,   colIndex(0)
0279         ,   sheet(0)
0280         ,   numRows(0)
0281         ,   beginRow(0)
0282         ,   endRow(0)
0283         {};
0284     };
0285 
0286     struct SpreadSheet : public Window
0287     {
0288         unsigned int maxRows;
0289         bool loose;
0290         unsigned int sheets;
0291         vector<SpreadColumn> columns;
0292 
0293         SpreadSheet(const string& _name = string())
0294         :   Window(_name)
0295         ,   maxRows(30)
0296         ,   loose(true)
0297         ,   sheets(1)
0298         {};
0299     };
0300 
0301     struct Excel : public Window
0302     {
0303         unsigned int maxRows;
0304         bool loose;
0305         vector<SpreadSheet> sheets;
0306 
0307         Excel(const string& _name = string(), const string& _label = string(), int _maxRows = 0, bool _hidden = false, bool _loose = true)
0308         :   Window(_name, _label, _hidden)
0309         ,   maxRows(_maxRows)
0310         ,   loose(_loose)
0311         {
0312         };
0313     };
0314 
0315     struct MatrixSheet
0316     {
0317         enum ViewType {DataView, ImageView};
0318 
0319         string name;
0320         unsigned short rowCount;
0321         unsigned short columnCount;
0322         int valueTypeSpecification;
0323         int significantDigits;
0324         int decimalPlaces;
0325         NumericDisplayType numericDisplayType;
0326         string command;
0327         unsigned short width;
0328         unsigned int index;
0329         ViewType view;
0330         ColorMap colorMap;
0331         vector<double> data;
0332         vector<double> coordinates;
0333 
0334         MatrixSheet(const string& _name = string(), unsigned int _index = 0)
0335         :   name(_name)
0336         ,   rowCount(8)
0337         ,   columnCount(8)
0338         ,   valueTypeSpecification(0)
0339         ,   significantDigits(6)
0340         ,   decimalPlaces(6)
0341         ,   numericDisplayType(DefaultDecimalDigits)
0342         ,   width(8)
0343         ,   index(_index)
0344         ,   view(DataView)
0345         ,   colorMap()
0346         {coordinates.push_back(10.0);coordinates.push_back(10.0);coordinates.push_back(1.0);coordinates.push_back(1.0);};
0347     };
0348 
0349     struct Matrix : public Window
0350     {
0351         enum HeaderViewType {ColumnRow, XY};
0352 
0353         unsigned int activeSheet;
0354         HeaderViewType header;
0355         vector<MatrixSheet> sheets;
0356 
0357         Matrix(const string& _name = string())
0358         :   Window(_name)
0359         ,   activeSheet(0)
0360         ,   header(ColumnRow)
0361         {};
0362     };
0363 
0364     struct Function
0365     {
0366         enum FunctionType {Normal, Polar};
0367 
0368         string name;
0369         FunctionType type;
0370         string formula;
0371         double begin;
0372         double end;
0373         int totalPoints;
0374         unsigned int index;
0375 
0376         Function(const string& _name = string(), unsigned int _index = 0)
0377         :   name(_name)
0378         ,   type(Normal)
0379         ,   begin(0.0)
0380         ,   end(0.0)
0381         ,   totalPoints(0)
0382         ,   index(_index)
0383         {};
0384     };
0385 
0386 
0387     struct TextBox
0388     {
0389         string text;
0390         Rect clientRect;
0391         Color color;
0392         unsigned short fontSize;
0393         int rotation;
0394         int tab;
0395         BorderType borderType;
0396         Attach attach;
0397 
0398         TextBox(const string& _text = string())
0399         :   text(_text)
0400         ,   color({Color::Regular, {Color::Black}})
0401         ,   fontSize(20)
0402         ,   rotation(0)
0403         ,   tab(8)
0404         ,   borderType(BlackLine)
0405         ,   attach(Frame)
0406         {};
0407 
0408         TextBox(const string& _text, Rect _clientRect, Color _color, unsigned short _fontSize, int _rotation, int _tab, BorderType _borderType, Attach _attach)
0409         :   text(_text)
0410         ,   clientRect(_clientRect)
0411         ,   color(_color)
0412         ,   fontSize(_fontSize)
0413         ,   rotation(_rotation)
0414         ,   tab(_tab)
0415         ,   borderType(_borderType)
0416         ,   attach(_attach)
0417         {};
0418     };
0419 
0420     struct PieProperties
0421     {
0422         unsigned char viewAngle;
0423         unsigned char thickness;
0424         bool clockwiseRotation;
0425         short rotation;
0426         unsigned short radius;
0427         unsigned short horizontalOffset;
0428         unsigned long displacedSectionCount; // maximum - 32 sections
0429         unsigned short displacement;
0430 
0431         //labels
0432         bool formatAutomatic;
0433         bool formatValues;
0434         bool formatPercentages;
0435         bool formatCategories;
0436         bool positionAssociate;
0437         unsigned short distance;
0438 
0439         PieProperties()
0440         :   viewAngle(33)
0441         ,   thickness(33)
0442         ,   clockwiseRotation(false)
0443         ,   rotation(33)
0444         ,   radius(70)
0445         ,   horizontalOffset(0)
0446         ,   displacedSectionCount(0)
0447         ,   displacement(25)
0448         ,   formatAutomatic(false)
0449         ,   formatValues(false)
0450         ,   formatPercentages(false)
0451         ,   formatCategories(false)
0452         ,   positionAssociate(false)
0453         ,   distance(25)
0454         {};
0455     };
0456 
0457     struct VectorProperties
0458     {
0459         enum VectorPosition {Tail, Midpoint, Head};
0460 
0461         Color color;
0462         double width;
0463         unsigned short arrowLength;
0464         unsigned char arrowAngle;
0465         bool arrowClosed;
0466         string endXColumnName;
0467         string endYColumnName;
0468 
0469         VectorPosition position;
0470         string angleColumnName;
0471         string magnitudeColumnName;
0472         float multiplier;
0473         int constAngle;
0474         int constMagnitude;
0475 
0476         VectorProperties()
0477         :   color({Color::Regular, {Color::Black}})
0478         ,   width(2.0)
0479         ,   arrowLength(45)
0480         ,   arrowAngle(30)
0481         ,   arrowClosed(false)
0482         ,   position(Tail)
0483         ,   multiplier(1.0)
0484         ,   constAngle(0)
0485         ,   constMagnitude(0)
0486         {};
0487     };
0488 
0489     struct TextProperties
0490     {
0491         enum Justify {Left, Center, Right};
0492 
0493         Color color;
0494         bool fontBold;
0495         bool fontItalic;
0496         bool fontUnderline;
0497         bool whiteOut;
0498         Justify justify;
0499 
0500         short rotation;
0501         short xOffset;
0502         short yOffset;
0503         unsigned short fontSize;
0504     };
0505 
0506     struct SurfaceProperties
0507     {
0508         struct SurfaceColoration
0509         {
0510             bool fill;
0511             bool contour;
0512             Color lineColor;
0513             double lineWidth;
0514         };
0515 
0516         enum Type {ColorMap3D, ColorFill, WireFrame, Bars};
0517         enum Grids {None, X, Y, XY};
0518 
0519         unsigned char type;
0520         Grids grids;
0521         double gridLineWidth;
0522         Color gridColor;
0523 
0524         bool backColorEnabled;
0525         Color frontColor;
0526         Color backColor;
0527 
0528         bool sideWallEnabled;
0529         Color xSideWallColor;
0530         Color ySideWallColor;
0531 
0532         SurfaceColoration surface;
0533         SurfaceColoration topContour;
0534         SurfaceColoration bottomContour;
0535 
0536         ColorMap colorMap;
0537     };
0538 
0539     struct PercentileProperties
0540     {
0541         unsigned char maxSymbolType;
0542         unsigned char p99SymbolType;
0543         unsigned char meanSymbolType;
0544         unsigned char p1SymbolType;
0545         unsigned char minSymbolType;
0546         Color symbolColor;
0547         Color symbolFillColor;
0548         unsigned short symbolSize;
0549         unsigned char boxRange;
0550         unsigned char whiskersRange;
0551         double boxCoeff;
0552         double whiskersCoeff;
0553         bool diamondBox;
0554         unsigned char labels;
0555         PercentileProperties()
0556         :   maxSymbolType(1)
0557         ,   p99SymbolType(2)
0558         ,   meanSymbolType(3)
0559         ,   p1SymbolType(4)
0560         ,   minSymbolType(5)
0561         ,   symbolColor({Color::Regular, {Color::Black}})
0562         ,   symbolFillColor({Color::Regular, {Color::White}})
0563         ,   symbolSize(5)
0564         ,   boxRange(25)
0565         ,   whiskersRange(5)
0566         ,   boxCoeff(1.0)
0567         ,   whiskersCoeff(1.5)
0568         ,   diamondBox(true)
0569         ,   labels(0)
0570         {};
0571     };
0572 
0573     struct GraphCurve
0574     {
0575         enum Plot {Scatter3D = 101, Surface3D = 103, Vector3D = 183, ScatterAndErrorBar3D = 184, TernaryContour = 185,
0576             PolarXrYTheta = 186, SmithChart = 191, Polar = 192, BubbleIndexed = 193, BubbleColorMapped = 194,
0577             Line = 200, Scatter=201, LineSymbol=202, Column = 203, Area = 204, HiLoClose = 205, Box = 206,
0578             ColumnFloat = 207, Vector = 208, PlotDot = 209, Wall3D = 210, Ribbon3D = 211, Bar3D = 212, ColumnStack = 213,
0579             AreaStack = 214, Bar = 215, BarStack = 216, FlowVector = 218, Histogram = 219, MatrixImage = 220, Pie = 225,
0580             Contour = 226, Unknown = 230, ErrorBar = 231, TextPlot = 232, XErrorBar = 233, SurfaceColorMap = 236,
0581             SurfaceColorFill = 237, SurfaceWireframe = 238, SurfaceBars = 239, Line3D = 240, Text3D = 241, Mesh3D = 242,
0582             XYZContour = 243, XYZTriangular = 245, LineSeries = 246, YErrorBar = 254, XYErrorBar = 255};
0583         enum LineStyle {Solid = 0, Dash = 1, Dot = 2, DashDot = 3, DashDotDot = 4, ShortDash = 5, ShortDot = 6, ShortDashDot = 7};
0584         enum LineConnect {NoLine = 0, Straight = 1, TwoPointSegment = 2, ThreePointSegment = 3, BSpline = 8, Spline = 9,
0585             StepHorizontal = 11, StepVertical = 12, StepHCenter = 13, StepVCenter = 14, Bezier = 15};
0586 
0587         bool hidden;
0588         unsigned char type;
0589         string dataName;
0590         string xDataName;
0591         string xColumnName;
0592         string yColumnName;
0593         string zColumnName;
0594         Color lineColor;
0595         unsigned char lineTransparency;
0596         unsigned char lineStyle;
0597         unsigned char lineConnect;
0598         unsigned char boxWidth;
0599         double lineWidth;
0600 
0601         bool fillArea;
0602         unsigned char fillAreaType;
0603         unsigned char fillAreaPattern;
0604         Color fillAreaColor;
0605         unsigned char fillAreaTransparency;
0606         bool fillAreaWithLineTransparency;
0607         Color fillAreaPatternColor;
0608         double fillAreaPatternWidth;
0609         unsigned char fillAreaPatternBorderStyle;
0610         Color fillAreaPatternBorderColor;
0611         double fillAreaPatternBorderWidth;
0612 
0613         unsigned char symbolInterior;
0614         unsigned char symbolShape;
0615         Color symbolColor;
0616         Color symbolFillColor;
0617         unsigned char symbolFillTransparency;
0618         double symbolSize;
0619         unsigned char symbolThickness;
0620         unsigned char pointOffset;
0621 
0622         bool connectSymbols;
0623 
0624         //pie
0625         PieProperties pie;
0626 
0627         //vector
0628         VectorProperties vector;
0629 
0630         //text
0631         TextProperties text;
0632 
0633         //surface
0634         SurfaceProperties surface;
0635 
0636         //contour
0637         ColorMap colorMap;
0638     };
0639 
0640     struct GraphAxisBreak
0641     {
0642         bool show;
0643 
0644         bool log10;
0645         double from;
0646         double to;
0647         double position;
0648 
0649         double scaleIncrementBefore;
0650         double scaleIncrementAfter;
0651 
0652         unsigned char minorTicksBefore;
0653         unsigned char minorTicksAfter;
0654 
0655         GraphAxisBreak()
0656         :   show(false)
0657         ,   log10(false)
0658         ,   from(4.)
0659         ,   to(6.)
0660         ,   position(50.)
0661         ,   scaleIncrementBefore(5)
0662         ,   scaleIncrementAfter(5)
0663         ,   minorTicksBefore(1)
0664         ,   minorTicksAfter(1)
0665         {};
0666     };
0667 
0668     struct GraphGrid
0669     {
0670         bool hidden;
0671         unsigned char color;
0672         unsigned char style;
0673         double width;
0674     };
0675 
0676     struct GraphAxisFormat
0677     {
0678         bool hidden;
0679         unsigned char color;
0680         double thickness;
0681         double majorTickLength;
0682         int majorTicksType;
0683         int minorTicksType;
0684         int axisPosition;
0685         double axisPositionValue;
0686         TextBox label;
0687         string prefix;
0688         string suffix;
0689         string factor;
0690     };
0691 
0692     struct GraphAxisTick
0693     {
0694         bool showMajorLabels;
0695         unsigned char color;
0696         ValueType valueType;
0697         int valueTypeSpecification;
0698         int decimalPlaces;
0699         unsigned short fontSize;
0700         bool fontBold;
0701         string dataName;
0702         string columnName;
0703         int rotation;
0704     };
0705 
0706     struct GraphAxis
0707     {
0708         enum AxisPosition {Left = 0, Bottom, Right, Top, Front, Back};
0709         enum Scale {Linear = 0, Log10 = 1, Probability = 2, Probit = 3, Reciprocal = 4, OffsetReciprocal = 5, Logit = 6, Ln = 7, Log2 = 8};
0710 
0711         AxisPosition position;
0712         bool zeroLine;
0713         bool oppositeLine;
0714         double min;
0715         double max;
0716         double step;
0717         unsigned char majorTicks;
0718         unsigned char minorTicks;
0719         unsigned char scale;
0720         GraphGrid majorGrid;
0721         GraphGrid minorGrid;
0722         GraphAxisFormat formatAxis[2];
0723         GraphAxisTick tickAxis[2]; //bottom-top, left-right
0724     };
0725 
0726     struct Figure
0727     {
0728         enum FigureType {Rectangle, Circle};
0729 
0730         FigureType type;
0731         Rect clientRect;
0732         Attach attach;
0733         Color color;
0734         unsigned char style;
0735         double width;
0736         Color fillAreaColor;
0737         unsigned char fillAreaPattern;
0738         Color fillAreaPatternColor;
0739         double fillAreaPatternWidth;
0740         bool useBorderColor;
0741 
0742         Figure(FigureType _type = Rectangle)
0743         :   type(_type)
0744         ,   attach(Frame)
0745         ,   color({Color::Regular, {Color::Black}})
0746         ,   style(0)
0747         ,   width(1.0)
0748         ,   fillAreaColor({Color::Regular, {Color::LightGray}})
0749         ,   fillAreaPattern(FillPattern::NoFill)
0750         ,   fillAreaPatternColor({Color::Regular, {Color::Black}})
0751         ,   fillAreaPatternWidth(1)
0752         ,   useBorderColor(false)
0753         {
0754         };
0755     };
0756 
0757     struct LineVertex
0758     {
0759         unsigned char shapeType;
0760         double shapeWidth;
0761         double shapeLength;
0762         double x;
0763         double y;
0764 
0765         LineVertex()
0766         :   shapeType(0)
0767         ,   shapeWidth(0.0)
0768         ,   shapeLength(0.0)
0769         ,   x(0.0)
0770         ,   y(0.0)
0771         {};
0772     };
0773 
0774     struct Line
0775     {
0776         Rect clientRect;
0777         Color color;
0778         Attach attach;
0779         double width;
0780         unsigned char style;
0781         LineVertex begin;
0782         LineVertex end;
0783     };
0784 
0785     struct Bitmap
0786     {
0787         Rect clientRect;
0788         Attach attach;
0789         unsigned long size;
0790         string windowName;
0791         BorderType borderType;
0792         unsigned char* data;
0793 
0794         Bitmap(const string& _name = string())
0795         :   attach(Frame)
0796         ,   size(0)
0797         ,   windowName(_name)
0798         ,   borderType(BlackLine)
0799         ,   data(nullptr)
0800         {
0801         };
0802 
0803         Bitmap(const Bitmap& bitmap)
0804         :   clientRect(bitmap.clientRect)
0805         ,   attach(bitmap.attach)
0806         ,   size(bitmap.size)
0807         ,   windowName(bitmap.windowName)
0808         ,   borderType(bitmap.borderType)
0809         ,   data(nullptr)
0810         {
0811             if(size > 0)
0812             {
0813                 data = new unsigned char[size];
0814                 memcpy(data, bitmap.data, size);
0815             }
0816         };
0817 
0818         ~Bitmap()
0819         {
0820             if(size > 0)
0821                 delete data;
0822         };
0823     };
0824 
0825     struct ColorScale
0826     {
0827         bool visible;
0828         bool reverseOrder;
0829         unsigned short labelGap;
0830         unsigned short colorBarThickness;
0831         Color labelsColor;
0832         ColorScale()
0833         :   visible(true)
0834         ,   reverseOrder(false)
0835         ,   labelGap(5)
0836         ,   colorBarThickness(3)
0837         ,   labelsColor({Color::Regular, {Color::Black}})
0838         {};
0839     };
0840 
0841     struct GraphLayer
0842     {
0843         Rect clientRect;
0844         TextBox legend;
0845         Color backgroundColor;
0846         BorderType borderType;
0847 
0848         GraphAxis xAxis;
0849         GraphAxis yAxis;
0850         GraphAxis zAxis;
0851 
0852         GraphAxisBreak xAxisBreak;
0853         GraphAxisBreak yAxisBreak;
0854         GraphAxisBreak zAxisBreak;
0855 
0856         double histogramBin;
0857         double histogramBegin;
0858         double histogramEnd;
0859 
0860         PercentileProperties percentile;
0861         ColorScale colorScale;
0862         ColorMap colorMap;
0863 
0864         vector<TextBox> texts;
0865         vector<TextBox> pieTexts;
0866         vector<Line> lines;
0867         vector<Figure> figures;
0868         vector<Bitmap> bitmaps;
0869         vector<GraphCurve> curves;
0870 
0871         float xAngle;
0872         float yAngle;
0873         float zAngle;
0874 
0875         float xLength;
0876         float yLength;
0877         float zLength;
0878 
0879         int imageProfileTool;
0880         double vLine;
0881         double hLine;
0882 
0883         bool isWaterfall;
0884         int xOffset;
0885         int yOffset;
0886 
0887         bool gridOnTop;
0888         bool exchangedAxes;
0889         bool isXYY3D;
0890         bool orthographic3D;
0891 
0892         GraphLayer()
0893         :   backgroundColor({Color::Regular, {Color::White}})
0894         ,   borderType(BlackLine)
0895         ,   xAxis(), yAxis(), zAxis()
0896         ,   histogramBin(0.5)
0897         ,   histogramBegin(0.0)
0898         ,   histogramEnd(10.0)
0899         ,   colorMap()
0900         ,   xAngle(0)
0901         ,   yAngle(0)
0902         ,   zAngle(0)
0903         ,   xLength(10)
0904         ,   yLength(10)
0905         ,   zLength(10)
0906         ,   imageProfileTool(0)
0907         ,   vLine(0.0)
0908         ,   hLine(0.0)
0909         ,   isWaterfall(false)
0910         ,   xOffset(10)
0911         ,   yOffset(10)
0912         ,   gridOnTop(false)
0913         ,   exchangedAxes(false)
0914         ,   isXYY3D(false)
0915         ,   orthographic3D(false)
0916         {colorScale.visible = false;};
0917 
0918         //bool threeDimensional;
0919         bool is3D() const
0920         {
0921             for (vector<GraphCurve>::const_iterator it = curves.begin(); it != curves.end(); ++it)
0922             {
0923                 switch (it->type)
0924                 {
0925                     case GraphCurve::Scatter3D:
0926                     case GraphCurve::Surface3D:
0927                     case GraphCurve::Vector3D:
0928                     case GraphCurve::ScatterAndErrorBar3D:
0929                     case GraphCurve::TernaryContour:
0930                     case GraphCurve::Line3D:
0931                     case GraphCurve::Mesh3D:
0932                     case GraphCurve::XYZContour:
0933                     case GraphCurve::XYZTriangular:
0934                         return true;
0935                     default:
0936                         break;
0937                 }
0938             }
0939         return false;
0940         }
0941     };
0942 
0943     struct GraphLayerRange
0944     {
0945         double min;
0946         double max;
0947         double step;
0948 
0949         GraphLayerRange(double _min = 0.0, double _max = 0.0, double _step = 0.0)
0950         :   min(_min)
0951         ,   max(_max)
0952         ,   step(_step)
0953         {};
0954     };
0955 
0956     struct Graph : public Window
0957     {
0958         vector<GraphLayer> layers;
0959         unsigned short width;
0960         unsigned short height;
0961         bool is3D;
0962         bool isLayout;
0963         bool connectMissingData;
0964         string templateName;
0965 
0966         Graph(const string& _name = string())
0967         :   Window(_name)
0968         ,   width(400)
0969         ,   height(300)
0970         ,   is3D(false)
0971         ,   isLayout(false)
0972         ,   connectMissingData(false)
0973         {};
0974     };
0975 
0976     struct Note : public Window
0977     {
0978         string text;
0979         Note(const string& _name = string())
0980         :   Window(_name)
0981         {};
0982     };
0983 
0984     struct ProjectNode
0985     {
0986         enum NodeType {SpreadSheet, Matrix, Excel, Graph, Graph3D, Note, Folder};
0987 
0988         NodeType type;
0989         string name;
0990         time_t creationDate;
0991         time_t modificationDate;
0992         bool active;
0993 
0994         ProjectNode(const string& _name = string(), NodeType _type = Folder, const time_t _creationDate = time(nullptr), const time_t _modificationDate = time(nullptr), bool _active = false)
0995         :   type(_type)
0996         ,   name(_name)
0997         ,   creationDate(_creationDate)
0998         ,   modificationDate(_modificationDate)
0999         ,   active(_active)
1000         {};
1001     };
1002 }
1003 
1004 
1005 
1006 #endif // ORIGIN_OBJ_H