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