QPOptions.h
Go to the documentation of this file.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 #ifndef QPOPTIONS_QO_H_
00028 #define QPOPTIONS_QO_H_
00029
00030 #ifdef AIPS_HAS_QWT
00031
00032 #include <graphics/GenericPlotter/PlotOperation.h>
00033 #include <graphics/GenericPlotter/PlotOptions.h>
00034
00035 #include <QColor>
00036 #include <QFont>
00037 #include <QMutex>
00038
00039 #include <qwt_color_map.h>
00040 #include <qwt_plot.h>
00041 #include <qwt_symbol.h>
00042
00043 namespace casa {
00044
00045
00046 class QPColor : public PlotColor {
00047 public:
00048
00049 QPColor();
00050
00051
00052 QPColor(const String& name);
00053
00054
00055 QPColor(const QColor& color);
00056
00057
00058
00059 QPColor(const PlotColor& color);
00060 QPColor(const PlotColorPtr color);
00061
00062
00063
00064 QPColor(const QPColor& color);
00065
00066
00067 ~QPColor();
00068
00069
00070
00071 using PlotColor::operator=;
00072
00073
00074
00075
00076
00077 String asHexadecimal() const;
00078
00079
00080 String asName() const;
00081
00082
00083 void setAsHexadecimalOrName(const String& str);
00084
00085
00086 double alpha() const;
00087
00088
00089 void setAlpha(double a);
00090
00091
00092
00093
00094
00095
00096 const QColor& asQColor() const;
00097 void setAsQColor(const QColor& color);
00098
00099
00100 private:
00101 QColor m_color;
00102 };
00103
00104
00105
00106 class QPFont : public PlotFont {
00107 public:
00108
00109 QPFont();
00110
00111
00112 QPFont(const QFont& font, const QColor& color);
00113
00114
00115
00116 QPFont(const PlotFont& font);
00117 QPFont(const PlotFontPtr font);
00118
00119
00120
00121 QPFont(const QPFont& font);
00122
00123
00124 ~QPFont();
00125
00126
00127
00128 using PlotFont::operator=;
00129 using PlotFont::setColor;
00130
00131
00132
00133
00134
00135 double pointSize() const;
00136
00137
00138 void setPointSize(double size);
00139
00140
00141 int pixelSize() const;
00142
00143
00144 void setPixelSize(int size);
00145
00146
00147 String fontFamily() const;
00148
00149
00150 void setFontFamily(const String& font);
00151
00152
00153 PlotColorPtr color() const;
00154
00155
00156 void setColor(const PlotColor& color);
00157
00158
00159 bool italics() const;
00160
00161
00162 void setItalics(bool i = true);
00163
00164
00165 bool bold() const;
00166
00167
00168 void setBold(bool b = true);
00169
00170
00171 bool underline() const;
00172
00173
00174 void setUnderline(bool u = true);
00175
00176
00177
00178
00179
00180
00181 const QFont& asQFont() const;
00182 void setAsQFont(const QFont& font);
00183
00184
00185
00186
00187 const QColor& asQColor() const;
00188 void setAsQColor(const QColor& color);
00189
00190
00191 private:
00192 QFont m_font;
00193 QPColor m_color;
00194 };
00195
00196
00197
00198 class QPLine : public PlotLine {
00199 public:
00200
00201 QPLine();
00202
00203
00204 QPLine(const QPen& pen);
00205
00206
00207
00208 QPLine(const PlotLine& copy);
00209 QPLine(const PlotLinePtr copy);
00210
00211
00212
00213 ~QPLine();
00214
00215
00216
00217 using PlotLine::operator=;
00218 using PlotLine::setColor;
00219
00220
00221
00222
00223
00224 double width() const;
00225
00226
00227 void setWidth(double width);
00228
00229
00230 Style style() const;
00231
00232
00233 void setStyle(Style style);
00234
00235
00236 PlotColorPtr color() const;
00237
00238
00239 void setColor(const PlotColor& color);
00240
00241
00242
00243
00244
00245
00246 const QPen& asQPen() const;
00247 void setAsQPen(const QPen& pen);
00248
00249
00250 private:
00251 QPen m_pen;
00252 QPColor m_color;
00253 };
00254
00255
00256
00257 class QPAreaFill : public PlotAreaFill {
00258 public:
00259
00260 QPAreaFill();
00261
00262
00263 QPAreaFill(const QBrush& brush);
00264
00265
00266
00267 QPAreaFill(const PlotAreaFill& copy);
00268 QPAreaFill(const PlotAreaFillPtr copy);
00269
00270
00271
00272 ~QPAreaFill();
00273
00274
00275
00276 using PlotAreaFill::operator=;
00277 using PlotAreaFill::setColor;
00278
00279
00280
00281
00282
00283 PlotColorPtr color() const;
00284
00285
00286 void setColor(const PlotColor& color);
00287
00288
00289 Pattern pattern() const;
00290
00291
00292 void setPattern(Pattern pattern);
00293
00294
00295
00296
00297
00298
00299 const QBrush& asQBrush() const;
00300 void setAsQBrush(const QBrush& brush);
00301
00302
00303 private:
00304 QBrush m_brush;
00305 QPColor m_color;
00306 };
00307
00308
00309
00310 class QPSymbol : public PlotSymbol, public QwtSymbol {
00311 public:
00312
00313 QPSymbol();
00314
00315 #if QWT_VERSION >= 0x060000
00316
00317 QPSymbol(QwtSymbol::Style style, const QBrush & brush,
00318 const QPen & pen, const QSize & sz);
00319 #else
00320
00321 QPSymbol(const QwtSymbol& s);
00322 #endif
00323
00324
00325
00326 QPSymbol(const PlotSymbol& copy);
00327 QPSymbol(const PlotSymbolPtr copy);
00328
00329
00330
00331 ~QPSymbol();
00332
00333
00334
00335 using PlotSymbol::operator=;
00336 using PlotSymbol::setSize;
00337 using PlotSymbol::setAreaFill;
00338 using PlotSymbol::setLine;
00339
00340
00341
00342
00343
00344 psize_t size() const;
00345
00346
00347
00348 void setSize(double width, double height, bool heightIsPixel = true);
00349
00350
00351 bool heightIsPixel() const;
00352
00353
00354 void setHeightIsPixel(bool pixel = true);
00355
00356
00357 Symbol symbol() const;
00358
00359
00360 char symbolChar() const;
00361
00362
00363 unsigned short symbolUChar() const;
00364
00365
00366
00367 void setSymbol(Symbol symbol);
00368 void setSymbol(char c);
00369
00370
00371
00372 void setUSymbol(unsigned short unicode);
00373
00374
00375 PlotLinePtr line() const;
00376
00377
00378 void setLine(const PlotLine& line);
00379
00380
00381 PlotAreaFillPtr areaFill() const;
00382
00383
00384 void setAreaFill(const PlotAreaFill& fill);
00385
00386
00387
00388
00389
00390
00391 void draw(QPainter* p, const QRect& r) const;
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405 const QPen& drawPen() const;
00406 const QBrush& drawBrush() const;
00407
00408
00409 private:
00410 Symbol m_style;
00411 QChar m_char;
00412
00413 bool m_heightIsPixel;
00414
00415 QPen m_pixelPen;
00416 QBrush m_pixelBrush;
00417
00418
00419 const QPen* m_drawPen;
00420
00421
00422 const QBrush* m_drawBrush;
00423 };
00424
00425
00426
00427
00428 class QPMutex : public PlotMutex {
00429 public:
00430
00431 QPMutex();
00432
00433
00434 ~QPMutex();
00435
00436
00437
00438 void lock();
00439
00440
00441 void unlock();
00442
00443
00444 bool tryLock();
00445
00446 private:
00447
00448 QMutex m_mutex;
00449 };
00450
00451
00452
00453
00454 class QPOptions {
00455 public:
00456
00457
00458 static QwtPlot::Axis axis(PlotAxis a);
00459 static PlotAxis axis(QwtPlot::Axis a);
00460 static bool isAxisX( PlotAxis a );
00461
00462
00463
00464
00465
00466 static Qt::CursorShape cursor(PlotCursor c) {
00467 switch(c) {
00468 case NORMAL_CURSOR: return Qt::ArrowCursor;
00469 case HAND_OPEN: return Qt::OpenHandCursor;
00470 case HAND_CLOSED: return Qt::ClosedHandCursor;
00471 case CROSSHAIR: return Qt::CrossCursor;
00472 case WAIT: return Qt::WaitCursor;
00473 case TEXT: return Qt::IBeamCursor;
00474
00475 default: return Qt::ArrowCursor;
00476 }
00477 }
00478 static PlotCursor cursor(Qt::CursorShape c) {
00479 switch(c) {
00480 case Qt::ArrowCursor: return NORMAL_CURSOR;
00481 case Qt::OpenHandCursor: return HAND_OPEN;
00482 case Qt::ClosedHandCursor: return HAND_CLOSED;
00483 case Qt::CrossCursor: return CROSSHAIR;
00484 case Qt::WaitCursor: case Qt::BusyCursor: return WAIT;
00485 case Qt::IBeamCursor: return TEXT;
00486
00487 default: return NORMAL_CURSOR;
00488 }
00489 }
00490
00491
00492
00493
00494 static Qt::PenStyle linestyle(PlotLine::Style s) {
00495 switch(s) {
00496
00497 case PlotLine::SOLID: return Qt::SolidLine;
00498 case PlotLine::DASHED: return Qt::DashLine;
00499 case PlotLine::DOTTED: return Qt::DotLine;
00500
00501
00502 default: return Qt::NoPen;
00503 }
00504 }
00505 static PlotLine::Style linestyle(Qt::PenStyle s) {
00506 switch(s) {
00507
00508 case Qt::SolidLine: return PlotLine::SOLID;
00509 case Qt::DashLine: return PlotLine::DASHED;
00510 case Qt::DotLine: return PlotLine::DOTTED;
00511
00512
00513 default: return PlotLine::NOLINE;
00514 }
00515 }
00516
00517
00518
00519
00520 static Qt::BrushStyle areapattern(PlotAreaFill::Pattern p) {
00521 switch(p) {
00522
00523 case PlotAreaFill::FILL: return Qt::SolidPattern;
00524 case PlotAreaFill::MESH1: return Qt::Dense2Pattern;
00525 case PlotAreaFill::MESH2: return Qt::Dense4Pattern;
00526 case PlotAreaFill::MESH3: return Qt::Dense6Pattern;
00527
00528
00529 default: return Qt::NoBrush;
00530 }
00531 }
00532 static PlotAreaFill::Pattern areapattern(Qt::BrushStyle p) {
00533 switch(p) {
00534
00535 case Qt::SolidPattern: return PlotAreaFill::FILL;
00536 case Qt::Dense1Pattern: case Qt::Dense2Pattern:
00537 return PlotAreaFill::MESH1;
00538 case Qt::Dense3Pattern: case Qt::Dense4Pattern:
00539 return PlotAreaFill::MESH2;
00540 case Qt::Dense5Pattern: case Qt::Dense6Pattern: case Qt::Dense7Pattern:
00541 return PlotAreaFill::MESH3;
00542
00543
00544 default: return PlotAreaFill::NOFILL;
00545 }
00546 }
00547
00548
00549
00550
00551 static QwtSymbol::Style symbol(PlotSymbol::Symbol s) {
00552 switch(s) {
00553
00554 case PlotSymbol::AUTOSCALING:
00555 case PlotSymbol::CIRCLE: return QwtSymbol::Ellipse;
00556 case PlotSymbol::SQUARE: return QwtSymbol::Rect;
00557 case PlotSymbol::DIAMOND: return QwtSymbol::Diamond;
00558
00559
00560 default: return QwtSymbol::NoSymbol;
00561 }
00562 }
00563 static PlotSymbol::Symbol symbol(QwtSymbol::Style s) {
00564 switch(s) {
00565
00566 case QwtSymbol::Ellipse: return PlotSymbol::CIRCLE;
00567 case QwtSymbol::Rect: return PlotSymbol::SQUARE;
00568 case QwtSymbol::Diamond: return PlotSymbol::DIAMOND;
00569
00570
00571 default: return PlotSymbol::NOSYMBOL;
00572 }
00573 }
00574
00575
00576
00577 static String cssLineStyle(PlotLine::Style style) {
00578 switch(style) {
00579 case PlotLine::SOLID: return "solid";
00580 case PlotLine::DASHED: return "dashed";
00581 case PlotLine::DOTTED: return "dotted";
00582
00583 default: return "";
00584 }
00585 }
00586
00587
00588 static int round(double d) {
00589 if(d >= 0) return (int)(d + 0.5);
00590 else return (int)(d - 0.5);
00591 }
00592
00593
00594
00595 static QwtLinearColorMap* standardSpectrogramMap();
00596 static QwtLinearColorMap* standardRasterMap();
00597 static QwtLinearColorMap* rasterMap(const vector<double>& values);
00598
00599 };
00600
00601 }
00602
00603 #endif
00604
00605 #endif