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