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