General Purpose Geodetic Library
SgGuiPlotter.cpp
Go to the documentation of this file.
1 /*
2  *
3  * This file is a part of Space Geodetic Library. The library is used by
4  * nuSolve, a part of CALC/SOLVE system, and designed to make analysis of
5  * geodetic VLBI observations.
6  * Copyright (C) 2010-2020 Sergei Bolotin.
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 #include <math.h>
24 
25 
26 #include <SgGuiPlotter.h>
27 #include <SgMJD.h>
28 #include <SgVersion.h>
29 
30 #include <QtCore/QDir>
31 #include <QtCore/QFile>
32 #include <QtCore/QTextStream>
33 
34 
35 
36 
37 #if QT_VERSION >= 0x050000
38 # include <QtWidgets/QApplication>
39 # include <QtWidgets/QBoxLayout>
40 # include <QtWidgets/QButtonGroup>
41 # include <QtWidgets/QGroupBox>
42 # include <QtWidgets/QLabel>
43 # include <QtWidgets/QListView>
44 # include <QtWidgets/QMenu>
45 # include <QtWidgets/QMessageBox>
46 # include <QtWidgets/QRadioButton>
47 # include <QtCore/QStringListModel>
48 # include <QtWidgets/QToolTip>
49 #else
50 # include <QtGui/QApplication>
51 # include <QtGui/QBoxLayout>
52 # include <QtGui/QButtonGroup>
53 # include <QtGui/QGroupBox>
54 # include <QtGui/QLabel>
55 # include <QtGui/QListView>
56 # include <QtGui/QMenu>
57 # include <QtGui/QMessageBox>
58 # include <QtGui/QRadioButton>
59 # include <QtGui/QStringListModel>
60 # include <QtGui/QToolTip>
61 #endif
62 
63 #include <QtGui/QFontMetrics>
64 #include <QtGui/QImage>
65 #include <QtGui/QPaintDevice>
66 #include <QtGui/QPainter>
67 #include <QtGui/QPdfWriter>
68 
69 
70 
71 
72 
73 /*=======================================================================================================
74 *
75 * SgPlotBranch:
76 *
77 *======================================================================================================*/
78 SgPlotBranch::SgPlotBranch(unsigned int numOfRows,
79  unsigned int numOfValuesColumns, unsigned int numOfSigmasColumns,
80  const QString& name, bool hasExtKeys)
81  :
82  name_(name),
83  alternativeTitleName_(),
84  extKeys_()
85 {
86  alternativeTitleName_[-1] = name;
88  data_ = new SgMatrix(numOfRows_, numOfValuesColumns + numOfSigmasColumns + 1);
89  isBrowsable_ = true;
90  if ((hasExtKeys_=hasExtKeys))
91  {
92  extKeys_.resize(numOfRows_);
94  for (unsigned int i=0; i<numOfRows_; i++)
95  extKeysVisible_[i] = true;
96  };
97 // idx_ = 0;
98 };
99 
100 
101 
102 //
104 {
105  if (data_)
106  {
107  delete data_;
108  data_ = NULL;
109  };
110 };
111 
112 
113 
114 //
115 void SgPlotBranch::setDataAttr(unsigned int i, unsigned int attr)
116 {
117  data_->setElement(i, data_->nCol()-1, (double) attr);
118 };
119 
120 
121 
122 //
123 void SgPlotBranch::addDataAttr(unsigned int i, unsigned int attr)
124 {
125  unsigned int a = getDataAttr(i);
126  data_->setElement(i, data_->nCol()-1, (double) (a | attr));
127 };
128 
129 
130 
131 //
132 void SgPlotBranch::delDataAttr(unsigned int i, unsigned int attr)
133 {
134  unsigned int a = getDataAttr(i);
135  data_->setElement(i, data_->nCol()-1, (double) (a & ~attr));
136 };
137 
138 
139 
140 //
141 void SgPlotBranch::xorDataAttr(unsigned int i, unsigned int attr)
142 {
143  unsigned int a = getDataAttr(i);
144  data_->setElement(i, data_->nCol()-1, (double) (a ^ attr));
145 };
146 
147 
148 
149 //
150 unsigned int SgPlotBranch::getDataAttr(unsigned int i) const
151 {
152  return (unsigned int) data_->getElement(i, data_->nCol()-1);
153 };
154 
155 
156 
157 //
158 bool SgPlotBranch::isPointInRanges(int idx, unsigned int limits) const
159 {
161  bool isInRanges(false);
162 
163  if (sod == SgPlotArea::SOD_ALL)
164  isInRanges = true;
165  else if (sod == SgPlotArea::SOD_USABLE)
166  isInRanges = !(getDataAttr(idx) & SgPlotCarrier::DA_NONUSABLE);
167  else if (sod == SgPlotArea::SOD_PROCESSED)
168  isInRanges = !(getDataAttr(idx) & SgPlotCarrier::DA_NONUSABLE) &&
170  return isInRanges;
171 };
172 
173 
174 
175 //
176 bool SgPlotBranch::isPointVisible(int idx, unsigned int limits) const
177 {
179  bool isVisible(false);
180 
181  if (hasExtKeys_ && !extKeysVisible_.at(idx))
182  return false;
183 
184  if (sod == SgPlotArea::SOD_ALL)
185  isVisible = true;
186  else if (sod == SgPlotArea::SOD_USABLE)
187  isVisible = !(getDataAttr(idx) & SgPlotCarrier::DA_NONUSABLE);
188  else if (sod == SgPlotArea::SOD_PROCESSED)
189  {
190  isVisible = !(getDataAttr(idx) & SgPlotCarrier::DA_NONUSABLE) &&
192  };
193  return isVisible;
194 };
195 
196 
197 
198 //
199 void SgPlotBranch::flagExtKey(const QString& eKey, bool on)
200 {
201  for (unsigned int i=0; i<numOfRows_; i++)
202  if (extKeys_.at(i).contains(eKey))
203  extKeysVisible_[i] = on;
204 };
205 /*=====================================================================================================*/
206 
207 
208 
209 
210 /*=======================================================================================================
211 *
212 * SgPlotCarrier:
213 *
214 *======================================================================================================*/
215 SgPlotCarrier::SgPlotCarrier(unsigned int numOfValuesColumns,
216  unsigned int numOfSigmasColumns,
217  const QString& name) :
218  name_(),
219  columnNames_(numOfValuesColumns + numOfSigmasColumns, NULL)
220 {
223 
224  name_[-1] = name;
225  file2SaveBaseName_ = "unnamed_data";
226 
227  dataTypes_ = new int[numOfColumns()-1];
228  dataStdVarIdx_ = new int[numOfColumns()-1];
229  //set default values:
230  for (int i=0; i<numOfColumns()-1; i++)
231  {
232  *(dataTypes_ + i) = AxisType_DATA;
233  *(dataStdVarIdx_ + i) = -1;
234  };
235  isOK_ = false;
236 };
237 
238 
239 
240 //
242 {
243  if (dataTypes_)
244  {
245  delete[] dataTypes_;
246  dataTypes_ = NULL;
247  };
248  if (dataStdVarIdx_)
249  {
250  delete[] dataStdVarIdx_;
251  dataStdVarIdx_ = NULL;
252  };
253  for (unsigned int i=0; i<numOfValuesColumns_+numOfSigmasColumns_; i++)
254  delete columnNames_.at(i);
255  while (!listOfBranches_.isEmpty())
256  delete listOfBranches_.takeFirst();
257 };
258 
259 
260 
261 //
262 void SgPlotCarrier::createBranch(unsigned int numberOfRows, const QString& branchName,
263  bool hasExtKeys)
264 {
265  listOfBranches_.append(
266  new SgPlotBranch(numberOfRows, numOfValuesColumns_, numOfSigmasColumns_, branchName, hasExtKeys));
267 };
268 
269 
270 
271 //
273 {
274  isOK_ = false;
275  // check sizes:
276  if (!listOfBranches_.size())
277  {
279  ": selfCheck(): the list of branches is empty, nothing to plot");
280  return isOK_; // nothing to plot
281  };
282 
283  // check names of columns, fill empty slots:
284  for (unsigned int i=0; i<numOfValuesColumns_+numOfSigmasColumns_; i++)
285  if (columnNames_.at(i) == NULL)
286  columnNames_[i] = new QString("");
287 
288  // check sizes of each branch:
289  for (int i=0; i<listOfBranches_.size(); i++)
290  if (!listOfBranches_.at(i)->data()->nRow())
291  {
293  ": selfCheck(): the branch " + listOfBranches_.at(i)->getName() + " has no points");
294  }
295  // it's ok:
296  return (isOK_=true);
297 };
298 
299 
300 
301 //
302 void SgPlotCarrier::setNameOfColumn(unsigned int idx, const QString& name)
303 {
305  columnNames_[idx] = new QString(name);
306 };
307 /*=====================================================================================================*/
308 
309 
310 
311 
312 
313 
314 /*=======================================================================================================
315 *
316 * SgPlotArea:
317 *
318 *======================================================================================================*/
319 QString SgPlotArea::xLabel4Unknown_("Unnamed X axis");
320 QString SgPlotArea::yLabel4Unknown_("Unnamed Y axis");
321 SgPlotArea::SgPlotArea(SgPlotCarrier* plotCarrier, QWidget* parent, Qt::WindowFlags f)
322  : QWidget(parent, f)
323 {
324  plotCarrier_ = plotCarrier;
325 
326  width_ = 980;
327  height_ = 510;
330 
331  xColumn_ = yColumn_ = 0;
332 
333  radius_ = 3;
334  ddr_ = 1;
335 
336  isXTicsMJD_ = false;
337  isPlotPoints_ = true;
338  isPlotLines_ = false;
339  isPlotErrBars_ = false;
340  isPlotImpulses_ = false;
341  have2HasZero_ = false;
342  isLimitsOnVisible_ = false;
345  isStdVar_ = true;
346  isRangeSymmetrical_ = false;
347 
350 
351  setXColumn(0);
352  setYColumn(1);
353 
354  resize(width_, height_);
355  setBackgroundRole(QPalette::Base);
356  framePen_ = new QPen(QColor(0,0,0), 1);
357  zeroPen_ = new QPen(QColor(120,120,120), 1);
358  barPen_ = new QPen(QColor(180,0,0), 1);
359  rulerPen_ = new QPen(QColor(150,150,150), 1);
360  ticLinesPen_ = new QPen(QColor(225,225,225), 1);
361  rulerBrush_ = new QBrush(QColor(255, 230, 10, 200));
362  ignoredPen_ = new QPen(QColor(140,140,140), 1);
363  ignoredBrush_ = new QBrush(QColor(200,200,200));
364 
365 
366  bpHuePhase_ = 0;
367  bpSaturation_ = 255;
368  bpValue_ = 230;
369 
370  branchPens_ = NULL;
371  branchBrushes_ = NULL;
372  branchSelectedPens_ = NULL;
373  branchSelectedBrushes_ = NULL;
374  initBranchPens();
375 
376  maxX_ = 20.0;
377  maxY_ = 20.0;
378  minX_ =-20.0;
379  minY_ =-20.0;
381 
382  //
383  upMargin_ = 10;
384  rightMargin_ = 10;
385  xLabelWidth_ = 0;
386  labelsHeight_= 0;
387  yLabelWidth_ = 0;
388  yLabelHeight_= 0;
389  xTicsWidth_ = 0;
390  yTicsWidth_ = 0;
391 
392  titleWidth_ = 0;
393  // XTics:
394  numOfXTics_ = 0;
395  xStepP_ = 0;
396  xTicsStep_ = 0.0;
397  xTicsBias_ = 0.0;
398  isXTicsBiased_= false;
399 
400  // YTics:
401  numOfYTics_ = 0;
402  yStepP_ = 0;
403  yTicsStep_ = 0.0;
404  yTicsBias_ = 0.0;
405  isYTicsBiased_= false;
406 
407  xFrameBegin_ = 0;
408  xFrameEnd_ = 0;
409  yFrameBegin_ = 0;
410  yFrameEnd_ = 0;
411 
412  xDataBegin_ = 0;
413  xDataEnd_ = 0;
414  xMargins_ = 0;
415  yDataBegin_ = 0;
416  yDataEnd_ = 0;
417  yMargins_ = 0;
418 
419  f_Ax_ = f_Bx_ = f_Ay_ = f_By_ = 0.0;
420 
421  xTicsMJD_ = 0;
422 
423  rulerFromPoint_.setX(-1);
424  rulerFromPoint_.setY(-1);
425  rulerToPoint_.setX(-1);
426  rulerToPoint_.setY(-1);
427  rulerToPointPrev_.setX(-1);
428  rulerToPointPrev_.setY(-1);
429 
430  cursorDefault_.setShape(Qt::ArrowCursor);
431  cursorScrolling_.setShape(Qt::ClosedHandCursor);
432  cursorMeasuring_.setShape(Qt::CrossCursor);
433 // cursorMeasuring_.setShape(Qt::ArrowCursor);
434 
436 };
437 
438 
439 
440 //
442 {
443  if (ignoredPen_)
444  {
445  delete ignoredPen_;
446  ignoredPen_ = NULL;
447  };
448  if (ignoredBrush_)
449  {
450  delete ignoredBrush_;
451  ignoredBrush_ = NULL;
452  };
453  if (rulerBrush_)
454  {
455  delete rulerBrush_;
456  rulerBrush_ = NULL;
457  };
458  if (framePen_)
459  {
460  delete framePen_;
461  framePen_ = NULL;
462  };
463  if (zeroPen_)
464  {
465  delete zeroPen_;
466  zeroPen_ = NULL;
467  };
468  if (barPen_)
469  {
470  delete barPen_;
471  barPen_ = NULL;
472  };
473  if (branchPens_)
474  {
475  delete[] branchPens_;
476  branchPens_ = NULL;
477  };
478  if (branchBrushes_)
479  {
480  delete[] branchBrushes_;
481  branchBrushes_ = NULL;
482  };
484  {
485  delete[] branchSelectedPens_;
486  branchSelectedPens_ = NULL;
487  };
489  {
490  delete[] branchSelectedBrushes_;
491  branchSelectedBrushes_ = NULL;
492  };
493  if (ticLinesPen_)
494  {
495  delete ticLinesPen_;
496  ticLinesPen_ = NULL;
497  };
498  if (rulerPen_)
499  {
500  delete rulerPen_;
501  rulerPen_ = NULL;
502  };
503 };
504 
505 
506 
507 //
508 void SgPlotArea::setUserDefinedRanges(double minX, double maxX, double minY, double maxY)
509 {
510  userDefinedMinX_ = minX;
511  userDefinedMaxX_ = maxX;
512 
513  userDefinedMinY_ = minY;
514  userDefinedMaxY_ = maxY;
515 
516  useUserDefinedRanges_ = true;
517 };
518 
519 
520 
521 //
523 {
524  userDefinedMinX_ = 0.0;
525  userDefinedMaxX_ = 0.0;
526 
527  userDefinedMinY_ = 0.0;
528  userDefinedMaxY_ = 0.0;
529 
530  useUserDefinedRanges_ = false;
531 };
532 
533 
534 
535 //
537 {
538  if (userMode_ != mode)
539  {
540  userMode_ = mode;
541  switch (userMode_)
542  {
543  case UserMode_INQUIRING:
544  case UserMode_QUERYING:
545  case UserMode_SELECTING:
547  setCursor(cursorDefault_);
548  break;
549 
550  case UserMode_SCROLLING:
551  setCursor(cursorScrolling_);
552  break;
553 
554  case UserMode_MEASURING:
555  setCursor(cursorMeasuring_);
556  break;
557 
558  case UserMode_RERANGING:
559  setCursor(cursorMeasuring_);
560  break;
561 
562  default:
563  case UserMode_DEFAULT:
564  setCursor(cursorDefault_);
565  // zerofy ruler's points:
566  rulerFromPoint_.setX(-1);
567  rulerFromPoint_.setY(-1);
568  rulerToPoint_.setX(-1);
569  rulerToPoint_.setY(-1);
570  rulerToPointPrev_.setX(-1);
571  rulerToPointPrev_.setY(-1);
572  break;
573  };
574  };
575 };
576 
577 
578 
579 //
581 {
582  if (branchPens_)
583  delete[] branchPens_;
584  if (branchBrushes_)
585  delete[] branchBrushes_;
587  delete[] branchSelectedPens_;
589  delete[] branchSelectedBrushes_;
590  int numOfBranches = plotCarrier_->listOfBranches()->size();
591  branchPens_ = new QPen[numOfBranches];
592  branchBrushes_ = new QBrush[numOfBranches];
593  branchSelectedPens_ = new QPen[numOfBranches];
594  branchSelectedBrushes_ = new QBrush[numOfBranches];
595  setBranchColors();
596 };
597 
598 
599 
600 //
602 {
603  int numOfBranches = plotCarrier_->listOfBranches()->size();
604  QPen *pen = branchPens_;
605  QBrush *brush = branchBrushes_;
606  QPen *pen4Selection = branchSelectedPens_;
607  QBrush *brush4Selection = branchSelectedBrushes_;
608  QColor color, color4Selection;
609  for (int i=0; i<numOfBranches; i++, pen++, brush++, pen4Selection++, brush4Selection++)
610  {
611  color.setHsv(bpHuePhase_ + (int)(360*i/numOfBranches), bpSaturation_, bpValue_);
612  pen->setColor(color);
613  pen->setWidth(1);
614  brush->setColor(color);
615  brush->setStyle(Qt::SolidPattern);
616 
617  color4Selection.setHsv((int)(360*i/numOfBranches), 255, 175);
618  pen4Selection->setColor(color4Selection);
619  pen4Selection->setWidth(3);
620  brush4Selection->setColor(QColor(255,255,255));
621  brush4Selection->setStyle(Qt::SolidPattern);
622  };
623 };
624 
625 
626 
627 //
629 {
630  bpHuePhase_ = phase;
631  setBranchColors();
632  update();
633 };
634 
635 
636 
637 //
638 void SgPlotArea::setBPSaturation(int saturation)
639 {
640  bpSaturation_ = saturation;
641  setBranchColors();
642  update();
643 };
644 
645 
646 
647 //
648 void SgPlotArea::setBPValue(int value)
649 {
650  bpValue_ = value;
651  setBranchColors();
652  update();
653 };
654 
655 
656 
657 //
658 void SgPlotArea::setXColumn(unsigned int xColumn)
659 {
660  if (plotCarrier_->isOK() && xColumn < (unsigned int)plotCarrier_->numOfColumns())
661  {
662  xColumn_ = xColumn;
664  isXTicsMJD_ = true;
665  else
666  isXTicsMJD_ = false;
667  if (*plotCarrier_->columnNames()->at(xColumn_) != "")
669  else
671  };
672 };
673 
674 
675 
676 //
677 void SgPlotArea::setYColumn(unsigned int yColumn)
678 {
679  if (plotCarrier_->isOK() && yColumn < (unsigned int)plotCarrier_->numOfColumns())
680  {
681  yColumn_ = yColumn;
682  if (*plotCarrier_->columnNames()->at(yColumn_) != "")
684  else
686  };
687 };
688 
689 
690 
691 //
693 {
694  if (!plotCarrier_->isOK())
695  return; // nothing to do
696 
698  {
701 
704  }
705  else
706  {
707  // find out first browsable point:
708  int iBranch=0;
710  SgPlotBranch *branch=plotCarrier_->listOfBranches()->at(iBranch);
711  SetsOfData rangeLimits=rangeLimits_;
712  // first, skip branches with zero data:
713  while (iBranch<plotCarrier_->listOfBranches()->size() &&
714  (branch=plotCarrier_->listOfBranches()->at(iBranch))->data()->nRow()<=0)
715  iBranch++;
716  if (iBranch==plotCarrier_->listOfBranches()->size() && branch->data()->nRow()<=0)
717  return; // all are turned off, nothing to calc, use previous limits
718  //
719  if (isLimitsOnVisible_)
720  {
721  while (iBranch<plotCarrier_->listOfBranches()->size() &&
722  !(branch=plotCarrier_->listOfBranches()->at(iBranch))->getIsBrowsable())
723  iBranch++;
724  if (iBranch==plotCarrier_->listOfBranches()->size() && !branch->getIsBrowsable())
725  return; // all are turned off, nothing to calc, use previous limits
726  };
727 
728  unsigned idx=0;
729  if (rangeLimits != SOD_ALL)
730  {
731  bool isInvisible=true;
732  while (isInvisible && iBranch<plotCarrier_->listOfBranches()->size())
733  {
734  idx = 0;
735  while (idx < branch->data()->nRow() &&
736 // (isInvisible = branch->getDataAttr(idx) & SgPlotCarrier::DA_REJECTED))
737  (isInvisible = !(isLimitsOnVisible_?
738  branch->isPointVisible(idx, rangeLimits):
739  branch->isPointInRanges(idx, rangeLimits))
740  ))
741  idx++;
742  if (isInvisible)
743  {
744  iBranch++;
745  if (iBranch < plotCarrier_->listOfBranches()->size())
746  branch = plotCarrier_->listOfBranches()->at(iBranch);
747  };
748  };
749  if (isInvisible) // all points are in DATA_IGNORE mode, calc limits using all data
750  {
751  rangeLimits = SOD_ALL;
752  idx = 0;
753  };
754  };
755 
756  minX_ = branch->data()->getElement(idx, xColumn_);
757  maxX_ = branch->data()->getElement(idx, xColumn_);
758  minY_ = (ei>=0) ? branch->data()->getElement(idx, yColumn_) - branch->data()->getElement(idx, ei) :
759  branch->data()->getElement(idx, yColumn_);
760  maxY_ = (ei>=0) ? branch->data()->getElement(idx, yColumn_) + branch->data()->getElement(idx, ei) :
761  branch->data()->getElement(idx, yColumn_);
762  //
763  for (int j=0; j<plotCarrier_->listOfBranches()->size(); j++)
764  {
765  branch = plotCarrier_->listOfBranches()->at(j);
766  if (branch->getIsBrowsable() || !isLimitsOnVisible_)
767  for (unsigned i=0; i<branch->data()->nRow(); i++)
768  {
769  if (isLimitsOnVisible_?
770  branch->isPointVisible(i, rangeLimits):
771  branch->isPointInRanges(i, rangeLimits))
772  {
773  minX_ = std::min(minX_, branch->data()->getElement(i, xColumn_));
774  maxX_ = std::max(maxX_, branch->data()->getElement(i, xColumn_));
775  minY_ = std::min(minY_, (ei>=0) ? branch->data()->getElement(i, yColumn_) -
776  branch->data()->getElement(i, ei) : branch->data()->getElement(i, yColumn_) );
777  maxY_ = std::max(maxY_, (ei>=0) ? branch->data()->getElement(i, yColumn_) +
778  branch->data()->getElement(i, ei) : branch->data()->getElement(i, yColumn_) );
779  };
780  };
781  };
782  };
783  //
784  // make final arrangements:
785  if (maxX_ == minX_)
786  {
787  minX_ -= 0.5;
788  maxX_ += 0.5;
789  };
790  if (maxY_ == minY_)
791  {
792  minY_ -= 0.5;
793  maxY_ += 0.5;
794  };
795  // adjust the limits:
796  double d;
797  d = (maxY_ + minY_)/2.0;
798  if ( (maxY_-minY_)<d && (maxY_-minY_)/d<1.0e-12 )
799  {
800 
801  minY_ -= d*1.0e-12;
802  maxY_ += d*1.0e-12;
803  };
804 
805  if (have2HasZero_)
806  {
808  {
809  if (minX_>0.0)
810  minX_ = 0.0;
811  else
812  maxX_ = 0.0;
813  };
815  {
816  if (minY_ > 0.0)
817  minY_ = 0.0;
818  else
819  maxY_ = 0.0;
820  };
821  };
822  //
823  if (isRangeSymmetrical_) // for nonMJD-axis only:
824  {
825  double max;
827  {
828  max = std::max(fabs(maxX_), fabs(minX_));
829  maxX_ = max;
830  minX_ =-max;
831  };
833  {
834  max = std::max(fabs(maxY_), fabs(minY_));
835  maxY_ = max;
836  minY_ =-max;
837  };
838  };
839  //
840 };
841 
842 
843 
844 //
846 {
849 
852 };
853 
854 
855 
856 //
857 void SgPlotArea::defineAreas(QPainter* painter)
858 {
859  double dy = 0.0;
860 
861  isXTicsBiased_ = false;
862  isYTicsBiased_ = false;
863 
864  QFontMetrics fm(painter->fontMetrics());
865  labelsHeight_ = fm.height();
866 
867  xLabelWidth_ = fm.width(*xLabel_);
868  yLabelWidth_ = fm.width(*yLabel_);
869  yLabelHeight_ = fm.height();
871 
872  // should be smarter a bit
873  xTicsWidth_ = fm.width("800000000");
874  if (isXTicsMJD_)
875  xTicsWidth_ = fm.width(" " + SgMJD(minX_).toString(SgMJD::F_Date) + " ");
876 
877  upMargin_ = 3*labelsHeight_/2;
880  // Define Width of Y Tics:
883  yStepP_ = (int)floor(log10(yTicsStep_));
884 
885  yTicsStep_ = trunc( yTicsStep_/exp10(yStepP_) );
886  if (yTicsStep_ == 3)
887  yTicsStep_ = 2;
888  else if (yTicsStep_==4 || yTicsStep_==6 || yTicsStep_==7)
889  yTicsStep_ = 5;
890  else if (yTicsStep_ == 8 || yTicsStep_ == 9)
891  yTicsStep_ = 10;
892  yTicsStep_ = yTicsStep_*exp10(yStepP_);
893  yTicsWidth_ = 10;
894  if ((maxY_ + yTicsStep_/3.0)*(minY_ - yTicsStep_/3.0)<0.0) // here the "0" is the origin
895  {
896  dy = 0.0;
897  while (dy <= maxY_ + yTicsStep_/3.0)
898  {
899  yTicsWidth_ = std::max(yTicsWidth_, fm.width(QString().sprintf("%.8g", dy)));
900  dy += yTicsStep_;
901  };
902  dy = 0.0;
903  while (dy >= minY_ - yTicsStep_/3.0)
904  {
905  yTicsWidth_ = std::max(yTicsWidth_, fm.width(QString().sprintf("%.8g", dy)));
906  dy -= yTicsStep_;
907  };
908  }
909  else
910  {
911  if (log10(fabs(minY_)) - yStepP_ > 7.0) // need a bias
912  {
913  isYTicsBiased_ = true;
914  yTicsBias_ = trunc( minY_/exp10(yStepP_ + 1.0) )*exp10(yStepP_ + 1.0);
915  yLabelWidth_ += fm.width(QString().sprintf(", %.16g +", yTicsBias_));
916  }
917  else
918  {
919  yTicsBias_ = 0.0;
920  isYTicsBiased_ = false;
921  };
922  // define the origin:
923  dy = yTicsStep_*floor(maxY_/yTicsStep_);
924  if (!isYTicsBiased_) //?
925  while (dy > minY_) // down from the origin:
926  {
927  yTicsWidth_ = std::max(yTicsWidth_,
928  fm.width(QString().sprintf("%.8g", isYTicsBiased_ ? dy-yTicsBias_ : dy)));
929  dy -= yTicsStep_;
930  };
931  };
932  // end of Y-Tics calculations
933 
936 
937  // Define X Tics parameters:
938  if (isXTicsMJD_)
939  {
941  xTicsStep_ = 86400.0*(maxX_ - minX_)/numOfXTics_; // here xTicsStep_ in sec
942  if (xTicsStep_ <= 60.0) // sec.s
943  {
944  xStepP_ = (int)floor(log10(xTicsStep_));
945  xTicsStep_ = trunc( xTicsStep_/exp10(xStepP_) )*exp10(xStepP_);
946  xTicsMJD_ = 0;
947  }
948  else if (xTicsStep_/60.0 <= 45.0) // min.s
949  {
950  xTicsStep_ /= 60.0;
951  xStepP_ = (int)floor(log10(xTicsStep_));
952  xTicsStep_ = trunc( xTicsStep_/exp10(xStepP_) )*exp10(xStepP_);
953  if (10.0>xTicsStep_ && xTicsStep_>=8.0)
954  xTicsStep_ = 10.0;
955  else if (8.0>xTicsStep_ && xTicsStep_>=5.0)
956  xTicsStep_ = 5.0;
957  else if (5.0>xTicsStep_ && xTicsStep_>=2.0)
958  xTicsStep_ = 2.0;
959  xTicsMJD_ = 1;
960  }
961  else if (xTicsStep_/3600.0 <= 18.0) // hrs
962  {
963  xTicsStep_ /= 3600.0;
964  xStepP_ = (int)floor(log10(xTicsStep_));
965  xTicsStep_ = trunc( xTicsStep_/exp10(xStepP_) )*exp10(xStepP_);
966  if (xTicsStep_ >= 10.0)
967  xTicsStep_ = 12.0;
968  else if (xTicsStep_ >= 8.0)
969  xTicsStep_ = 8.0;
970  else if (xTicsStep_ >= 6.0)
971  xTicsStep_ = 6.0;
972  else if (xTicsStep_ >= 4.0)
973  xTicsStep_ = 4.0;
974  if (xTicsStep_ < 1.0)
975  xTicsStep_ = 1.0;
976  xTicsMJD_ = 2;
977  }
978  else if (xTicsStep_/86400.0 <= 20.0) // days
979  {
980  xTicsStep_ /= 86400.0;
981  if (xTicsStep_ < 1.0)
982  xTicsStep_ = 0.5;
983  xStepP_ = (int)floor(log10(xTicsStep_));
984  xTicsStep_ = trunc( xTicsStep_/exp10(xStepP_) )*exp10(xStepP_);
985  xTicsMJD_ = 3; //days
986  }
987  else
988  {
990  xTicsStep_ = 86400.0*(maxX_ - minX_)/numOfXTics_;
991 
992  xTicsStep_ /= 86400.0;
993  xStepP_ = (int)floor(log10(xTicsStep_));
994  xTicsStep_ = trunc( xTicsStep_/exp10(xStepP_) )*exp10(xStepP_);
995  xTicsMJD_ = 4; //days and more
996  };
997  }
998  else
999  {
1002  xStepP_ = (int)floor(log10(xTicsStep_));
1003  xTicsStep_ = trunc( xTicsStep_/exp10(xStepP_) );
1004  if (xTicsStep_ == 3)
1005  xTicsStep_ = 2;
1006  else if (xTicsStep_ == 4 || xTicsStep_ == 6 || xTicsStep_ == 7)
1007  xTicsStep_ = 5;
1008  else if (xTicsStep_==8 || xTicsStep_==9)
1009  xTicsStep_ = 10;
1010  xTicsStep_ = xTicsStep_*exp10(xStepP_);
1011  if (!isXTicsMJD_ && log10(fabs(minX_)) - xStepP_ > 7.0) // need a bias
1012  {
1013  isXTicsBiased_ = true;
1014  xTicsBias_ = trunc( minX_/exp10(xStepP_ + 1.0) )*exp10(xStepP_ + 1.0);
1015  xLabelWidth_ += fm.width(QString().sprintf(", %.16g +", xTicsBias_));
1016  }
1017  else
1018  {
1019  xTicsBias_ = 0.0;
1020  isXTicsBiased_ = false;
1021  };
1022  };
1023  // end of XTics calculations
1024  xDataBegin_ = xFrameBegin_ + 20;
1025  xDataEnd_ = xFrameEnd_ - 20;
1027 
1028  yDataBegin_ = yFrameBegin_ + 20;
1029  yDataEnd_ = yFrameEnd_ - 20;
1031 };
1032 
1033 
1034 
1035 //
1036 void SgPlotArea::resizeEvent(QResizeEvent* ev)
1037 {
1038  height_ = ev->size().height();
1039  width_ = ev->size().width();
1040  QWidget::resizeEvent(ev);
1041 };
1042 
1043 
1044 
1045 //
1046 void SgPlotArea::paintEvent(QPaintEvent *e)
1047 {
1048  QPainter painter(this);
1049  QRect rect = e->rect();
1050  drawWholePlot(&painter, rect);
1051 };
1052 
1053 
1054 
1055 //
1056 void SgPlotArea::drawWholePlot(QPainter* painter, const QRect& rect)
1057 {
1058 // painter->setRenderHint(QPainter::Antialiasing);
1059 // painter->setRenderHint(QPainter::TextAntialiasing);
1060 // painter->setRenderHint(QPainter::HighQualityAntialiasing);
1061 
1062  calcLimits();
1063  defineAreas(painter);
1064  calcTransforms();
1065  drawFrames(painter);
1066  drawYTics(painter);
1067 
1068  if (isXTicsMJD_)
1069  drawXmjdTics(painter);
1070  else
1071  drawXTics(painter);
1072 
1073  //painter->setRenderHint(QPainter::Antialiasing);
1074  drawData(painter, rect);
1075 
1077  drawPointInfo(painter);
1078  else if (userMode_==UserMode_MEASURING)
1079  drawRuler(painter);
1080  else if (userMode_==UserMode_RERANGING)
1081  drawRangeSelector(painter);
1083  drawPointSelector(painter);
1084 };
1085 
1086 
1087 
1088 //
1089 void SgPlotArea::drawPointInfo(QPainter* painter)
1090 {
1091  if (rulerToPoint_.x()>=0 && rulerToPoint_.y()>=0)
1092  {
1093  painter->setPen(*rulerPen_);
1094  painter->drawEllipse(rulerFromPoint_, 2, 2);
1095  painter->drawEllipse(rulerToPoint_, 2, 2);
1096 
1097  double x = reverseCalcX(rulerToPoint_.x());
1098  double y = reverseCalcY(rulerToPoint_.y());
1099 
1100  QString xInfo, yInfo;
1101  QFontMetrics fm(painter->fontMetrics());
1102 
1103  if (isXTicsMJD_)
1104  {
1105  xInfo = "t: " + SgMJD(x).toString(SgMJD::F_YYYYMMDDHHMMSSSS);
1106  yInfo.sprintf("f: %.4g", y);
1107  }
1108  else
1109  {
1110  xInfo.sprintf("x: %.4g", x);
1111  yInfo.sprintf("y: %.4g", y);
1112  };
1113 
1114  int biasX = 5, biasY = 5;
1115  int widthDX = fm.width(xInfo);
1116  int widthDY = fm.width(yInfo);
1117  int rectHeight = 2*fm.height() + 3*biasY;
1118  int rectWidth = std::max(widthDX, widthDY) + 2*biasX;
1119 
1120  QRect infoRect(rulerToPoint_.x()+10, rulerToPoint_.y()-10 - rectHeight, rectWidth, rectHeight);
1121 
1122  painter->setPen(*framePen_);
1123  painter->fillRect(infoRect, *rulerBrush_);
1124  painter->setBrush(Qt::NoBrush);
1125 
1126  painter->drawText(rulerToPoint_.x()+10 + biasX,
1127  rulerToPoint_.y()-10 - rectHeight + biasY + fm.height(), xInfo);
1128  painter->drawText(rulerToPoint_.x()+10 + biasX,
1129  rulerToPoint_.y()-10 - rectHeight + 2*(biasY + fm.height()), yInfo);
1130  };
1131 };
1132 
1133 
1134 
1135 //
1136 void SgPlotArea::drawRuler(QPainter* painter)
1137 {
1138  if (rulerFromPoint_.x()>=0 && rulerFromPoint_.y()>=0)
1139  {
1140  painter->setPen(*rulerPen_);
1141  painter->drawEllipse(rulerFromPoint_, 2, 2);
1142  painter->drawEllipse(rulerToPoint_, 2, 2);
1143  painter->drawLine(rulerFromPoint_, rulerToPoint_);
1144 
1145  double dx = reverseCalcX(rulerToPoint_.x()) - reverseCalcX(rulerFromPoint_.x());
1146  double dy = reverseCalcY(rulerToPoint_.y()) - reverseCalcY(rulerFromPoint_.y());
1147  QString dXInfo, dYInfo;
1148  QFontMetrics fm(painter->fontMetrics());
1149 
1150  if (isXTicsMJD_)
1151  {
1152  dXInfo = "dt: " + interval2Str(dx);
1153  dYInfo.sprintf("df: %.4g", dy);
1154  }
1155  else
1156  {
1157  dXInfo.sprintf("dx: %.4g", dx);
1158  dYInfo.sprintf("dy: %.4g", dy);
1159  };
1160 
1161  int biasX = 5, biasY = 5;
1162  int widthDX = fm.width(dXInfo);
1163  int widthDY = fm.width(dYInfo);
1164  int rectHeight = 2*fm.height() + 3*biasY;
1165  int rectWidth = std::max(widthDX, widthDY) + 2*biasX;
1166 
1167  QRect infoRect(rulerToPoint_.x()+10, rulerToPoint_.y()-10 - rectHeight, rectWidth, rectHeight);
1168 
1169  painter->setPen(*framePen_);
1170  painter->fillRect(infoRect, *rulerBrush_);
1171  painter->setBrush(Qt::NoBrush);
1172 
1173  painter->drawText(rulerToPoint_.x()+10 + biasX,
1174  rulerToPoint_.y()-10 - rectHeight + biasY + fm.height(), dXInfo);
1175  painter->drawText(rulerToPoint_.x()+10 + biasX,
1176  rulerToPoint_.y()-10 - rectHeight + 2*(biasY + fm.height()), dYInfo);
1177  };
1178 };
1179 
1180 
1181 
1182 //
1183 void SgPlotArea::drawRangeSelector(QPainter* painter)
1184 {
1185  if (rulerFromPoint_.x()>=0 && rulerFromPoint_.y()>=0)
1186  {
1187  painter->setPen(*rulerPen_);
1188  QRect rect(rulerFromPoint_, (rulerToPoint_ -QPoint(1,1)));
1189  painter->drawRect(rect);
1190 
1191  double x_to = reverseCalcX(rulerToPoint_.x());
1192  double x_from = reverseCalcX(rulerFromPoint_.x());
1193  double y_to = reverseCalcY(rulerToPoint_.y());
1194  double y_from = reverseCalcY(rulerFromPoint_.y());
1195  double dx = x_to - x_from;
1196  double dy = y_to - y_from;
1197 
1198  QString xRangesInfo, yRangesInfo;
1199  QString dXInfo, dYInfo;
1200  QFontMetrics fm(painter->fontMetrics());
1201 
1202  if (isXTicsMJD_)
1203  {
1204  xRangesInfo = "t: from <" + SgMJD(x_from).toString(SgMJD::F_YYYYMMDDHHMMSSSS) +
1205  "> to <" + SgMJD(x_to).toString(SgMJD::F_YYYYMMDDHHMMSSSS) + ">";
1206  yRangesInfo.sprintf("f: from: <%.4g> to <%4.g>", y_from, y_to);
1207  dXInfo = "dt: " + interval2Str(dx);
1208  dYInfo.sprintf("df: %.4g", dy);
1209  }
1210  else
1211  {
1212  xRangesInfo.sprintf("f: from: <%.4g> to <%4.g>", x_from, x_to);
1213  yRangesInfo.sprintf("f: from: <%.4g> to <%4.g>", y_from, y_to);
1214  dXInfo.sprintf("dx: %.4g", dx);
1215  dYInfo.sprintf("dy: %.4g", dy);
1216  };
1217 
1218  int biasX = 5, biasY = 5;
1219  int rectWidth = std::max(fm.width(xRangesInfo), fm.width(yRangesInfo));
1220  rectWidth = std::max(rectWidth, fm.width(dXInfo));
1221  rectWidth = std::max(rectWidth, fm.width(dYInfo));
1222  rectWidth += 2*biasX;
1223  int rectHeight = 5*fm.height() + 6*biasY;
1224 
1225  QRect infoRect(rulerToPoint_.x()+10, rulerToPoint_.y()-10 - rectHeight, rectWidth, rectHeight);
1226 
1227  painter->setPen(*framePen_);
1228  painter->fillRect(infoRect, *rulerBrush_);
1229  painter->setBrush(Qt::NoBrush);
1230 
1231  painter->drawText(rulerToPoint_.x()+10 + biasX,
1232  rulerToPoint_.y()-10 - rectHeight + biasY + fm.height(), "New ranges:");
1233  painter->drawText(rulerToPoint_.x()+10 + biasX,
1234  rulerToPoint_.y()-10 - rectHeight + 2*(biasY + fm.height()), xRangesInfo);
1235  painter->drawText(rulerToPoint_.x()+10 + biasX,
1236  rulerToPoint_.y()-10 - rectHeight + 3*(biasY + fm.height()), yRangesInfo);
1237  painter->drawText(rulerToPoint_.x()+10 + biasX,
1238  rulerToPoint_.y()-10 - rectHeight + 4*(biasY + fm.height()), dXInfo);
1239  painter->drawText(rulerToPoint_.x()+10 + biasX,
1240  rulerToPoint_.y()-10 - rectHeight + 5*(biasY + fm.height()), dYInfo);
1241  };
1242 };
1243 
1244 
1245 
1246 //
1247 void SgPlotArea::drawPointSelector(QPainter* painter)
1248 {
1249  if (rulerFromPoint_.x()>=0 && rulerFromPoint_.y()>=0)
1250  {
1251  painter->setPen(*rulerPen_);
1252 // painter->setBrush(QBrush(QColor(200, 180, 50), Qt::Dense6Pattern));
1253  painter->setBrush(QBrush(QColor(144, 238, 144, 100)));
1254  QRect rect(rulerFromPoint_, (rulerToPoint_ - QPoint(1,1)));
1255 // painter->drawEllipse(rect);
1256  painter->drawRect(rect);
1257  painter->setBrush(Qt::NoBrush);
1258  };
1259 };
1260 
1261 
1262 
1263 //
1264 void SgPlotArea::drawFrames(QPainter* painter)
1265 {
1266  // Title:
1267  SgPlotBranch *branch=NULL;
1268  int numOfVisibleBranches=0;
1269  for (int i=0; i<plotCarrier_->listOfBranches()->size(); i++)
1270  if (plotCarrier_->listOfBranches()->at(i)->getIsBrowsable())
1271  {
1272  numOfVisibleBranches++;
1273  branch = plotCarrier_->listOfBranches()->at(i);
1274  };
1275  QFontMetrics fm(painter->fontMetrics());
1276  QString str(plotCarrier_->getName(yColumn_));
1277  if (numOfVisibleBranches==1)
1278  str = branch->getAlternativeTitleName(yColumn_);
1279  titleWidth_ = fm.width(str);
1280  painter->drawText((xFrameEnd_ + xFrameBegin_ - titleWidth_)/2, labelsHeight_, str);
1281  //
1282  // Labels:
1283  // X Label:
1284  if (isXTicsMJD_)
1285  painter->drawText((xFrameBegin_+xFrameEnd_-xLabelWidth_)/2, height_-labelsHeight_/2,
1286  (xTicsMJD_<=2 && maxX_-minX_<1.0) ?
1287  (*xLabel_+"; "+SgMJD((int)trunc(minX_),0.0).toString(SgMJD::F_Date)) :
1288  *xLabel_);
1289  else
1290  painter->drawText((xFrameBegin_+xFrameEnd_-xLabelWidth_)/2, height_-labelsHeight_/2,
1291  isXTicsBiased_ ? (*xLabel_+QString().sprintf(", %.16g +",xTicsBias_)) :
1292  *xLabel_);
1293  // Y Label:
1294  painter->save();
1295  painter->rotate(270);
1296  painter->drawText(-(yFrameEnd_+yFrameBegin_+yLabelWidth_)/2, 3*labelsHeight_/2,
1297  isYTicsBiased_ ? (*yLabel_+QString().sprintf(", %.16g +",yTicsBias_)) : *yLabel_);
1298  painter->restore();
1299 
1300  // frames:
1301  painter->setPen(*framePen_);
1302  painter->drawLine(xFrameBegin_, yFrameEnd_, xFrameEnd_, yFrameEnd_);
1303  painter->drawLine(xFrameEnd_, yFrameEnd_, xFrameEnd_, yFrameBegin_);
1304  painter->drawLine(xFrameEnd_, yFrameBegin_, xFrameBegin_, yFrameBegin_);
1305  painter->drawLine(xFrameBegin_, yFrameBegin_, xFrameBegin_, yFrameEnd_);
1306 };
1307 
1308 
1309 
1310 //
1311 void SgPlotArea::drawYTics(QPainter* painter)
1312 {
1313  QString Str;
1314  int ticAlignFlag = (yStepP_<0) ? Qt::AlignLeft : Qt::AlignRight;
1315  double dy = 0.0;
1316  int yTic = 0, i;
1317  //if (MaxY*MinY<0.0) // there is "0":
1318  if ((maxY_+yTicsStep_/3.0)*(minY_-yTicsStep_/3.0) < 0.0) // there is "0":
1319  {
1320  painter->setPen(*zeroPen_);
1321  dy = 0.0;
1322  yTic = calcY(dy);
1323  painter->drawLine(xFrameBegin_+1, yTic, xFrameEnd_-1, yTic);
1324  painter->setPen(*framePen_);
1325  while (dy <= maxY_)
1326  {
1327  if ((yTic=calcY(dy))>yFrameBegin_+3 && yTic<yFrameEnd_-3)
1328  {
1329  Str.sprintf("%.8g", dy);
1330  painter->setPen(*ticLinesPen_);
1331  painter->drawLine(xFrameBegin_, yTic, xFrameEnd_, yTic);
1332  painter->setPen(*framePen_);
1333  painter->drawLine(xFrameEnd_, yTic, xFrameEnd_-10, yTic);
1334  painter->drawLine(xFrameBegin_, yTic, xFrameBegin_+10, yTic);
1335  painter->drawText(xFrameBegin_-yTicsWidth_-10, yTic-labelsHeight_/2,
1336  yTicsWidth_, labelsHeight_, ticAlignFlag, Str);
1337  };
1338  for (i=0; i<9; i++)
1339  if ((yTic = calcY(dy + yTicsStep_*(i+1)/10.0))>yFrameBegin_+3 && yTic<yFrameEnd_-3)
1340  {
1341  painter->drawLine(xFrameEnd_, yTic, xFrameEnd_ - ((i!=4) ? 3 : 6), yTic);
1342  painter->drawLine(xFrameBegin_, yTic, xFrameBegin_+ ((i!=4) ? 4 : 7), yTic);
1343  };
1344  dy += yTicsStep_;
1345  };
1346  for (i=0; i<9; i++)
1347  if ((yTic = calcY(-yTicsStep_*(i+1)/10.0))<yFrameEnd_-3 && yTic>yFrameBegin_+3)
1348  {
1349  painter->drawLine(xFrameEnd_, yTic, xFrameEnd_ - ((i!=4) ? 3 : 6), yTic);
1350  painter->drawLine(xFrameBegin_, yTic, xFrameBegin_+ ((i!=4) ? 4 : 7), yTic);
1351  };
1352  dy =- yTicsStep_;
1353  while (dy >= minY_)
1354  {
1355  if ((yTic=calcY(dy))<yFrameEnd_-3 && yTic>yFrameBegin_+3)
1356  {
1357  Str.sprintf("%.8g", dy);
1358  painter->setPen(*ticLinesPen_);
1359  painter->drawLine(xFrameBegin_, yTic, xFrameEnd_, yTic);
1360  painter->setPen(*framePen_);
1361  painter->drawLine(xFrameEnd_, yTic, xFrameEnd_-10, yTic);
1362  painter->drawLine(xFrameBegin_, yTic, xFrameBegin_+10, yTic);
1363  painter->drawText(xFrameBegin_-yTicsWidth_-10, yTic-labelsHeight_/2,
1364  yTicsWidth_, labelsHeight_, ticAlignFlag, Str);
1365  };
1366  for (i=0; i<9; i++)
1367  if ((yTic = calcY(dy - yTicsStep_*(i+1)/10.0))<yFrameEnd_-3 && yTic>yFrameBegin_+3)
1368  {
1369  painter->drawLine(xFrameEnd_, yTic, xFrameEnd_ - ((i!=4) ? 3 : 6), yTic);
1370  painter->drawLine(xFrameBegin_, yTic, xFrameBegin_+ ((i!=4) ? 4 : 7), yTic);
1371  };
1372  dy -= yTicsStep_;
1373  };
1374  }
1375  else
1376  {
1377  // define the origin:
1378  double y_0 = yTicsStep_*floor((yFrameBegin_+3-f_Ay_)/f_By_/yTicsStep_);
1379  dy = y_0;
1380  while (dy > (yFrameEnd_-3-f_Ay_)/f_By_) // down from the origin:
1381  {
1382  yTic = calcY(dy);
1383  Str.sprintf("%.8g", isYTicsBiased_ ? dy-yTicsBias_ : dy);
1384  painter->setPen(*ticLinesPen_);
1385  painter->drawLine(xFrameBegin_, yTic, xFrameEnd_, yTic);
1386  painter->setPen(*framePen_);
1387  painter->drawLine(xFrameEnd_, yTic, xFrameEnd_-10, yTic);
1388  painter->drawLine(xFrameBegin_, yTic, xFrameBegin_+10, yTic);
1389  painter->drawText(xFrameBegin_-yTicsWidth_-10, yTic-labelsHeight_/2,
1390  yTicsWidth_, labelsHeight_, ticAlignFlag, Str);
1391  for (i=0; i<9; i++)
1392  if ((yTic = calcY(dy - yTicsStep_*(i+1)/10.0)) < yFrameEnd_-3)
1393  {
1394  painter->drawLine(xFrameEnd_, yTic, xFrameEnd_ - ((i!=4) ? 3 : 6), yTic);
1395  painter->drawLine(xFrameBegin_, yTic, xFrameBegin_+ ((i!=4) ? 4 : 7), yTic);
1396  };
1397  dy -= yTicsStep_;
1398  };
1399  for (i=0; i<9; i++) // draw upward from the origin:
1400  if ((yTic = calcY(y_0 + yTicsStep_*(i+1)/10.0)) > yFrameBegin_+3)
1401  {
1402  painter->drawLine(xFrameEnd_, yTic, xFrameEnd_ - ((i!=4) ? 3 : 6), yTic);
1403  painter->drawLine(xFrameBegin_, yTic, xFrameBegin_+ ((i!=4) ? 4 : 7), yTic);
1404  };
1405  };
1406 };
1407 
1408 
1409 
1410 //
1411 void SgPlotArea::drawXTics(QPainter* painter)
1412 {
1413  QString Str;
1414  double dx = 0.0;
1415  int xTic = 0, i;
1416  int ticAlignFlag = Qt::AlignCenter;
1417 
1418  if (maxX_*minX_<0.0) // there is "0":
1419  {
1420  dx = 0.0;
1421  painter->setPen(*zeroPen_);
1422  xTic = calcX(dx);
1423  painter->drawLine(xTic, yFrameBegin_+1, xTic, yFrameEnd_-1);
1424  painter->setPen(*framePen_);
1425  while (dx <= maxX_)
1426  {
1427  xTic = calcX(dx);
1428  Str.sprintf("%.8g", dx);
1429  painter->setPen(*ticLinesPen_);
1430  painter->drawLine(xTic, yFrameBegin_, xTic, yFrameEnd_);
1431  painter->setPen(*framePen_);
1432  painter->drawLine(xTic, yFrameEnd_, xTic, yFrameEnd_ -10);
1433  painter->drawLine(xTic, yFrameBegin_, xTic, yFrameBegin_+10);
1434  painter->drawText(xTic-xTicsWidth_/2, yFrameEnd_+labelsHeight_/2,
1435  xTicsWidth_, labelsHeight_, ticAlignFlag, Str);
1436  for (i=0; i<9; i++)
1437  if ((xTic=calcX(dx + xTicsStep_*(i+1)/10.0)) < xFrameEnd_-3)
1438  {
1439  painter->drawLine(xTic, yFrameEnd_, xTic, yFrameEnd_ - ((i!=4) ? 3 : 6));
1440  painter->drawLine(xTic, yFrameBegin_, xTic, yFrameBegin_+ ((i!=4) ? 4 : 7));
1441  };
1442  dx += xTicsStep_;
1443  };
1444  for (i=0; i<9; i++)
1445  if ((xTic=calcX(-xTicsStep_*(i+1)/10.0)) > xFrameBegin_+3)
1446  {
1447  painter->drawLine(xTic, yFrameEnd_, xTic, yFrameEnd_ - ((i!=4) ? 3 : 6));
1448  painter->drawLine(xTic, yFrameBegin_, xTic, yFrameBegin_+ ((i!=4) ? 4 : 7));
1449  };
1450  dx =- xTicsStep_;
1451  while (dx >= minX_)
1452  {
1453  xTic = calcX(dx);
1454  Str.sprintf("%.8g", dx);
1455  painter->setPen(*ticLinesPen_);
1456  painter->drawLine(xTic, yFrameBegin_, xTic, yFrameEnd_);
1457  painter->setPen(*framePen_);
1458  painter->drawLine(xTic, yFrameEnd_, xTic, yFrameEnd_ -10);
1459  painter->drawLine(xTic, yFrameBegin_, xTic, yFrameBegin_+10);
1460  painter->drawText(xTic-xTicsWidth_/2, yFrameEnd_+labelsHeight_/2,
1461  xTicsWidth_, labelsHeight_, ticAlignFlag, Str);
1462  for (i=0; i<9; i++)
1463  if ((xTic=calcX(dx-xTicsStep_*(i+1)/10.0)) > xFrameBegin_+3)
1464  {
1465  painter->drawLine(xTic, yFrameEnd_, xTic, yFrameEnd_ - ((i!=4) ? 3 : 6));
1466  painter->drawLine(xTic, yFrameBegin_, xTic, yFrameBegin_+ ((i!=4) ? 4 : 7));
1467  };
1468  dx -= xTicsStep_;
1469  };
1470  }
1471  else
1472  {
1473  // define the origin:
1474  double x_0=xTicsStep_*floor((xFrameEnd_-3-f_Ax_)/f_Bx_/xTicsStep_);
1475  dx = x_0;
1476  while (dx > (xFrameBegin_-f_Ax_)/f_Bx_) // down from the origin:
1477  {
1478  xTic = calcX(dx);
1479  Str.sprintf("%.8g", isXTicsBiased_? dx-xTicsBias_ : dx);
1480  painter->setPen(*ticLinesPen_);
1481  painter->drawLine(xTic, yFrameBegin_, xTic, yFrameEnd_);
1482  painter->setPen(*framePen_);
1483  painter->drawLine(xTic, yFrameEnd_, xTic, yFrameEnd_ -10);
1484  painter->drawLine(xTic, yFrameBegin_, xTic, yFrameBegin_+10);
1485  painter->drawText(xTic-xTicsWidth_/2, yFrameEnd_+labelsHeight_/2,
1486  xTicsWidth_, labelsHeight_, ticAlignFlag, Str);
1487  for (i=0; i<9; i++)
1488  if ((xTic=calcX(dx-xTicsStep_*(i+1)/10.0)) > xFrameBegin_+3)
1489  {
1490  painter->drawLine(xTic, yFrameEnd_, xTic, yFrameEnd_ - ((i!=4) ? 3 : 6));
1491  painter->drawLine(xTic, yFrameBegin_, xTic, yFrameBegin_+ ((i!=4) ? 4 : 7));
1492  };
1493  dx -= xTicsStep_;
1494  };
1495  for (i=0; i<9; i++) // draw upward from the origin:
1496  if ((xTic=calcX(x_0+xTicsStep_*(i+1)/10.0)) < xFrameEnd_-3)
1497  {
1498  painter->drawLine(xTic, yFrameEnd_, xTic, yFrameEnd_ - ((i!=4) ? 3 : 6));
1499  painter->drawLine(xTic, yFrameBegin_, xTic, yFrameBegin_+ ((i!=4) ? 4 : 7));
1500  };
1501  };
1502 };
1503 
1504 
1505 
1506 //
1507 void SgPlotArea::drawXmjdTics(QPainter* painter)
1508 {
1509  QString Str;
1510  SgMJD dt;
1511  SgMJD D0((int)trunc(minX_)+1, 0.0); // here is the next midnight of the epoch of the MinX
1512  QFontMetrics fm(painter->fontMetrics());
1513  double tmp;
1514  int tTic=0, i;
1515  int ss=2, tw=0;
1516  int ticAlignFlag=Qt::AlignCenter;
1517  int n4SubTic;
1518 
1519  switch (xTicsMJD_)
1520  {
1521  case 0: // XTicsStep in seconds:
1522  D0 = SgMJD((int)trunc(minX_), 0.0);
1523  D0 += xTicsStep_/86400.0*
1524  trunc((SgMJD((xFrameBegin_ + 3 - f_Ax_)/f_Bx_) - D0)/(xTicsStep_/86400.0));
1525  dt = D0;
1526  ss = 5;
1527  n4SubTic = 20;
1528  while (dt.toDouble() < (xFrameEnd_-3-f_Ax_)/f_Bx_) // upward from the origin:
1529  {
1530  tTic = calcX(dt.toDouble());
1531  if ( modf(dt.toDouble(), &tmp)*86400.0 < 0.1)
1532  {
1533  Str = SgMJD(tmp).toString(SgMJD::F_Date);
1534  painter->setPen(*zeroPen_);
1535  painter->drawLine(tTic, yFrameBegin_+1, tTic, yFrameEnd_-1);
1536  painter->setPen(*framePen_);
1537  }
1538  else
1539  {
1540  Str = SgMJD(dt).toString(SgMJD::F_Time);
1541  painter->setPen(*ticLinesPen_);
1542  painter->drawLine(tTic, yFrameBegin_+1, tTic, yFrameEnd_-1);
1543  painter->setPen(*framePen_);
1544  };
1545 
1546  if (tTic > xFrameBegin_+3)
1547  {
1548  tw = fm.width(Str);
1549  painter->drawLine(tTic, yFrameEnd_, tTic, yFrameEnd_ -10);
1550  painter->drawLine(tTic, yFrameBegin_, tTic, yFrameBegin_+10);
1551  painter->drawText(tTic-tw/2, yFrameEnd_+labelsHeight_/2,
1552  tw, labelsHeight_, ticAlignFlag, Str);
1553  };
1554  for (i=0; i<n4SubTic-1; i++)
1555  if ((tTic = calcX(dt.toDouble() + xTicsStep_/86400.0*(i+1)/n4SubTic))<xFrameEnd_-3 &&
1556  tTic>xFrameBegin_+3)
1557  {
1558  painter->drawLine(tTic, yFrameEnd_, tTic, yFrameEnd_ - (((i+1)%ss)?3:6));
1559  painter->drawLine(tTic, yFrameBegin_, tTic, yFrameBegin_+ (((i+1)%ss)?4:7));
1560  };
1561  dt += xTicsStep_/86400.0;
1562  };
1563  for (i=0; i<n4SubTic-1; i++)
1564  if ((tTic = calcX(D0.toDouble() - xTicsStep_/86400.0*(i+1)/n4SubTic))>xFrameBegin_+3 &&
1565  tTic>xFrameBegin_+3)
1566  {
1567  painter->drawLine(tTic, yFrameEnd_, tTic, yFrameEnd_ - (((i+1)%ss)?3:6));
1568  painter->drawLine(tTic, yFrameBegin_, tTic, yFrameBegin_+ (((i+1)%ss)?4:7));
1569  };
1570  dt = D0 - xTicsStep_/86400.0;
1571  while (dt.toDouble() > (xFrameBegin_+3-f_Ax_)/f_Bx_) // downward from the origin:
1572  {
1573  tTic = calcX(dt.toDouble());
1574  if ( modf(dt.toDouble(), &tmp)*86400.0 < 0.3)
1575  {
1576  Str = SgMJD(tmp).toString(SgMJD::F_Date);
1577  painter->setPen(*zeroPen_);
1578  painter->drawLine(tTic, yFrameBegin_+1, tTic, yFrameEnd_-1);
1579  painter->setPen(*framePen_);
1580  }
1581  else
1582  {
1583  Str = SgMJD(dt).toString(SgMJD::F_Time);
1584  painter->setPen(*ticLinesPen_);
1585  painter->drawLine(tTic, yFrameBegin_+1, tTic, yFrameEnd_-1);
1586  painter->setPen(*framePen_);
1587  };
1588 
1589  tw = fm.width(Str);
1590  painter->drawLine(tTic, yFrameEnd_, tTic, yFrameEnd_ -10);
1591  painter->drawLine(tTic, yFrameBegin_, tTic, yFrameBegin_+10);
1592  painter->drawText(tTic-tw/2, yFrameEnd_+labelsHeight_/2, tw, labelsHeight_,
1593  ticAlignFlag, Str);
1594  for (i=0; i<n4SubTic-1; i++)
1595  if ((tTic = calcX(dt.toDouble() - xTicsStep_/86400.0*(i+1)/n4SubTic))>xFrameBegin_+3 &&
1596  tTic>xFrameBegin_+3)
1597  {
1598  painter->drawLine(tTic, yFrameEnd_, tTic, yFrameEnd_ - (((i+1)%ss)?3:6));
1599  painter->drawLine(tTic, yFrameBegin_, tTic, yFrameBegin_+ (((i+1)%ss)?4:7));
1600  };
1601  dt -= xTicsStep_/86400.0;
1602  };
1603  break;
1604 
1605  case 1: // XTicsStep in minutes:
1606  D0 = SgMJD((int)trunc(minX_), 0.0);
1607  D0+= xTicsStep_/1440.0*trunc((SgMJD((xFrameBegin_ + 3 - f_Ax_)/f_Bx_) - D0)/(xTicsStep_/1440.0));
1608 
1609  dt = D0;
1610  ss = 1;
1611  if (xTicsStep_ >= 50)
1612  {
1613  ss = 5;
1614  n4SubTic = 10;
1615  }
1616  else if (xTicsStep_ >= 30)
1617  {
1618  ss = 10;
1619  n4SubTic = 20;
1620  }
1621  else if (xTicsStep_ == 20)
1622  {
1623  ss = 5;
1624  n4SubTic = 20;
1625  }
1626  else if (xTicsStep_ == 10)
1627  {
1628  ss = 5;
1629  n4SubTic = 10;
1630  }
1631  else if (xTicsStep_ >= 8)
1632  {
1633  ss = 2;
1634  n4SubTic = (int)(ss*xTicsStep_);
1635  }
1636  else
1637  {
1638  ss = 5;
1639  n4SubTic = (int)(ss*xTicsStep_);
1640  };
1641 
1642  while (dt.toDouble() < (xFrameEnd_-3-f_Ax_)/f_Bx_) // upward from the origin:
1643  {
1644  tTic = calcX(dt.toDouble());
1645  if (modf(dt.toDouble(), &tmp)*1440.0 < 0.1)
1646  {
1647  Str = SgMJD(tmp).toString(SgMJD::F_Date);
1648  painter->setPen(*zeroPen_);
1649  painter->drawLine(tTic, yFrameBegin_+1, tTic, yFrameEnd_-1);
1650  painter->setPen(*framePen_);
1651  }
1652  else
1653  {
1654  Str = SgMJD(dt).toString(SgMJD::F_TimeShort);
1655  painter->setPen(*ticLinesPen_);
1656  painter->drawLine(tTic, yFrameBegin_+1, tTic, yFrameEnd_-1);
1657  painter->setPen(*framePen_);
1658  };
1659 
1660  if (tTic > xFrameBegin_+3)
1661  {
1662  tw = fm.width(Str);
1663  painter->drawLine(tTic, yFrameEnd_, tTic, yFrameEnd_ -10);
1664  painter->drawLine(tTic, yFrameBegin_, tTic, yFrameBegin_+10);
1665  painter->drawText(tTic-tw/2, yFrameEnd_+labelsHeight_/2,
1666  tw, labelsHeight_, ticAlignFlag, Str);
1667  };
1668  for (i=0; i<n4SubTic-1; i++)
1669  if ((tTic = calcX(dt.toDouble() + xTicsStep_/1440.0*(i+1)/n4SubTic))<xFrameEnd_-3 &&
1670  tTic>xFrameBegin_+3)
1671  {
1672  painter->drawLine(tTic, yFrameEnd_, tTic, yFrameEnd_ - (((i+1)%ss)?3:6));
1673  painter->drawLine(tTic, yFrameBegin_, tTic, yFrameBegin_+ (((i+1)%ss)?4:7));
1674  };
1675  dt += xTicsStep_/1440.0;
1676  };
1677  for (i=0; i<n4SubTic-1; i++)
1678  if ((tTic = calcX(D0.toDouble() - xTicsStep_/1440.0*(i+1)/n4SubTic))>xFrameBegin_+3 &&
1679  tTic>xFrameBegin_+3)
1680  {
1681  painter->drawLine(tTic, yFrameEnd_, tTic, yFrameEnd_ - (((i+1)%ss)?3:6));
1682  painter->drawLine(tTic, yFrameBegin_, tTic, yFrameBegin_+ (((i+1)%ss)?4:7));
1683  };
1684  dt = D0 - xTicsStep_/1440.0;
1685  while (dt.toDouble() > (xFrameBegin_+3-f_Ax_)/f_Bx_) // downward from the origin:
1686  {
1687  tTic = calcX(dt.toDouble());
1688  if ( modf(dt.toDouble(), &tmp)*1440.0 < 0.1)
1689  {
1690  Str = SgMJD(tmp).toString(SgMJD::F_Date);
1691  painter->setPen(*zeroPen_);
1692  painter->drawLine(tTic, yFrameBegin_+1, tTic, yFrameEnd_-1);
1693  painter->setPen(*framePen_);
1694  }
1695  else
1696  {
1697  Str = SgMJD(dt).toString(SgMJD::F_TimeShort);
1698  painter->setPen(*ticLinesPen_);
1699  painter->drawLine(tTic, yFrameBegin_+1, tTic, yFrameEnd_-1);
1700  painter->setPen(*framePen_);
1701  };
1702 
1703  tw = fm.width(Str);
1704  painter->drawLine(tTic, yFrameEnd_, tTic, yFrameEnd_ -10);
1705  painter->drawLine(tTic, yFrameBegin_, tTic, yFrameBegin_+10);
1706  painter->drawText(tTic-tw/2, yFrameEnd_+labelsHeight_/2,
1707  tw, labelsHeight_, ticAlignFlag, Str);
1708  for (i=0; i<n4SubTic-1; i++)
1709  if ((tTic = calcX(dt.toDouble() - xTicsStep_/1440.0*(i+1)/n4SubTic))>xFrameBegin_+3 &&
1710  tTic>xFrameBegin_+3)
1711  {
1712  painter->drawLine(tTic, yFrameEnd_, tTic, yFrameEnd_ - (((i+1)%ss)?3:6));
1713  painter->drawLine(tTic, yFrameBegin_, tTic, yFrameBegin_+ (((i+1)%ss)?4:7));
1714  };
1715  dt -= xTicsStep_/1440.0;
1716  };
1717  break;
1718 
1719  case 2: // XTicsStep in hours:
1720  dt = D0;
1721  ss = 2;
1722  if (xTicsStep_ < 4)
1723  ss = 3;
1724  if (xTicsStep_ < 3)
1725  ss = 4;
1726  if (xTicsStep_ < 2)
1727  ss = 6;
1728  while (dt.toDouble() < (xFrameEnd_-3-f_Ax_)/f_Bx_) // upward from the origin:
1729  {
1730  tTic = calcX(dt.toDouble());
1731  if ( modf(dt.toDouble(), &tmp)*24.0 < 0.1)
1732  {
1733  Str = SgMJD(tmp).toString(SgMJD::F_Date);
1734  painter->setPen(*zeroPen_);
1735  painter->drawLine(tTic, yFrameBegin_+1, tTic, yFrameEnd_-1);
1736  painter->setPen(*framePen_);
1737  }
1738  else
1739  {
1740  Str = SgMJD(dt).toString(SgMJD::F_TimeShort);
1741  painter->setPen(*ticLinesPen_);
1742  painter->drawLine(tTic, yFrameBegin_+1, tTic, yFrameEnd_-1);
1743  painter->setPen(*framePen_);
1744  };
1745 
1746  tw = fm.width(Str);
1747  painter->drawLine(tTic, yFrameEnd_, tTic, yFrameEnd_ -10);
1748  painter->drawLine(tTic, yFrameBegin_, tTic, yFrameBegin_+10);
1749  painter->drawText(tTic-tw/2, yFrameEnd_+labelsHeight_/2,
1750  tw, labelsHeight_, ticAlignFlag, Str);
1751  for (i=0; i<ss*xTicsStep_-1; i++)
1752  if ((tTic=calcX(dt.toDouble()+xTicsStep_/24.0*(i+1)/(ss*xTicsStep_))) < xFrameEnd_-3)
1753  {
1754  painter->drawLine(tTic, yFrameEnd_, tTic, yFrameEnd_ - (((i+1)%ss)?3:6));
1755  painter->drawLine(tTic, yFrameBegin_, tTic, yFrameBegin_+ (((i+1)%ss)?4:7));
1756  };
1757  dt += xTicsStep_/24.0;
1758  };
1759  for (i=0; i<ss*xTicsStep_-1; i++)
1760  if ((tTic=calcX(D0.toDouble()-xTicsStep_/24.0*(i+1)/(ss*xTicsStep_)))>xFrameBegin_+3 &&
1761  tTic<xFrameEnd_-3)
1762  {
1763  painter->drawLine(tTic, yFrameEnd_, tTic, yFrameEnd_ - (((i+1)%ss)?3:6));
1764  painter->drawLine(tTic, yFrameBegin_, tTic, yFrameBegin_+ (((i+1)%ss)?4:7));
1765  };
1766  dt = D0 - xTicsStep_/24.0;
1767  while (dt.toDouble() > (xFrameBegin_+3-f_Ax_)/f_Bx_) // downward from the origin:
1768  {
1769  tTic = calcX(dt.toDouble());
1770  if ( modf(dt.toDouble(), &tmp)*24.0 < 0.1)
1771  {
1772  Str = SgMJD(tmp).toString(SgMJD::F_Date);
1773  painter->setPen(*zeroPen_);
1774  painter->drawLine(tTic, yFrameBegin_+1, tTic, yFrameEnd_-1);
1775  painter->setPen(*framePen_);
1776  }
1777  else
1778  {
1779  Str = SgMJD(dt).toString(SgMJD::F_TimeShort);
1780  painter->setPen(*ticLinesPen_);
1781  painter->drawLine(tTic, yFrameBegin_+1, tTic, yFrameEnd_-1);
1782  painter->setPen(*framePen_);
1783  };
1784 
1785  tw = fm.width(Str);
1786  painter->drawLine(tTic, yFrameEnd_, tTic, yFrameEnd_ -10);
1787  painter->drawLine(tTic, yFrameBegin_, tTic, yFrameBegin_+10);
1788  painter->drawText(tTic-tw/2, yFrameEnd_+labelsHeight_/2,
1789  tw, labelsHeight_, ticAlignFlag, Str);
1790  for (i=0; i<ss*xTicsStep_-1; i++)
1791  if ((tTic=calcX(dt.toDouble()-xTicsStep_/24.0*(i+1)/(ss*xTicsStep_)))>xFrameBegin_+3 &&
1792  tTic<xFrameEnd_-3)
1793  {
1794  painter->drawLine(tTic, yFrameEnd_, tTic, yFrameEnd_ - (((i+1)%ss)?3:6));
1795  painter->drawLine(tTic, yFrameBegin_, tTic, yFrameBegin_+ (((i+1)%ss)?4:7));
1796  };
1797  dt -= xTicsStep_/24.0;
1798  };
1799  break;
1800 
1801  case 3: // XTicsStep in days:
1802  dt = D0;
1803  ss = 6;
1804  if (xTicsStep_ < 1.0)
1805  ss = 24;
1806  else if (xTicsStep_ < 2)
1807  ss = 12;
1808  else if (xTicsStep_ < 4)
1809  ss = 6;
1810  else if (xTicsStep_ < 6)
1811  ss = 4;
1812  else if (xTicsStep_ < 12)
1813  ss = 2;
1814  else
1815  ss = 1;
1816  while (dt.toDouble() < (xFrameEnd_-3-f_Ax_)/f_Bx_) // upward from the origin:
1817  {
1818  tTic = calcX(dt.toDouble());
1819  if (modf(dt.toDouble(), &tmp)*24.0 < 0.1)
1820  {
1821  Str = SgMJD(tmp).toString(SgMJD::F_Date);
1822  painter->setPen(*zeroPen_);
1823  painter->drawLine(tTic, yFrameBegin_+1, tTic, yFrameEnd_-1);
1824  painter->setPen(*framePen_);
1825  }
1826  else
1827  {
1828  Str = SgMJD(dt).toString(SgMJD::F_TimeShort);
1829  painter->setPen(*ticLinesPen_);
1830  painter->drawLine(tTic, yFrameBegin_+1, tTic, yFrameEnd_-1);
1831  painter->setPen(*framePen_);
1832  };
1833 
1834  tw = fm.width(Str);
1835  painter->drawLine(tTic, yFrameEnd_, tTic, yFrameEnd_ -10);
1836  painter->drawLine(tTic, yFrameBegin_, tTic, yFrameBegin_+10);
1837  painter->drawText(tTic-tw/2, yFrameEnd_+labelsHeight_/2,
1838  tw, labelsHeight_, ticAlignFlag, Str);
1839  for (i=0; i<ss*xTicsStep_-1; i++)
1840  if ((tTic=calcX(dt.toDouble()+xTicsStep_*(i+1)/(ss*xTicsStep_))) < xFrameEnd_-3)
1841  {
1842  painter->drawLine(tTic, yFrameEnd_, tTic, yFrameEnd_ - (((i+1)%ss)?3:6));
1843  painter->drawLine(tTic, yFrameBegin_, tTic, yFrameBegin_+ (((i+1)%ss)?4:7));
1844  };
1845  dt += xTicsStep_;
1846  };
1847  for (i=0; i<ss*xTicsStep_-1; i++)
1848  if ((tTic=calcX(D0.toDouble()-xTicsStep_*(i+1)/(ss*xTicsStep_))) > xFrameBegin_+3)
1849  {
1850  painter->drawLine(tTic, yFrameEnd_, tTic, yFrameEnd_ - (((i+1)%ss)?3:6));
1851  painter->drawLine(tTic, yFrameBegin_, tTic, yFrameBegin_+ (((i+1)%ss)?4:7));
1852  };
1853  dt = D0 - xTicsStep_;
1854  while (dt.toDouble() > (xFrameBegin_+3-f_Ax_)/f_Bx_) // downward from the origin:
1855  {
1856  tTic = calcX(dt.toDouble());
1857  if (modf(dt.toDouble(), &tmp)*24.0 < 0.1)
1858  {
1859  Str = SgMJD(tmp).toString(SgMJD::F_Date);
1860  painter->setPen(*zeroPen_);
1861  painter->drawLine(tTic, yFrameBegin_+1, tTic, yFrameEnd_-1);
1862  painter->setPen(*framePen_);
1863  }
1864  else
1865  {
1866  Str = SgMJD(dt).toString(SgMJD::F_TimeShort);
1867  painter->setPen(*ticLinesPen_);
1868  painter->drawLine(tTic, yFrameBegin_+1, tTic, yFrameEnd_-1);
1869  painter->setPen(*framePen_);
1870  };
1871 
1872  tw = fm.width(Str);
1873  painter->drawLine(tTic, yFrameEnd_, tTic, yFrameEnd_ -10);
1874  painter->drawLine(tTic, yFrameBegin_, tTic, yFrameBegin_+10);
1875  painter->drawText(tTic-tw/2, yFrameEnd_+labelsHeight_/2,
1876  tw, labelsHeight_, ticAlignFlag, Str);
1877  for (i=0; i<ss*xTicsStep_-1; i++)
1878  if ((tTic=calcX(dt.toDouble()-xTicsStep_*(i+1)/(ss*xTicsStep_))) > xFrameBegin_+3)
1879  {
1880  painter->drawLine(tTic, yFrameEnd_, tTic, yFrameEnd_ - (((i+1)%ss)?3:6));
1881  painter->drawLine(tTic, yFrameBegin_, tTic, yFrameBegin_+ (((i+1)%ss)?4:7));
1882  };
1883  dt -= xTicsStep_;
1884  };
1885  break;
1886 
1887  case 4: // XTicsStep in days:
1888  dt = D0;
1889  while (dt.toDouble() < (xFrameEnd_-3-f_Ax_)/f_Bx_) // upward from the origin:
1890  {
1891  tTic = calcX(dt.toDouble());
1892  Str = SgMJD(dt).toString(SgMJD::F_Date);
1893  painter->setPen(*zeroPen_);
1894  painter->drawLine(tTic, yFrameBegin_+1, tTic, yFrameEnd_-1);
1895  painter->setPen(*framePen_);
1896 
1897  tw = fm.width(Str);
1898  painter->drawLine(tTic, yFrameEnd_, tTic, yFrameEnd_ -10);
1899  painter->drawLine(tTic, yFrameBegin_, tTic, yFrameBegin_+10);
1900  painter->drawText(tTic-tw/2, yFrameEnd_+labelsHeight_/2,
1901  tw, labelsHeight_, ticAlignFlag, Str);
1902  for (i=0; i<9; i++)
1903  if ((tTic = calcX(dt.toDouble() + xTicsStep_*(i+1)/(10)))<xFrameEnd_-3)
1904  {
1905  painter->drawLine(tTic, yFrameEnd_, tTic, yFrameEnd_ - (((i+1)%5)?3:6));
1906  painter->drawLine(tTic, yFrameBegin_, tTic, yFrameBegin_+ (((i+1)%5)?4:7));
1907  };
1908  dt += xTicsStep_;
1909  };
1910  for (i=0; i<9; i++)
1911  if ((tTic = calcX(D0.toDouble() - xTicsStep_*(i+1)/10))>xFrameBegin_+3)
1912  {
1913  painter->drawLine(tTic, yFrameEnd_, tTic, yFrameEnd_ - (((i+1)%5)?3:6));
1914  painter->drawLine(tTic, yFrameBegin_, tTic, yFrameBegin_+ (((i+1)%5)?4:7));
1915  };
1916  break;
1917  }; // end of cases
1918 
1919 };
1920 
1921 
1922 
1923 //
1924 void SgPlotArea::drawData(QPainter* painter, const QRect& rect)
1925 {
1926  if (!plotCarrier_->isOK())
1927  return;
1928 
1929  int i, ei;
1930  int dr = 0;
1931 
1932  int limitLeft = std::max(rect.left() - visibleWidth_/2, xFrameBegin_);
1933  int limitRight = std::min(rect.right() + visibleWidth_/2, xFrameEnd_);
1934  int limitTop = std::max(rect.top() - visibleHeight_/2, yFrameBegin_);
1935  int limitBottom= std::min(rect.bottom() + visibleHeight_/2, yFrameEnd_);
1936 
1937  // selection/deselection stuff:
1938  QPoint pointLT; // left top
1939  QPoint pointRB; // right bottom
1940  pointLT.setX(std::min(rulerFromPoint_.x(), rulerToPoint_.x()));
1941  pointLT.setY(std::min(rulerFromPoint_.y(), rulerToPoint_.y()));
1942  pointRB.setX(std::max(rulerFromPoint_.x(), rulerToPoint_.x()));
1943  pointRB.setY(std::max(rulerFromPoint_.y(), rulerToPoint_.y()));
1944 // QRegion selectionRegion(QRect(pointLT, pointRB-QPoint(1,1)), QRegion::Ellipse);
1945  QRegion selectionRegion(QRect(pointLT, pointRB-QPoint(1,1)));
1946  bool selectionRegionIsAPoint = rulerFromPoint_==rulerToPoint_;
1947 
1948  for (i=0; i<plotCarrier_->listOfBranches()->size(); i++)
1949  {
1950  SgPlotBranch *branch = plotCarrier_->listOfBranches()->at(i);
1951  if (branch->getIsBrowsable())
1952  {
1953  painter->setPen(*(branchPens_+i));
1954  painter->setBrush(*(branchBrushes_+i));
1955  bool isFirstPointDrawn = false;
1956  int x=0, y=0;
1957  int prevX=0, prevY=0;
1958  QPoint point;
1959  for (unsigned int j=0; j<branch->data()->nRow(); j++)
1960  if (branch->isPointVisible(j, sets2plot_))
1961  {
1962  int y_u=0;
1963  int y_d=0;
1964  prevX = x;
1965  prevY = y;
1966  x = calcX(branch->data()->getElement(j, xColumn_));
1967  y = calcY(branch->data()->getElement(j, yColumn_));
1968  point.setX(x);
1969  point.setY(y);
1970 // if (xFrameBegin_<=x && x<=xFrameEnd_ && yFrameBegin_<=y && y<=yFrameEnd_)
1971  if (limitLeft<=x && x<=limitRight && limitTop<=y && y<=limitBottom)
1972  {
1973  QRect rect(x-radius_, y-radius_, 2*radius_, 2*radius_);
1974  if (selectionRegionIsAPoint) // special case:
1975  {
1976  selectionRegion.setRects(&rect, 1);
1977  if (selectionRegion.contains(rulerToPoint_))
1979  }
1980  else
1981  {
1982  if (userMode_ == UserMode_SELECTING && selectionRegion.contains(rect))
1984  else if (userMode_ == UserMode_DESELECTING && selectionRegion.contains(rect))
1986  };
1987 
1988  // drawing data with primitives:
1989  // lines:
1990  if (isPlotLines_)
1991  {
1992  if (!isFirstPointDrawn)
1993  isFirstPointDrawn = true;
1994  else
1995  painter->drawLine(prevX, prevY, x, y);
1996  };
1997  // points:
1998  if (isPlotPoints_)
1999  {
2000  dr = 0;
2001  if ((branch->getDataAttr(j) & SgPlotCarrier::DA_SELECTED))
2002  {
2003 // painter->setBrush(Qt::NoBrush);
2004 // painter->setPen(*framePen_);
2005  dr = ddr_;
2006  painter->setBrush(*(branchSelectedBrushes_+i));
2007  painter->setPen(*(branchSelectedPens_+i));
2008  }
2009  else if ( (branch->getDataAttr(j) & SgPlotCarrier::DA_REJECTED) ||
2010  (branch->getDataAttr(j) & SgPlotCarrier::DA_NONUSABLE) )
2011  {
2012  painter->setBrush(*ignoredBrush_);
2013  painter->setPen(*ignoredPen_);
2014  }
2015  else // regular points:
2016  {
2017  painter->setBrush(*(branchBrushes_+i));
2018  painter->setPen(*framePen_);
2019  };
2020  if (branch->getDataAttr(j) & SgPlotCarrier::DA_NONUSABLE)
2021  painter->drawRect(x-radius_-dr, y-radius_-dr, 2*(radius_+dr), 2*(radius_+dr));
2022  else
2023  painter->drawEllipse(QPoint(x,y), radius_+dr,radius_+dr);
2024  painter->setPen(*(branchPens_+i));
2025  };
2026  // error bars (if available):
2028  {
2029  y_u = std::max( calcY(branch->data()->getElement(j, yColumn_) +
2030  branch->data()->getElement(j, ei)), yFrameBegin_);
2031  y_d = std::min( calcY(branch->data()->getElement(j, yColumn_) -
2032  branch->data()->getElement(j, ei)), yFrameEnd_);
2033  painter->drawLine(x, y_u, x, y_d);
2034  };
2035  // impulses:
2036  if (isPlotImpulses_)
2037  {
2038  if (branch->data()->getElement(j, yColumn_) > 0.0)
2039  {
2040  y_u = calcY(branch->data()->getElement(j, yColumn_));
2041  y_d = std::min(calcY(0.0), yDataEnd_);
2042  }
2043  else
2044  {
2045  y_u = std::max(calcY(0.0), yDataBegin_);
2046  y_d = calcY(branch->data()->getElement(j, yColumn_));
2047  };
2048  painter->drawLine(x, y_u, x, y_d);
2049  };
2050  };
2051 
2052  // draw bars:
2053  if (branch->getDataAttr(j) & SgPlotCarrier::DA_BAR &&
2054  yFrameBegin_<=y && y<=yFrameEnd_)
2055  {
2056  painter->setPen(*barPen_);
2057  painter->drawLine(x, yDataBegin_, x, yDataEnd_);
2058  painter->setPen(*(branchPens_+i));
2059  };
2060  };
2061  };
2062  };
2063  painter->setBrush(Qt::NoBrush);
2064 };
2065 
2066 
2067 
2068 //
2069 void SgPlotArea::queryPoint(const QPoint& queryPoint, SgPlotBranch*& queryBranch, int &queryIdx)
2070 {
2071  double d, minD;
2072  double leftLimit, rightLimit, topLimit, bottomLimit;
2073  double queryX, queryY;
2074  double x, y;
2075 
2076  queryX = queryPoint.x();
2077  queryY = queryPoint.y();
2078 
2079  // a window for lookup:
2080  leftLimit = queryPoint.x() - 5*radius_;
2081  rightLimit = queryPoint.x() + 5*radius_;
2082  topLimit = queryPoint.y() - 5*radius_;
2083  bottomLimit = queryPoint.y() + 5*radius_;
2084 
2085  // initial values:
2086  minD = sqrt((rightLimit-leftLimit)*(rightLimit-leftLimit) +
2087  (bottomLimit-topLimit)*(bottomLimit-topLimit));
2088  queryBranch = NULL;
2089  queryIdx = -1;
2090 
2091  if (!plotCarrier_->isOK())
2092  return;
2093 
2094 //for (int i=0; i<plotCarrier_->listOfBranches()->size(); i++)
2095  for (int i=plotCarrier_->listOfBranches()->size()-1; 0<=i; i--) // search from the back
2096  {
2097  SgPlotBranch *branch = plotCarrier_->listOfBranches()->at(i);
2098  if (branch->getIsBrowsable())
2099  for (unsigned int j=0; j<branch->data()->nRow(); j++)
2100  if (branch->isPointVisible(j, sets2plot_))
2101  {
2102  x = calcX(branch->data()->getElement(j, xColumn_));
2103  y = calcY(branch->data()->getElement(j, yColumn_));
2104  if (leftLimit<=x && x<=rightLimit && topLimit<=y && y<=bottomLimit)
2105  {
2106  d = sqrt( (x-queryX)*(x-queryX) + (y-queryY)*(y-queryY) );
2107  if (minD > d)
2108  {
2109  queryBranch = branch;
2110  queryIdx = j;
2111  minD = d;
2112  };
2113  };
2114  };
2115  };
2116  if (queryBranch)
2118  ": query successful for [" + queryBranch->getName() + "] branch, point# " +
2119  QString().setNum(queryIdx));
2120 };
2121 
2122 
2123 
2124 //
2125 void SgPlotArea::output4Files(const QString& path)
2126 {
2127  bool isOutputDirExists(false);
2128  if (!path.isEmpty())
2129  {
2130  bool isOk(true);
2131  QDir d(path);
2132  if (!d.exists())
2133  isOk = d.mkpath("./"); // Qt, wtf?
2134  else
2135  isOutputDirExists = true;
2136  if (!isOk)
2138  ": cannot create directory " + path);
2139  else
2140  isOutputDirExists = true;
2141  };
2142 
2143  QString fileName = plotCarrier_->getFile2SaveBaseName()
2144  + QString("").sprintf("[%u:%u]", xColumn_, yColumn_);
2145 
2146  if (isOutputDirExists)
2147  fileName = path + "/" + fileName;
2148 
2149  QString buff;
2150  QFile f;
2151  QTextStream s;
2152  int ei;
2153  for (int i=0; i<plotCarrier_->listOfBranches()->size(); i++)
2154  {
2155  SgPlotBranch *branch = plotCarrier_->listOfBranches()->at(i);
2156  if (branch->getIsBrowsable())
2157  {
2158  f.setFileName(fileName + QString("").sprintf("_%03d.dat", i));
2159  if (f.open(QIODevice::WriteOnly))
2160  {
2161  s.setDevice(&f);
2162  s << "# " << branch->getName() << "\n";
2163  s << "# X: [" << qPrintable(*xLabel_) << "]\n";
2164  s << "# Y: [" << qPrintable(*yLabel_) << "]\n";
2165 
2166  for (unsigned int j=0; j<branch->data()->nRow(); j++)
2167  if (branch->isPointVisible(j, sets2plot_))
2168  {
2169  s << QString().sprintf("%24.12f %24.12f ",
2170  branch->data()->getElement(j, xColumn_), branch->data()->getElement(j, yColumn_));
2171  if ((ei=plotCarrier_->getStdVarIdx(yColumn_)) != -1)
2172  s << QString().sprintf(" %24.12f ", branch->data()->getElement(j, ei));
2173  if (isXTicsMJD_)
2174  s << " "
2176  s << "\n";
2177  };
2178  logger->write(SgLogger::DBG, SgLogger::IO_TXT, className() + " output4Files(): the data '" +
2179  plotCarrier_->getName(yColumn_) + "' has been saved to the file " + f.fileName());
2180  f.close();
2181  s.setDevice(NULL);
2182  }
2183  else
2185  ": output4Files(): cannot open the file " + f.fileName() + " for writing");
2186  };
2187  };
2188 };
2189 
2190 
2191 
2192 void SgPlotArea::output4Print(QPainter *prnPainter, int width, int height, int radius, int ddr,
2193  int fontSize)
2194 {
2195  int widthSaved(width_);
2196  int heightSaved(height_);
2197  int radiusSaved(radius_);
2198  int ddrSaved(ddr_);
2199  QFont font=QApplication::font();
2200 
2201 //font.setPointSize(12);
2202  font.setPointSize(fontSize);
2203  prnPainter->setFont(font);
2204 
2205  width_ = width;
2206  height_ = height;
2207 
2208  radius_ = radius;
2209  ddr_ = ddr;
2210  drawWholePlot(prnPainter, QRect(0, 0, width_, height_));
2211 
2212  width_ = widthSaved;
2213  height_ = heightSaved;
2214  radius_ = radiusSaved;
2215  ddr_ = ddrSaved;
2216 };
2217 /*=====================================================================================================*/
2218 
2219 
2220 
2221 
2222 
2223 /*=======================================================================================================
2224 *
2225 * SgPlot:
2226 *
2227 *======================================================================================================*/
2228 const double SgPlot::scaleFactor_ = M_2_SQRTPI; // it's a "right" scale factor: 2/sqrt(pi)
2229 SgPlot::SgPlot(SgPlotCarrier* plotCarrier, const QString& pth2outpt,
2230  QWidget *parent, unsigned int modes)
2231  : QWidget(parent),
2232  path2Outputs_(pth2outpt),
2233  filterActions_(),
2234  filterAuxActions_(),
2235  filterExtActions_(),
2236  extKeys_()
2237 {
2238  lvExtKeys_ = NULL;
2239 
2240  scaleX_ = 1.0;
2241  scaleY_ = 1.0;
2242 
2244 
2245  // limits for zoomin and zoomout; could be changed later
2246  maxZoomX_ = 40.0;
2247  minZoomX_ = 0.5;
2248  maxZoomY_ = 40.0;
2249  minZoomY_ = 0.5;
2250 
2251  modes_ = modes;
2252 
2253  // user actions:
2254  // isScrolling_ = false;
2255 
2256  plotCarrier_ = plotCarrier;
2257  if (!plotCarrier_->selfCheck())
2259  "::selfCheck() for [" + plotCarrier_->getName() + "] failed");
2260 
2261 
2262  if (modes_ & PM_EXT_KEY_SELECT)
2263  {
2264  extKeys_.clear();
2265  QMap<QString, QString> keyByKey;
2266  for (int i=0; i<plotCarrier_->listOfBranches()->size(); i++)
2267  {
2269  if (pb->hasExtKeys())
2270  for (uint j=0; j<pb->numOfRows(); j++)
2271  if (!keyByKey.contains(pb->getExtKey(j)))
2272  keyByKey.insert(pb->getExtKey(j), pb->getExtKey(j));
2273  };
2274  extKeys_ = keyByKey.keys();
2275  keyByKey.clear();
2276  };
2277 
2278 
2279 
2280  area_ = new SgPlotArea(plotCarrier_, this);
2281  area_->setBackgroundRole(QPalette::Base);
2282  area_->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
2283 
2284  plotScroller_ = new SgPlotScroller(this);
2285  plotScroller_->setBackgroundRole(QPalette::Dark);
2286  plotScroller_->setWidget(area_);
2287  plotScroller_->setAlignment(Qt::AlignCenter);
2288  plotScroller_->setFrameStyle(QFrame::Panel | QFrame::Sunken);
2289  plotScroller_->setLineWidth(2);
2290 
2291  // interaction with a user:
2292  connect(plotScroller_, SIGNAL(mouseWheelRotated(QWheelEvent*)),
2293  SLOT(processWheelEvent(QWheelEvent*)));
2294  connect(plotScroller_, SIGNAL(mousePressed(QMouseEvent*)),
2295  SLOT(processMousePressEvent(QMouseEvent*)));
2296  connect(plotScroller_, SIGNAL(mouseMoved(QMouseEvent*)),
2297  SLOT(processMouseMoveEvent(QMouseEvent*)));
2298  connect(plotScroller_, SIGNAL(mouseReleased(QMouseEvent*)),
2299  SLOT(processMouseReleaseEvent(QMouseEvent*)));
2300  connect(plotScroller_, SIGNAL(mouseDoubleClicked(QMouseEvent*)),
2301  SLOT(processMouseDoubleClickEvent(QMouseEvent*)));
2302 /*
2303  connect(plotScroller_, SIGNAL(keyPressed(QKeyEvent*)),
2304  SLOT(processKeyPressEvent(QKeyEvent*)));
2305  connect(plotScroller_, SIGNAL(keyReleased(QKeyEvent*)),
2306  SLOT(processKeyReleaseEvent(QKeyEvent*)));
2307 */
2308  zoomInAction_ = new QAction(tr("Zoom &In"), this);
2309  zoomInAction_->setShortcut(tr("Ctrl++"));
2310  connect(zoomInAction_, SIGNAL(triggered()), SLOT(zoomIn()));
2311  addAction(zoomInAction_);
2312 
2313  zoomOutAction_ = new QAction(tr("Zoom &Out"), this);
2314  zoomOutAction_->setShortcut(tr("Ctrl+-"));
2315  connect(zoomOutAction_, SIGNAL(triggered()), this, SLOT(zoomOut()));
2316  addAction(zoomOutAction_);
2317 
2318  zoomXInAction_ = new QAction(tr("Zoom In X-axis"), this);
2319  zoomXInAction_->setShortcut(Qt::CTRL + Qt::Key_Right);
2320  connect(zoomXInAction_, SIGNAL(triggered()), this, SLOT(zoomXIn()));
2321  addAction(zoomXInAction_);
2322 
2323  zoomYInAction_ = new QAction(tr("Zoom In Y-axis"), this);
2324  zoomYInAction_->setShortcut(Qt::CTRL + Qt::Key_Up);
2325  connect(zoomYInAction_, SIGNAL(triggered()), this, SLOT(zoomYIn()));
2326  addAction(zoomYInAction_);
2327 
2328  zoomXOutAction_ = new QAction(tr("Zoom Out X-axis"), this);
2329  zoomXOutAction_->setShortcut(Qt::CTRL + Qt::Key_Left);
2330  connect(zoomXOutAction_, SIGNAL(triggered()), this, SLOT(zoomXOut()));
2331  addAction(zoomXOutAction_);
2332 
2333  zoomYOutAction_ = new QAction(tr("Zoom Out Y-axis"), this);
2334  zoomYOutAction_->setShortcut(Qt::CTRL + Qt::Key_Down);
2335  connect(zoomYOutAction_, SIGNAL(triggered()), this, SLOT(zoomYOut()));
2336  addAction(zoomYOutAction_);
2337 
2338  normalSizeAction_= new QAction(tr("Set normal size"), this);
2339  normalSizeAction_->setShortcut(tr("Ctrl+*"));
2340  connect(normalSizeAction_, SIGNAL(triggered()), this, SLOT(zoomNormalView()));
2341  addAction(normalSizeAction_);
2342 
2343  if (modes_ & PM_HAS_HAVE_ZERO)
2344  area_->setHave2HasZero(true);
2345 
2346  QBoxLayout *mainLayout = new QHBoxLayout(this);
2347 
2348  if (modes_ & PM_EXT_KEY_SELECT)
2349  {
2350  QStringListModel *model=new QStringListModel();
2351  QStringList list;
2352  lvExtKeys_ = new QListView(this);
2353  for (int i=0; i<extKeys_.size(); i++)
2354  list << extKeys_.at(i);
2355  model->setStringList(list);
2356  lvExtKeys_->setModel(model);
2357 
2358  lvExtKeys_->setSelectionMode(QAbstractItemView::MultiSelection);
2359  lvExtKeys_->setEditTriggers (QAbstractItemView::NoEditTriggers);
2360  lvExtKeys_->setUniformItemSizes(true);
2361  lvExtKeys_->selectAll();
2363 
2364  connect(lvExtKeys_->selectionModel(),
2365  SIGNAL(selectionChanged(const QItemSelection, const QItemSelection)), SLOT(extKeyChanged()));
2366 
2367  //lvExtKeys_->setMinimumWidth(24 + lvExtKeys_->sizeHintForColumn(0));
2368  //lvExtKeys_->setMaximumHeight(9*lvExtKeys_->sizeHintForRow(0));
2369 
2370  QHBoxLayout *layoutH = new QHBoxLayout;
2371  layoutH->setSpacing(0);
2372  QPushButton *allPlus = new QPushButton("*+", this);
2373  QPushButton *prevKey = new QPushButton("<<", this);
2374  QPushButton *nextKey = new QPushButton(">>", this);
2375  QPushButton *allMinus= new QPushButton("-*", this);
2376  QSize btnSize = allPlus->fontMetrics().size(Qt::TextSingleLine, ">>");
2377 
2378  //btnSize += QSize(12,8);
2379  btnSize += QSize(8,4);
2380  allPlus ->setFixedSize(btnSize);
2381  allMinus->setFixedSize(btnSize);
2382  prevKey ->setFixedSize(btnSize);
2383  nextKey ->setFixedSize(btnSize);
2384 
2385  layoutH->addWidget(allMinus);
2386  layoutH->addStretch(1);
2387  layoutH->addWidget(prevKey);
2388  layoutH->addWidget(nextKey);
2389  layoutH->addStretch(1);
2390  layoutH->addWidget(allPlus);
2391 
2392  connect(allPlus, SIGNAL(clicked()), SLOT(markAllExtKeysAsSelected()));
2393  connect(allMinus, SIGNAL(clicked()), SLOT(markAllExtKeysAsDeselected()));
2394  connect(prevKey, SIGNAL(clicked()), SLOT(markPrevExtKey()));
2395  connect(nextKey, SIGNAL(clicked()), SLOT(markNextExtKey()));
2396  QVBoxLayout *layoutV = new QVBoxLayout;
2397  layoutV->setSpacing(0);
2398  layoutV->addLayout(layoutH);
2399  layoutV->addWidget(lvExtKeys_, 1);
2400  mainLayout->addLayout(layoutV, 0);
2401  };
2402  //
2403  QBoxLayout *layout = new QVBoxLayout;
2404  mainLayout->addLayout(layout, 5);
2405 
2406  layout->addWidget(plotScroller_, 5);
2407  layout->addWidget(control());
2408  mainLayout->activate();
2409  setLayout(mainLayout);
2410 
2411  currentKeyModifier_ = 0;
2412 };
2413 
2414 
2415 
2416 //
2418 {
2419  if (zoomOutAction_)
2420  {
2421  delete zoomOutAction_;
2422  zoomOutAction_ = NULL;
2423  };
2424 
2425  if (zoomInAction_)
2426  {
2427  delete zoomInAction_;
2428  zoomInAction_ = NULL;
2429  };
2430 
2431  if (area_)
2432  {
2433  delete area_;
2434  area_ = NULL;
2435  };
2436  filterActions_.clear();
2437  filterAuxActions_.clear();
2438  filterExtActions_.clear();
2439  extKeys_.clear();
2440 };
2441 
2442 
2443 
2444 //
2446 {
2447  QGridLayout *grid;
2448  QLabel *label;
2449  QGroupBox *gBox;
2450  QBoxLayout *layout, *aLayout;
2451  QPushButton *button;
2452  QSlider *slider;
2453  unsigned int i;
2454 
2455  controls_ = new QFrame(this);
2456  layout = new QHBoxLayout(controls_);
2457 
2458  // axis selection:
2459  if (!(modes_ & PM_WO_AXIS_NAMES))
2460  {
2461  aLayout = new QVBoxLayout;
2462  layout->addLayout(aLayout);
2463 
2464  gBox = new QGroupBox("Axis to plot", controls_);
2465  grid = new QGridLayout(gBox);
2466 
2467  label = new QLabel("X:", gBox);
2468  label -> setMinimumSize(label->sizeHint());
2469  grid -> addWidget(label, 0,0, Qt::AlignLeft | Qt::AlignVCenter);
2470 
2471  label = new QLabel("Y:", gBox);
2472  label -> setMinimumSize(label->sizeHint());
2473  grid -> addWidget(label, 1,0, Qt::AlignLeft | Qt::AlignVCenter);
2474 
2475  cbXAxis_ = new QComboBox(gBox);
2476  cbXAxis_->setInsertPolicy(QComboBox::InsertAtBottom);
2477  cbYAxis_ = new QComboBox(gBox);
2478  cbYAxis_->setInsertPolicy(QComboBox::InsertAtBottom);
2479 
2480  for (i=0; i<(unsigned int)(plotCarrier_->numOfColumns()-1); i++)
2481  {
2482  cbXAxis_->insertItem(i, *plotCarrier_->columnNames()->at(i));
2483  cbYAxis_->insertItem(i, *plotCarrier_->columnNames()->at(i));
2484  };
2485  // set defaults:
2486  cbXAxis_->setCurrentIndex(0);
2487  cbYAxis_->setCurrentIndex(plotCarrier_->numOfColumns()>1?1:0);
2488  connect(cbXAxis_, SIGNAL(highlighted(int)), SLOT(changeXaxisTemp(int)));
2489  connect(cbXAxis_, SIGNAL(currentIndexChanged(int)), SLOT(changeXaxis(int)));
2490  connect(cbYAxis_, SIGNAL(highlighted(int)), SLOT(changeYaxisTemp(int)));
2491  connect(cbYAxis_, SIGNAL(currentIndexChanged(int)), SLOT(changeYaxis(int)));
2492 
2493  cbXAxis_->setMinimumSize(cbXAxis_->sizeHint());
2494  grid->addWidget(cbXAxis_, 0,1);
2495  cbYAxis_->setMinimumSize(cbYAxis_->sizeHint());
2496  grid->addWidget(cbYAxis_, 1,1);
2497 
2498  gBox->setLayout(grid);
2499  aLayout->addWidget(gBox);
2500 // layout->addWidget(gBox);
2501 
2502  //--
2503  const char* sets2plotNames[3] = {"A", "U", "G"};
2504  QRadioButton *rbButton[3];
2505  gBox = new QGroupBox("Data to plot", controls_);
2506  QBoxLayout *bLayout=new QHBoxLayout(gBox);
2507  bgSets2plot_ = new QButtonGroup(gBox);
2508  for (int i=0; i<3; i++)
2509  {
2510  rbButton[i] = new QRadioButton(sets2plotNames[i], gBox);
2511  rbButton[i]-> setMinimumSize(rbButton[i]->sizeHint());
2512  bgSets2plot_->addButton(rbButton[i], i);
2513  bLayout->addWidget(rbButton[i]);
2514  };
2515  rbButton[area_->getSets2plot()]->setChecked(true);
2516  connect(bgSets2plot_, SIGNAL(buttonClicked(int)), SLOT(modifySets2plot(int)));
2517  aLayout->addWidget(gBox);
2518  //--
2519  };
2520  //
2521  // branches:
2522  if (!(modes_ & PM_WO_BRANCH_NAMES))
2523  {
2524  QStringListModel *model = new QStringListModel();
2525  QStringList list;
2526  lvBranches_ = new QListView(controls_);
2527  for (int i=0; i<plotCarrier_->listOfBranches()->size(); i++)
2528  list << plotCarrier_->listOfBranches()->at(i)->getName();
2529  model -> setStringList(list);
2530  lvBranches_->setModel(model);
2531 
2532  lvBranches_->setSelectionMode(QAbstractItemView::MultiSelection);
2533  lvBranches_->setEditTriggers (QAbstractItemView::NoEditTriggers);
2534  lvBranches_->setUniformItemSizes(true);
2535  lvBranches_->selectAll();
2537 
2538  connect(lvBranches_->selectionModel(),
2539  SIGNAL(selectionChanged(const QItemSelection, const QItemSelection)), SLOT(branchChanged()));
2540 
2541  lvBranches_->setMinimumWidth(24 + lvBranches_->sizeHintForColumn(0));
2542  lvBranches_->setMaximumHeight(9*lvBranches_->sizeHintForRow(0));
2543 
2544  QHBoxLayout *layoutH = new QHBoxLayout;
2545  layoutH->setSpacing(0);
2546  QPushButton *allPlus = new QPushButton("*+", this);
2547  QPushButton *prevBrn = new QPushButton("<<", this);
2548  QPushButton *nextBrn = new QPushButton(">>", this);
2549  QPushButton *allMinus= new QPushButton("-*", this);
2550  QSize btnSize = allPlus->fontMetrics().size(Qt::TextSingleLine, ">>");
2551 
2552  //btnSize+=QSize(12,8);
2553  btnSize+=QSize(8,4);
2554  allPlus ->setFixedSize(btnSize);
2555  allMinus->setFixedSize(btnSize);
2556  prevBrn ->setFixedSize(btnSize);
2557  nextBrn ->setFixedSize(btnSize);
2558 
2559  QPushButton *filterMinus=NULL, *filterPlus=NULL;
2560  if (modes_ & PM_FILTERS_ENABLED)
2561  {
2562  filterMinus = new QPushButton("-F", this);
2563  filterPlus = new QPushButton("F+", this);
2564  filterMinus->setFixedHeight (btnSize.height());
2565  filterMinus->setMinimumWidth(btnSize.width());
2566  filterPlus ->setFixedHeight (btnSize.height());
2567  filterPlus ->setMinimumWidth(btnSize.width());
2568  filterPlus ->setContextMenuPolicy(Qt::CustomContextMenu);
2569  filterMinus->setContextMenuPolicy(Qt::CustomContextMenu);
2570  };
2571  layoutH->addWidget(allMinus);
2572  if (modes_ & PM_FILTERS_ENABLED)
2573  layoutH->addWidget(filterMinus, 1);
2574  else
2575  layoutH->addStretch(1);
2576  layoutH->addWidget(prevBrn);
2577  layoutH->addWidget(nextBrn);
2578  if (modes_ & PM_FILTERS_ENABLED)
2579  layoutH->addWidget(filterPlus, 1);
2580  else
2581  layoutH->addStretch(1);
2582  layoutH->addWidget(allPlus);
2583 
2584  connect(allPlus, SIGNAL(clicked()), SLOT(markAllBranchesAsSelected()));
2585  connect(allMinus, SIGNAL(clicked()), SLOT(markAllBranchesAsDeselected()));
2586  connect(prevBrn, SIGNAL(clicked()), SLOT(markPrevBranch()));
2587  connect(nextBrn, SIGNAL(clicked()), SLOT(markNextBranch()));
2588  if (modes_ & PM_FILTERS_ENABLED)
2589  {
2590  connect(filterMinus, SIGNAL(clicked()), SLOT(processFilterMinus()));
2591  connect(filterPlus, SIGNAL(clicked()), SLOT(processFilterPlus ()));
2592  connect(filterMinus, SIGNAL(customContextMenuRequested(const QPoint&)),
2593  SLOT (processFilterAuxMinus(const QPoint&)));
2594  connect(filterPlus, SIGNAL(customContextMenuRequested(const QPoint&)),
2595  SLOT (processFilterAuxPlus (const QPoint&)));
2596  };
2597  QVBoxLayout *layoutV = new QVBoxLayout;
2598  layoutV->setSpacing(0);
2599  layoutV->addLayout(layoutH);
2600  layoutV->addWidget(lvBranches_);
2601  layout->addLayout(layoutV, 5);
2602  };
2603  //
2604  // draw modes:
2605  gBox = new QGroupBox("Plot data as:", controls_);
2606  aLayout = new QVBoxLayout(gBox);
2607 
2608  aLayout->addStretch(1);
2609  cbPoints_ = new QCheckBox("Points", gBox);
2610  cbPoints_->setMinimumSize(cbPoints_->sizeHint());
2611  // defaults:
2612  cbPoints_->setChecked(true);
2613  connect(cbPoints_, SIGNAL(toggled(bool)), SLOT(dmPointsChanged(bool)));
2614  if (modes_ & PM_WO_DOTS)
2615  cbPoints_->setChecked(false);
2616  aLayout->addWidget(cbPoints_);
2617 
2618  cbLines_ = new QCheckBox("Lines", gBox);
2619  cbLines_->setMinimumSize(cbLines_->sizeHint());
2620  connect(cbLines_, SIGNAL(toggled(bool)), SLOT(dmLinesChanged(bool)));
2621  if (modes_ & PM_LINES)
2622  cbLines_->setChecked(true);
2623  aLayout->addWidget(cbLines_);
2624 
2625  cbErrBars_ = new QCheckBox("Error bars", gBox);
2626  cbErrBars_->setMinimumSize(cbErrBars_->sizeHint());
2627  connect(cbErrBars_, SIGNAL(toggled(bool)), SLOT(dmErrBarsChanged(bool)));
2628  if (modes_ & PM_ERRBARS)
2629  cbErrBars_->setChecked(true);
2630  aLayout->addWidget(cbErrBars_);
2631 
2632  cbImpulses_ = new QCheckBox("Impulses", gBox);
2633  cbImpulses_->setMinimumSize(cbImpulses_->sizeHint());
2634  connect(cbImpulses_, SIGNAL(toggled(bool)), SLOT(dmImpulsesChanged(bool)));
2635  aLayout->addWidget(cbImpulses_);
2636  if (modes_ & PM_IMPULSE)
2637  cbImpulses_->setChecked(true);
2638  aLayout->addStretch(1);
2639 
2640  gBox->setLayout(aLayout);
2641  layout->addWidget(gBox);
2642  //
2643 
2644  // colors:
2645  gBox = new QGroupBox("Colors (H,S,V)", controls_);
2646  grid = new QGridLayout(gBox);
2647 
2648  slider = new QSlider(Qt::Vertical, gBox);
2649  slider->setTickPosition(QSlider::TicksLeft);
2650 // slider->setTickPosition(QSlider::NoTicks);
2651  slider->setRange(0, 360);
2652  slider->setPageStep(30);
2653  slider->setValue(0);
2654  slider->setMinimumSize(slider->sizeHint());
2655  connect(slider, SIGNAL(valueChanged(int)), SLOT(colorHChanged(int)));
2656  grid->addWidget(slider, 1,0);
2657 
2658  slider = new QSlider(Qt::Vertical, gBox);
2659 // slider->setTickPosition(QSlider::TicksBothSides);
2660  slider->setTickPosition(QSlider::NoTicks);
2661  slider->setRange(0, 255);
2662  slider->setPageStep(24);
2663  slider->setValue(255);
2664  slider->setMinimumSize(slider->sizeHint());
2665  connect(slider, SIGNAL(valueChanged(int)), SLOT(colorSChanged(int)));
2666  grid->addWidget(slider, 1,1);
2667 
2668  slider = new QSlider(Qt::Vertical, gBox);
2669  slider->setTickPosition(QSlider::TicksRight);
2670 // slider->setTickPosition(QSlider::NoTicks);
2671  slider->setRange(0, 255);
2672  slider->setPageStep(50);
2673  slider->setValue(200);
2674  slider->setMinimumSize(slider->sizeHint());
2675  connect(slider, SIGNAL(valueChanged(int)), SLOT(colorVChanged(int)));
2676  grid->addWidget(slider, 1,2);
2677 
2678 // grid->activate();
2679  gBox->setLayout(grid);
2680  layout->addWidget(gBox);
2681  //
2682 
2683  // options:
2684  gBox = new QGroupBox("Plot Ranges", controls_);
2685  aLayout = new QVBoxLayout(gBox);
2686 
2687  aLayout->addStretch(1);
2688  cbUserDefined_ = new QCheckBox("User's", gBox);
2689  cbUserDefined_->setMinimumSize(cbUserDefined_->sizeHint());
2690  cbUserDefined_->setEnabled(false);
2691  connect(cbUserDefined_, SIGNAL(toggled(bool)), SLOT(oUserDefinedChanged(bool)));
2692  aLayout->addWidget(cbUserDefined_);
2693 
2694  cbRangeVisible_ = new QCheckBox("Visible only", gBox);
2695  cbRangeVisible_->setMinimumSize(cbRangeVisible_->sizeHint());
2696  cbRangeVisible_->setChecked(false);
2697  connect(cbRangeVisible_, SIGNAL(toggled(bool)), SLOT(oVisRang(bool)));
2698  aLayout->addWidget(cbRangeVisible_);
2699 
2700  cbWStdVar_ = new QCheckBox("w/ StdVar", gBox);
2701  cbWStdVar_->setMinimumSize(cbWStdVar_->sizeHint());
2702  cbWStdVar_->setChecked(true);
2703  connect(cbWStdVar_, SIGNAL(toggled(bool)), SLOT(oWStdVar(bool)));
2704  aLayout->addWidget(cbWStdVar_);
2705 
2706  cbSymmetrical_ = new QCheckBox("Symmetrical", gBox);
2707  cbSymmetrical_->setMinimumSize(cbSymmetrical_->sizeHint());
2708  cbSymmetrical_->setChecked(false);
2709  connect(cbSymmetrical_, SIGNAL(toggled(bool)), SLOT(setRangeSymmetrical(bool)));
2710  aLayout->addWidget(cbSymmetrical_);
2711 
2712  //--
2713  const char* rangeLimitsNames[3] = {"A", "U", "G"};
2714  QRadioButton *rbButton[3];
2715  QBoxLayout *bLayout=new QHBoxLayout;
2716  aLayout->addLayout(bLayout);
2717  bgRangeLimits_ = new QButtonGroup(gBox);
2718  for (int i=0; i<3; i++)
2719  {
2720  rbButton[i] = new QRadioButton(rangeLimitsNames[i], gBox);
2721  rbButton[i]-> setMinimumSize(rbButton[i]->sizeHint());
2722  bgRangeLimits_->addButton(rbButton[i], i);
2723  bLayout->addWidget(rbButton[i]);
2724  };
2725  rbButton[area_->getRangeLimits()]->setChecked(true);
2726  connect(bgRangeLimits_, SIGNAL(buttonClicked(int)), SLOT(modifyRangeLimits(int)));
2727  //--
2728 
2729  aLayout->addStretch(1);
2730 
2731  gBox->setLayout(aLayout);
2732  layout->addWidget(gBox);
2733 
2734  //..
2735  // plot size:
2736  layout->addStretch(1);
2737  grid = new QGridLayout();
2738  layout->addLayout(grid, 0);
2739 
2740  button = new QPushButton(">file", controls_);
2741  button->setMinimumSize(2*button->sizeHint()/4);
2742  connect (button, SIGNAL(clicked()), SLOT(save2File()));
2743  grid->addWidget(button, 0,0);
2744 
2745  button = pbZommXOut_ = new QPushButton("Z'X-", controls_);
2746  button->setMinimumSize(2*button->sizeHint()/4);
2747  connect (button, SIGNAL(clicked()), SLOT(zoomXOut()));
2748  grid->addWidget(button, 1,0);
2749 
2750  button = pbZommOut_ = new QPushButton("Z'-", controls_);
2751  button->setMinimumSize(2*button->sizeHint()/4);
2752  button->addAction(zoomOutAction_);
2753  connect (button, SIGNAL(clicked()), SLOT(zoomOut()));
2754  grid->addWidget(button, 2,0);
2755 
2756  button = pbZommYIn_ = new QPushButton("Z'Y+", controls_);
2757  button->setMinimumSize(2*button->sizeHint()/4);
2758  connect (button, SIGNAL(clicked()), SLOT(zoomYIn()));
2759  grid->addWidget(button, 0,1);
2760 
2761  button = new QPushButton("O", controls_);
2762  button->setMinimumSize(2*button->sizeHint()/4);
2763  connect (button, SIGNAL(clicked()), SLOT(zoomNormalView()));
2764  grid->addWidget(button, 1,1);
2765 
2766  button = pbZommYOut_ = new QPushButton("Z'Y-", controls_);
2767  button->setMinimumSize(2*button->sizeHint()/4);
2768  connect (button, SIGNAL(clicked()), SLOT(zoomYOut()));
2769  grid->addWidget(button, 2,1);
2770 
2771  button = pbZommIn_ = new QPushButton("Z'+", controls_);
2772  button->setMinimumSize(2*button->sizeHint()/4);
2773  button->addAction(zoomInAction_);
2774  connect (button, SIGNAL(clicked()), SLOT(zoomIn()));
2775  grid->addWidget(button, 0,2);
2776 
2777  button = pbZommXIn_ = new QPushButton("Z'X+", controls_);
2778  button->setMinimumSize(2*button->sizeHint()/4);
2779  connect (button, SIGNAL(clicked()), SLOT(zoomXIn()));
2780  grid->addWidget(button, 1,2);
2781 
2782  button = new QPushButton(">Img", controls_);
2783  button->setMinimumSize(2*button->sizeHint()/4);
2784  connect (button, SIGNAL(clicked()), SLOT(save2Image()));
2785  grid->addWidget(button, 2,2);
2786  //
2787 // layout->activate();
2788 
2789  return controls_;
2790 };
2791 
2792 
2793 
2794 
2795 
2796 
2797 //
2799 {
2800  lvBranches_->selectAll();
2801 };
2802 
2803 
2804 
2805 //
2807 {
2808  lvBranches_->clearSelection();
2809 };
2810 
2811 
2812 
2813 //
2815 {
2816  lvExtKeys_->selectAll();
2817 };
2818 
2819 
2820 
2821 //
2823 {
2824  lvExtKeys_->clearSelection();
2825 };
2826 
2827 
2828 
2829 //
2831 {
2832  if (modes_ & PM_WO_AXIS_NAMES)
2833  return;
2834 
2835  int currentX = cbXAxis_->currentIndex();
2836  int currentY = cbYAxis_->currentIndex();
2837  cbXAxis_->clear();
2838  cbYAxis_->clear();
2839  if (plotCarrier_->numOfColumns())
2840  {
2841  QString *s;
2842  for (int i=0; i<plotCarrier_->numOfColumns()-1; i++)
2843  {
2844  s = plotCarrier_->columnNames()->at(i);
2845  cbXAxis_->insertItem(i, *s);
2846  cbYAxis_->insertItem(i, *s);
2847  };
2848  if (cbXAxis_->count() > currentX)
2849  cbXAxis_->setCurrentIndex(currentX);
2850  else
2851  cbXAxis_->setCurrentIndex(0);
2852  if (cbYAxis_->count() > currentY)
2853  cbYAxis_->setCurrentIndex(currentY);
2854  else
2855  cbYAxis_->setCurrentIndex(plotCarrier_->numOfColumns()>=1?1:0);
2856  };
2857  cbXAxis_->setMinimumSize(cbXAxis_->sizeHint());
2858  cbYAxis_->setMinimumSize(cbYAxis_->sizeHint());
2859 };
2860 
2861 
2862 
2863 //
2865 {
2866  if (modes_ & PM_WO_BRANCH_NAMES)
2867  return;
2868 
2869  if (plotCarrier_->listOfBranches()->count())
2870  {
2871  QAbstractItemModel *oldModel = lvBranches_->model();
2872  QStringList list;
2873  for (int i=0; i<plotCarrier_->listOfBranches()->size(); i++)
2874  list << plotCarrier_->listOfBranches()->at(i)->getName();
2875  lvBranches_->setModel(new QStringListModel(list));
2876  delete oldModel;
2877 
2878  lvBranches_->setSelectionMode(QAbstractItemView::MultiSelection);
2879 // lvBranches_->selectAll();
2880  lvBranches_->setMinimumWidth(20 + lvBranches_->sizeHintForColumn(0));
2881  lvBranches_->setMaximumHeight(6*lvBranches_->sizeHintForRow(0));
2882 
2883  connect(lvBranches_->selectionModel(),
2884  SIGNAL(selectionChanged(const QItemSelection, const QItemSelection)), SLOT(branchChanged()));
2885  lvBranches_->selectAll();
2886  };
2887 };
2888 
2889 
2890 
2891 //
2893 {
2894  area_->dataChanged();
2895  fillAxisNames();
2897  area_->update();
2898 };
2899 
2900 
2901 
2902 //
2904 {
2905  // area_->dataChanged();
2906  // fillAxisNames();
2907  // fillBranchesNames();
2908  area_->update();
2909 };
2910 
2911 
2912 
2913 //
2915 {
2916  if (n>-1)
2917  area_->setXColumn(n);
2918  area_->update();
2919  emit xAxisChanged(n);
2920 };
2921 
2922 
2923 
2924 //
2926 {
2927  if (n>-1)
2928  area_->setXColumn(n);
2929  area_->update();
2930 };
2931 
2932 
2933 
2934 //
2936 {
2937  cbYAxis_->setCurrentIndex(n);
2938  if (n>-1)
2939  area_->setXColumn(n);
2940  area_->update();
2941 };
2942 
2943 
2944 
2945 //
2947 {
2948  if (n>-1)
2949  area_->setYColumn(n);
2950  area_->update();
2951  emit yAxisChanged(n);
2952 };
2953 
2954 
2955 
2956 //
2958 {
2959  if (n>-1)
2960  area_->setYColumn(n);
2961  area_->update();
2962 };
2963 
2964 
2965 
2966 //
2968 {
2969  cbYAxis_->setCurrentIndex(n);
2970  if (n>-1)
2971  area_->setYColumn(n);
2972  area_->update();
2973 };
2974 
2975 
2976 
2977 //
2979 {
2980  area_->setBPHuePhase(n);
2981 };
2982 
2983 
2984 
2985 //
2987 {
2988  area_->setBPSaturation(n);
2989 };
2990 
2991 
2992 
2993 //
2995 {
2996  area_->setBPValue(n);
2997 };
2998 
2999 
3000 
3001 //
3003 {
3004  if (!isBranchViewInSpecialMode_) // adjust viewings:
3005  {
3006  lvBranches_->clearSelection();
3008  };
3009  QStringListModel *model = (QStringListModel*) lvBranches_->model();
3010  QModelIndex mIdx = lvBranches_->currentIndex();
3011  int row = mIdx.row();
3012  row--;
3013  if (row<0)
3014  row = model->rowCount() - 1;
3015  mIdx = model->index(row);
3016  lvBranches_->setCurrentIndex(mIdx);
3017 };
3018 
3019 
3020 
3021 //
3023 {
3024  if (!isBranchViewInSpecialMode_) // adjust viewings:
3025  {
3026  lvBranches_->clearSelection();
3028  };
3029  QStringListModel *model = (QStringListModel*) lvBranches_->model();
3030  QModelIndex mIdx = lvBranches_->currentIndex();
3031  int row = mIdx.row();
3032  row++;
3033  if (row > model->rowCount()-1)
3034  row = 0;
3035  mIdx = model->index(row);
3036  lvBranches_->setCurrentIndex(mIdx);
3037 };
3038 
3039 
3040 
3041 //
3043 {
3044  if (!isExtKeyViewInSpecialMode_) // adjust viewings:
3045  {
3046  lvExtKeys_->clearSelection();
3048  };
3049  QStringListModel *model = (QStringListModel*) lvExtKeys_->model();
3050  QModelIndex mIdx = lvExtKeys_->currentIndex();
3051  int row = mIdx.row();
3052  row--;
3053  if (row<0)
3054  row = model->rowCount() - 1;
3055  mIdx = model->index(row);
3056  lvExtKeys_->setCurrentIndex(mIdx);
3057 };
3058 
3059 
3060 
3061 //
3063 {
3064  if (!isExtKeyViewInSpecialMode_) // adjust viewings:
3065  {
3066  lvExtKeys_->clearSelection();
3068  };
3069  QStringListModel *model = (QStringListModel*) lvExtKeys_->model();
3070  QModelIndex mIdx = lvExtKeys_->currentIndex();
3071  int row = mIdx.row();
3072  row++;
3073  if (row > model->rowCount()-1)
3074  row = 0;
3075  mIdx = model->index(row);
3076  lvExtKeys_->setCurrentIndex(mIdx);
3077 };
3078 
3079 
3080 
3081 //
3083 {
3084  if (currentKeyModifier_ & Qt::ShiftModifier)
3085  {
3087  currentKeyModifier_ = 0;
3088  return;
3089  };
3090  //
3091  QAction *ret=NULL;
3092  if ((ret=QMenu::exec(filterActions_, QCursor::pos())))
3093  {
3094  QString txt=ret->text();
3095  QItemSelectionModel *selectionModel=lvBranches_->selectionModel();
3096  QStringListModel *model=(QStringListModel*)lvBranches_->model();
3097  for (int i=0; i<model->rowCount(); i++)
3098  if (plotCarrier_->listOfBranches()->at(i)->getName().contains(txt))
3099  selectionModel->select(model->index(i), QItemSelectionModel::Deselect);
3100  };
3101 };
3102 
3103 
3104 
3105 //
3107 {
3108  if (currentKeyModifier_ & Qt::ShiftModifier)
3109  {
3111  currentKeyModifier_ = 0;
3112  return;
3113  };
3114  //
3115  QAction *ret=NULL;
3116  if ((ret=QMenu::exec(filterActions_, QCursor::pos())))
3117  {
3118  QString txt=ret->text();
3119  QItemSelectionModel *selectionModel=lvBranches_->selectionModel();
3120  QStringListModel *model=(QStringListModel*)lvBranches_->model();
3121  for (int i=0; i<model->rowCount(); i++)
3122  if (plotCarrier_->listOfBranches()->at(i)->getName().contains(txt))
3123  selectionModel->select(model->index(i), QItemSelectionModel::Select);
3124  };
3125 };
3126 
3127 
3128 
3129 //
3131 {
3132  if (!filterAuxActions_.size())
3133  return;
3134  QAction *ret=NULL;
3135  if ((ret=QMenu::exec(filterAuxActions_, QCursor::pos())))
3136  {
3137  QString txt=ret->text();
3138  QItemSelectionModel *selectionModel=lvBranches_->selectionModel();
3139  QStringListModel *model=(QStringListModel*)lvBranches_->model();
3140  for (int i=0; i<model->rowCount(); i++)
3141  if (plotCarrier_->listOfBranches()->at(i)->getName().contains(txt))
3142  selectionModel->select(model->index(i), QItemSelectionModel::Deselect);
3143  };
3144 };
3145 
3146 
3147 
3148 //
3149 void SgPlot::processFilterAuxPlus(const QPoint&)
3150 {
3151  if (!filterAuxActions_.size())
3152  return;
3153  QAction *ret=NULL;
3154  if ((ret=QMenu::exec(filterAuxActions_, QCursor::pos())))
3155  {
3156  QString txt=ret->text();
3157  QItemSelectionModel *selectionModel=lvBranches_->selectionModel();
3158  QStringListModel *model=(QStringListModel*)lvBranches_->model();
3159  for (int i=0; i<model->rowCount(); i++)
3160  if (plotCarrier_->listOfBranches()->at(i)->getName().contains(txt))
3161  selectionModel->select(model->index(i), QItemSelectionModel::Select);
3162  };
3163 };
3164 
3165 
3166 
3167 //
3169 {
3170  if (!filterExtActions_.size())
3171  return;
3172  QAction *ret=NULL;
3173  if ((ret=QMenu::exec(filterExtActions_, QCursor::pos())))
3174  {
3175  QString txt=ret->text();
3176  for (int i=0; i<plotCarrier_->listOfBranches()->size(); i++)
3177  {
3178  SgPlotBranch *branch=plotCarrier_->listOfBranches()->at(i);
3179  if (branch->hasExtKeys())
3180  for (unsigned int j=0; j<branch->numOfRows(); j++)
3181  if (branch->getExtKey(j)==txt &&
3182  (branch->getDataAttr(j) & SgPlotCarrier::DA_SELECTED))
3184  };
3185  };
3186  area_->update();
3187 };
3188 
3189 
3190 
3191 //
3193 {
3194  if (!filterExtActions_.size())
3195  return;
3196  QAction *ret=NULL;
3197  if ((ret=QMenu::exec(filterExtActions_, QCursor::pos())))
3198  {
3199  QString txt=ret->text();
3200  for (int i=0; i<plotCarrier_->listOfBranches()->size(); i++)
3201  {
3202  SgPlotBranch *branch=plotCarrier_->listOfBranches()->at(i);
3203  if (branch->hasExtKeys())
3204  for (unsigned int j=0; j<branch->numOfRows(); j++)
3205  if (branch->getExtKey(j)==txt &&
3206  !(branch->getDataAttr(j) & SgPlotCarrier::DA_SELECTED))
3208  };
3209  };
3210  area_->update();
3211 };
3212 
3213 
3214 
3215 //
3217 {
3218  QItemSelectionModel *selectionModel = lvBranches_->selectionModel();
3219  QStringListModel *model = (QStringListModel*)lvBranches_->model();
3220  for (int i=0; i<model->rowCount(); i++)
3221  {
3222  if (selectionModel->isSelected(model->index(i)))
3223  plotCarrier_->listOfBranches()->at(i)->setIsBrowsable(true);
3224  else
3225  plotCarrier_->listOfBranches()->at(i)->setIsBrowsable(false);
3226  };
3227  area_->update();
3229 };
3230 
3231 
3232 
3233 //
3235 {
3236  QItemSelectionModel *selectionModel=lvExtKeys_->selectionModel();
3237  QStringListModel *model=(QStringListModel*)lvExtKeys_->model();
3238  for (int i=0; i<model->rowCount(); i++)
3239  {
3240  QString str("");
3241  str = model->data(model->index(i), Qt::DisplayRole).toString();
3242 
3243  if (selectionModel->isSelected(model->index(i)))
3244  {
3245  for (int j=0; j<plotCarrier_->listOfBranches()->size(); j++)
3246  plotCarrier_->listOfBranches()->at(j)->flagExtKey(str, true);
3247  //std::cout << " :" << qPrintable(str) << " is selected\n";
3248  }
3249 // plotCarrier_->listOfBranches()->at(i)->setIsBrowsable(true);
3250  else
3251  {
3252  for (int j=0; j<plotCarrier_->listOfBranches()->size(); j++)
3253  plotCarrier_->listOfBranches()->at(j)->flagExtKey(str, false);
3254  //std::cout << " :" << qPrintable(str) << " is unselected\n";
3255  };
3256 // plotCarrier_->listOfBranches()->at(i)->setIsBrowsable(false);
3257  };
3258  area_->update();
3260 };
3261 
3262 
3263 
3264 //
3266 {
3267  if (filterActions_.size())
3268  filterActions_.clear();
3269  for (int i=0; i<l.size(); i++)
3270  filterActions_.append(new QAction(l.at(i), this));
3271 };
3272 
3273 
3274 
3275 //
3277 {
3278  if (filterAuxActions_.size())
3279  filterAuxActions_.clear();
3280  for (int i=0; i<l.size(); i++)
3281  filterAuxActions_.append(new QAction(l.at(i), this));
3282 };
3283 
3284 
3285 
3286 //
3288 {
3289  if (filterExtActions_.size())
3290  filterExtActions_.clear();
3291  for (int i=0; i<l.size(); i++)
3292  filterExtActions_.append(new QAction(l.at(i), this));
3293 };
3294 
3295 
3296 
3297 //
3299 {
3300  area_->setIsPlotPoints(Is);
3301  area_->update();
3302 };
3303 
3304 
3305 
3306 //
3308 {
3309  area_->setIsPlotLines(Is);
3310  area_->update();
3311 };
3312 
3313 
3314 
3315 //
3317 {
3318  area_->setIsPlotErrBars(Is);
3319  area_->update();
3320 };
3321 
3322 
3323 
3324 //
3326 {
3327  area_->setIsPlotImpulses(Is);
3328  area_->update();
3329 };
3330 
3331 
3332 
3333 //
3335 {
3336  if (!is)
3337  {
3339  cbUserDefined_->setEnabled(false);
3340  for (int i=0; i<bgRangeLimits_->buttons().size(); i++)
3341  bgRangeLimits_->buttons().at(i)->setEnabled(true);
3342  cbRangeVisible_->setEnabled(true);
3343  cbWStdVar_->setEnabled(true);
3344  area_->update();
3345  };
3346 };
3347 
3348 
3349 
3350 //
3352 {
3354  sod = (SgPlotArea::SetsOfData)idx;
3355  area_->setSets2plot(sod);
3356  area_->update();
3357 };
3358 
3359 
3360 
3361 //
3363 {
3364 // int sets2plotIdx=bgSets2plot_->checkedId();
3366  area_->setRangeLimits(rl);
3367  //
3368  if (true /*-1<sets2plotIdx && idx<sets2plotIdx*/)
3369  {
3370  bgSets2plot_->buttons().at(idx)->setChecked(true);
3371  modifySets2plot(idx);
3372  }
3373  else
3374  area_->update();
3375 };
3376 
3377 
3378 
3379 //
3380 void SgPlot::oVisRang(bool is)
3381 {
3383  area_->update();
3384 };
3385 
3386 
3387 
3388 //
3389 void SgPlot::oWStdVar(bool is)
3390 {
3391  area_->setIsStdVar(is);
3392  area_->update();
3393 };
3394 
3395 
3396 
3397 //
3399 {
3401  area_->update();
3402 };
3403 
3404 
3405 
3406 //
3408 {
3409  scaleX_ = scaleY_ = 1.0;
3410  area_->resize(plotScroller_->maximumViewportSize());
3411  area_->setVisibleWidth(plotScroller_->maximumViewportSize().width());
3412  area_->setVisibleHeight(plotScroller_->maximumViewportSize().height());
3413  // enable actions:
3414  zoomInAction_->setEnabled(true);
3415  zoomOutAction_->setEnabled(true);
3416  // enable buttons:
3417  pbZommOut_->setEnabled(true);
3418  pbZommIn_->setEnabled(true);
3419  pbZommXOut_->setEnabled(true);
3420  pbZommXIn_->setEnabled(true);
3421  pbZommYOut_->setEnabled(true);
3422  pbZommYIn_->setEnabled(true);
3423 };
3424 
3425 
3426 
3427 //
3428 void SgPlot::resizeEvent(QResizeEvent *ev)
3429 {
3430  QSize size = plotScroller_->maximumViewportSize();
3431  area_->resize((int)(scaleX_*size.width()), (int)(scaleY_*size.height()));
3432  area_->setVisibleWidth(plotScroller_->maximumViewportSize().width());
3433  area_->setVisibleHeight(plotScroller_->maximumViewportSize().height());
3434  QWidget::resizeEvent(ev);
3435 };
3436 
3437 
3438 
3439 //
3441 {
3442  Qt::MouseButton button = e->button();
3443  Qt::KeyboardModifiers modifiers = e->modifiers();
3444 
3445  // here we process user input from the mouse:
3446  switch (button)
3447  {
3448  case Qt::LeftButton: // left eye
3449  switch (modifiers)
3450  {
3451  default:
3452  case Qt::NoModifier:
3453  case Qt::ShiftModifier:
3455  startSelecting(e->pos() +
3456  QPoint (plotScroller_->horizontalScrollBar()->value(),
3457  plotScroller_->verticalScrollBar()->value()), modifiers & Qt::ShiftModifier);
3458  break;
3459  case Qt::ControlModifier:
3460  break;
3461  };
3462  break;
3463 
3464  case Qt::MidButton: // wheel pressed
3465  switch (modifiers)
3466  {
3467  default:
3468  case Qt::NoModifier:
3470  startScrollViewport(e->globalPos());
3471  break;
3472  case Qt::ControlModifier:
3473  break;
3474  };
3475  break;
3476 
3477  case Qt::RightButton: // right eye
3478  switch (modifiers)
3479  {
3480  default:
3481  case Qt::NoModifier:
3483  startInquire(e->pos() +
3484  QPoint (plotScroller_->horizontalScrollBar()->value(),
3485  plotScroller_->verticalScrollBar()->value()));
3486  break;
3487  case Qt::ShiftModifier:
3489  startMeasuring(e->pos() +
3490  QPoint (plotScroller_->horizontalScrollBar()->value(),
3491  plotScroller_->verticalScrollBar()->value()));
3492  break;
3493  case Qt::ControlModifier:
3495  startReRanging(e->pos() +
3496  QPoint (plotScroller_->horizontalScrollBar()->value(),
3497  plotScroller_->verticalScrollBar()->value()));
3498  break;
3499  };
3500  break;
3501 
3502  default: // something else:
3504  ": processMousePressEvent(): mouse buttons pressed: " +
3505  ((button & Qt::LeftButton) ? "Left ": "") +
3506  ((button & Qt::RightButton) ? "Right ": "") +
3507  ((button & Qt::MidButton) ? "Middle ": "") +
3508  ((button & Qt::XButton1) ? "XButton1 ": "") +
3509  ((button & Qt::XButton2) ? "XButton2": "")
3510  );
3511  break;
3512  };
3513  e->accept();
3514 };
3515 
3516 
3517 
3518 //
3519 void SgPlot::processMouseMoveEvent(QMouseEvent* e)
3520 {
3521  // here we process user input from the mouse:
3522  switch (area_->getUserMode())
3523  {
3525  doScrollViewport(e->globalPos());
3526  break;
3527 
3529  doInquire(e->pos() +
3530  QPoint (plotScroller_->horizontalScrollBar()->value(),
3531  plotScroller_->verticalScrollBar()->value()));
3532  break;
3533 
3535  doMeasuring(e->pos() +
3536  QPoint (plotScroller_->horizontalScrollBar()->value(),
3537  plotScroller_->verticalScrollBar()->value()));
3538  break;
3539 
3541  doReRanging(e->pos() +
3542  QPoint (plotScroller_->horizontalScrollBar()->value(),
3543  plotScroller_->verticalScrollBar()->value()));
3544  break;
3545 
3548  doSelecting(e->pos() +
3549  QPoint (plotScroller_->horizontalScrollBar()->value(),
3550  plotScroller_->verticalScrollBar()->value()), e->modifiers() & Qt::ShiftModifier);
3551  break;
3552 
3553  default:
3554  break;
3555  };
3556  e->accept();
3557 };
3558 
3559 
3560 
3561 //
3563 {
3564  Qt::MouseButton button = e->button();
3565  Qt::KeyboardModifiers modifiers = e->modifiers();
3566  // here we process user input from the mouse:
3567  switch (button)
3568  {
3569  case Qt::LeftButton: // left eye
3572  stopSelecting(e->pos() +
3573  QPoint (plotScroller_->horizontalScrollBar()->value(),
3574  plotScroller_->verticalScrollBar()->value()), modifiers & Qt::ShiftModifier);
3575  break;
3576 
3577  case Qt::MidButton: // wheel pressed
3580  break;
3581 
3582  case Qt::RightButton: // right eye
3584  stopInquire();
3586  stopMeasuring();
3588  stopReRanging(modifiers & Qt::ControlModifier);
3589  break;
3590 
3591  default: // something else:
3593  ": processMousePressEvent(): mouse buttons released: " +
3594  ((button & Qt::LeftButton) ? "Left ": "") +
3595  ((button & Qt::RightButton) ? "Right ": "") +
3596  ((button & Qt::MidButton) ? "Middle ": "") +
3597  ((button & Qt::XButton1) ? "XButton1 ": "") +
3598  ((button & Qt::XButton2) ? "XButton2": "")
3599  );
3600  break;
3601  };
3602  e->accept();
3603 };
3604 
3605 
3606 
3607 //
3609 {
3610  Qt::MouseButton button = e->button();
3611  Qt::KeyboardModifiers modifiers = e->modifiers();
3612 
3613  // here we process user input from the mouse:
3614  switch (button)
3615  {
3616  case Qt::LeftButton: // left eye
3617  switch (modifiers)
3618  {
3619  default:
3620  case Qt::NoModifier:
3623  queryData(e->pos() +
3624  QPoint (plotScroller_->horizontalScrollBar()->value(),
3625  plotScroller_->verticalScrollBar()->value()));
3626  break;
3627  case Qt::ControlModifier:
3628  break;
3629  };
3630  break;
3631 
3632  case Qt::MidButton: // wheel pressed
3633  switch (modifiers)
3634  {
3635  default:
3636  case Qt::NoModifier:
3637  break;
3638  case Qt::ControlModifier:
3639  break;
3640  };
3641  break;
3642 
3643  case Qt::RightButton: // right eye
3644  switch (modifiers)
3645  {
3646  default:
3647  case Qt::NoModifier:
3648  break;
3649  case Qt::ShiftModifier:
3650  break;
3651  case Qt::ControlModifier:
3652  break;
3653  };
3654  break;
3655 
3656  default: // something else:
3657  break;
3658  };
3659  e->accept();
3660 };
3661 
3662 
3663 
3664 //
3665 void SgPlot::processWheelEvent(QWheelEvent *e)
3666 {
3667  QPoint p = e->pos();
3668  int delta = e->delta();
3669 
3670  if (delta>0 && zoomInAction_->isEnabled())
3671  rescaleArea(scaleFactor_, scaleFactor_, p.x(), p.y());
3672  else if (delta<0 && zoomOutAction_->isEnabled())
3673  rescaleArea(1.0/scaleFactor_, 1.0/scaleFactor_, p.x(), p.y());
3674 };
3675 
3676 
3677 
3678 //
3680 {
3681  Qt::KeyboardModifiers modifiers=e->modifiers();
3682  int key=e->key();
3683  currentKeyModifier_ = modifiers;
3684 
3685  switch (key)
3686  {
3687  case Qt::Key_Control:
3688  break;
3689 
3690  default:
3691  //std::cout << "Press: key= " << key << ", modifiers=" << modifiers << "\n";
3692  break;
3693  };
3694  emit userPressedAKey(this, modifiers, key);
3695  e->accept();
3696 };
3697 
3698 
3699 
3700 //
3702 {
3703  //Qt::KeyboardModifiers modifiers=e->modifiers();
3704  int key=e->key();
3705  currentKeyModifier_ = 0;
3706 
3707  switch (key)
3708  {
3709  case Qt::Key_Control:
3710  break;
3711 
3712  default:
3713  //std::cout << "Release: key= " << key << ", modifiers=" << modifiers << "\n";
3714  break;
3715  };
3716  //emit userPressedAKey(this, modifiers, key);
3717  e->accept();
3718 };
3719 
3720 
3721 
3722 //
3723 void SgPlot::rescaleArea(double xFactor, double yFactor, int posX, int posY)
3724 {
3725  scaleX_ *= xFactor;
3726  scaleY_ *= yFactor;
3727 
3728  QScrollBar *xScrollBar = plotScroller_->horizontalScrollBar();
3729  QScrollBar *yScrollBar = plotScroller_->verticalScrollBar();
3730 
3731  if (posX<0)
3732  posX = xScrollBar->pageStep()/2;
3733  if (posY<0)
3734  posY = yScrollBar->pageStep()/2;
3735  int x_old = xScrollBar->value() + posX;
3736  int y_old = yScrollBar->value() + posY;
3737 
3738  int xL = area_->width_;
3739  int yL = area_->height_;
3740  double xFprime = xFactor + (xFactor - 1.0)*(area_->xMargins_ - 1)/xL;
3741  double yFprime = yFactor + (yFactor - 1.0)*(area_->yMargins_ - 1)/yL;
3742 
3743  area_->resize(scaleX_*plotScroller_->maximumViewportSize().width(),
3744  scaleY_*plotScroller_->maximumViewportSize().height());
3745  area_->setVisibleWidth(plotScroller_->maximumViewportSize().width());
3746  area_->setVisibleHeight(plotScroller_->maximumViewportSize().height());
3747 
3748 
3749  xScrollBar->setValue(area_->xDataBegin_ + (int)round(xFprime*(x_old - area_->xDataBegin_)) - posX);
3750  yScrollBar->setValue(area_->yDataBegin_ + (int)round(yFprime*(y_old - area_->yDataBegin_)) - posY);
3751 
3752  // adjust enabilities of actions:
3753  zoomInAction_ ->setEnabled(scaleX_ <= maxZoomX_ && scaleY_ <= maxZoomY_);
3754  zoomOutAction_ ->setEnabled(scaleX_ >= minZoomX_ && scaleY_ >= minZoomY_);
3755  zoomXInAction_ ->setEnabled(scaleX_ <= maxZoomX_);
3756  zoomXOutAction_->setEnabled(scaleX_ >= minZoomX_);
3757  zoomYInAction_ ->setEnabled(scaleY_ <= maxZoomY_);
3758  zoomYOutAction_->setEnabled(scaleY_ >= minZoomY_);
3759 
3760  // and buttons:
3761  pbZommIn_ ->setEnabled(scaleX_ <= maxZoomX_ && scaleY_ <= maxZoomY_);
3762  pbZommOut_ ->setEnabled(scaleX_ >= minZoomX_ && scaleY_ >= minZoomY_);
3763  pbZommXIn_ ->setEnabled(scaleX_ <= maxZoomX_);
3764  pbZommXOut_->setEnabled(scaleX_ >= minZoomX_);
3765  pbZommYIn_ ->setEnabled(scaleY_ <= maxZoomY_);
3766  pbZommYOut_->setEnabled(scaleY_ >= minZoomY_);
3767 };
3768 
3769 
3770 
3771 //
3773 {
3775 };
3776 
3777 
3778 
3779 //
3781 {
3783 };
3784 
3785 
3786 
3787 //
3789 {
3790  rescaleArea(scaleFactor_, 1.0);
3791 };
3792 
3793 
3794 
3795 //
3797 {
3798  rescaleArea(1.0/scaleFactor_, 1.0);
3799 };
3800 
3801 
3802 
3803 //
3805 {
3806  rescaleArea(1.0, scaleFactor_);
3807 };
3808 
3809 
3810 
3811 //
3813 {
3814  rescaleArea(1.0, 1.0/scaleFactor_);
3815 };
3816 
3817 
3818 
3819 // User actions:
3820 // scrolling:
3821 void SgPlot::startScrollViewport(const QPoint& newCursorPosition)
3822 {
3824  oldCursorPosition_ = newCursorPosition;
3825 };
3826 
3827 
3828 
3829 //
3830 void SgPlot::doScrollViewport(const QPoint& newCursorPosition)
3831 {
3832  int dX = oldCursorPosition_.x() - newCursorPosition.x();
3833  int dY = oldCursorPosition_.y() - newCursorPosition.y();
3834 
3835  QScrollBar *xScrollBar = plotScroller_->horizontalScrollBar();
3836  QScrollBar *yScrollBar = plotScroller_->verticalScrollBar();
3837  xScrollBar->setValue(xScrollBar->value() + dX);
3838  yScrollBar->setValue(yScrollBar->value() + dY);
3839 
3840  oldCursorPosition_ = newCursorPosition;
3841 };
3842 
3843 
3844 
3845 //
3847 {
3849 };
3850 
3851 
3852 
3853 // inquiring:
3854 void SgPlot::startInquire(const QPoint& point)
3855 {
3857 
3858  int l, dx=0, dy=0;
3859  l = plotScroller_->maximumViewportSize().width();
3860  if (area_->width() < l)
3861  dx = -(int)round(0.5*l*(1.0-scaleX_));
3862  l = plotScroller_->maximumViewportSize().height();
3863  if (area_->height() < l)
3864  dy = -(int)round(0.5*l*(1.0-scaleY_));
3865 
3866  area_->setRulerToPoint(point + QPoint(dx, dy));
3867  area_->update();
3868 };
3869 
3870 
3871 
3872 //
3873 void SgPlot::doInquire(const QPoint& point)
3874 {
3875  QScrollBar *xScrollBar = plotScroller_->horizontalScrollBar();
3876  QScrollBar *yScrollBar = plotScroller_->verticalScrollBar();
3877  QRect rect(xScrollBar->value(), yScrollBar->value(),
3878  xScrollBar->pageStep(), yScrollBar->pageStep());
3879 
3880  int l, dx=0, dy=0;
3881  l = plotScroller_->maximumViewportSize().width();
3882  if (area_->width() < l)
3883  dx = -(int)round(0.5*l*(1.0-scaleX_));
3884  l = plotScroller_->maximumViewportSize().height();
3885  if (area_->height() < l)
3886  dy = -(int)round(0.5*l*(1.0-scaleY_));
3887 
3888  area_->setRulerToPoint(point + QPoint(dx, dy));
3889  area_->update(rect);
3890 };
3891 
3892 
3893 
3894 //
3896 {
3898  area_->update();
3899 };
3900 
3901 
3902 
3903 // measuring:
3904 void SgPlot::startMeasuring(const QPoint& point)
3905 {
3907 
3908  int l, dx=0, dy=0;
3909  l = plotScroller_->maximumViewportSize().width();
3910  if (area_->width() < l)
3911  dx = -(int)round(0.5*l*(1.0-scaleX_));
3912  l = plotScroller_->maximumViewportSize().height();
3913  if (area_->height() < l)
3914  dy = -(int)round(0.5*l*(1.0-scaleY_));
3915 
3916  area_->setRulerFromPoint(point + QPoint(dx, dy));
3917  area_->setRulerToPoint(point + QPoint(dx, dy));
3918 };
3919 
3920 
3921 
3922 //
3923 void SgPlot::doMeasuring(const QPoint& point)
3924 {
3925  QScrollBar *xScrollBar = plotScroller_->horizontalScrollBar();
3926  QScrollBar *yScrollBar = plotScroller_->verticalScrollBar();
3927  QRect rect(xScrollBar->value(), yScrollBar->value(),
3928  xScrollBar->pageStep(), yScrollBar->pageStep());
3929 
3930  int l, dx=0, dy=0;
3931  l = plotScroller_->maximumViewportSize().width();
3932  if (area_->width() < l)
3933  dx = -(int)round(0.5*l*(1.0-scaleX_));
3934  l = plotScroller_->maximumViewportSize().height();
3935  if (area_->height() < l)
3936  dy = -(int)round(0.5*l*(1.0-scaleY_));
3937 
3938  area_->setRulerToPoint(point + QPoint(dx, dy));
3939  area_->update(rect);
3940 };
3941 
3942 
3943 
3944 //
3946 {
3948  area_->update();
3949 };
3950 
3951 
3952 
3953 // changing ranges:
3954 void SgPlot::startReRanging(const QPoint& point)
3955 {
3957 
3958  int l, dx=0, dy=0;
3959  l = plotScroller_->maximumViewportSize().width();
3960  if (area_->width() < l)
3961  dx = -(int)round(0.5*l*(1.0-scaleX_));
3962  l = plotScroller_->maximumViewportSize().height();
3963  if (area_->height() < l)
3964  dy = -(int)round(0.5*l*(1.0-scaleY_));
3965 
3966  area_->setRulerFromPoint(point + QPoint(dx, dy));
3967  area_->setRulerToPoint(point + QPoint(dx, dy));
3968 };
3969 
3970 
3971 
3972 //
3973 void SgPlot::doReRanging(const QPoint& point)
3974 {
3975  QScrollBar *xScrollBar = plotScroller_->horizontalScrollBar();
3976  QScrollBar *yScrollBar = plotScroller_->verticalScrollBar();
3977  QRect rect(xScrollBar->value(), yScrollBar->value(),
3978  xScrollBar->pageStep(), yScrollBar->pageStep());
3979 
3980  int l, dx=0, dy=0;
3981  l = plotScroller_->maximumViewportSize().width();
3982  if (area_->width() < l)
3983  dx = -(int)round(0.5*l*(1.0-scaleX_));
3984  l = plotScroller_->maximumViewportSize().height();
3985  if (area_->height() < l)
3986  dy = -(int)round(0.5*l*(1.0-scaleY_));
3987 
3988  area_->setRulerToPoint(point + QPoint(dx, dy));
3989  area_->update(rect);
3990 };
3991 
3992 
3993 
3994 //
3995 void SgPlot::stopReRanging(bool performAction)
3996 {
3997  if (performAction)
3998  {
3999  double x_to = area_->reverseCalcX(area_->getRulerToPoint().x());
4000  double x_from = area_->reverseCalcX(area_->getRulerFromPoint().x());
4001  double y_to = area_->reverseCalcY(area_->getRulerToPoint().y());
4002  double y_from = area_->reverseCalcY(area_->getRulerFromPoint().y());
4003 
4004  if (x_to != x_from && y_to != y_from)
4005  {
4006  double minX = std::min(x_to, x_from);
4007  double maxX = std::max(x_to, x_from);
4008  double minY = std::min(y_to, y_from);
4009  double maxY = std::max(y_to, y_from);
4010  area_->setUserDefinedRanges(minX, maxX, minY, maxY);
4011  cbUserDefined_->setEnabled(true);
4012  cbUserDefined_->setChecked(true);
4013  cbRangeVisible_->setEnabled(false);
4014  for (int i=0; i<bgRangeLimits_->buttons().size(); i++)
4015  bgRangeLimits_->buttons().at(i)->setEnabled(false);
4016  cbWStdVar_->setEnabled(false);
4017  };
4018  };
4019 // else
4020 // area_->unsetUserDefinedRanges();
4021 
4023  area_->update();
4024 };
4025 
4026 
4027 
4028 // querying data:
4029 void SgPlot::queryData(const QPoint& point)
4030 {
4031  int l, dx=0, dy=0;
4032  l = plotScroller_->maximumViewportSize().width();
4033  if (area_->width() < l)
4034  dx = -(int)round(0.5*l*(1.0 - scaleX_));
4035  l = plotScroller_->maximumViewportSize().height();
4036  if (area_->height() < l)
4037  dy = -(int)round(0.5*l*(1.0 - scaleY_));
4038 
4039  SgPlotBranch *branch = NULL;
4040  int idx = -1;
4041  area_->queryPoint(point + QPoint(dx, dy), branch, idx);
4042  if (branch && idx>-1)
4043  {
4044  if (modes_ & PM_Q_PNT_EXT_PROC)
4045  emit pointInfoRequested(this, branch, idx, area_->getXColumn(), area_->getYColumn());
4046  else
4047  {
4048  QString xStr, yStr;
4049  double x = branch->data()->getElement(idx, area_->getXColumn());
4050  double y = branch->data()->getElement(idx, area_->getYColumn());
4051 
4052  if (!(branch->getDataAttr(idx) & SgPlotCarrier::DA_SELECTED))
4053  {
4055  area_->update();
4056  };
4057 
4058  if (area_->isXTicsMJD())
4059  xStr = " (time axis): " + SgMJD(x).toString();
4060  else
4061  xStr.sprintf(" (argument axis): %.6g", x);
4062  yStr.sprintf(" (value axis): %.6g", y);
4063 
4064  QMessageBox msgBox(this);
4065  msgBox.setIcon(QMessageBox::Information);
4066  msgBox.setText("<b>Inquired point</b>");
4067  msgBox.setInformativeText("<p>You have selected a point from the branch <b>" +
4068  branch->getName() + "</b>. Its attributes are:</p>" +
4069  "<p>index #" + QString().setNum(idx) + ",</p>" +
4070  "<p>" + xStr + "</p>" +
4071  "<p>" + yStr + "</p>" );
4072  // msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
4073  // msgBox.setDefaultButton(QMessageBox::Save);
4074  msgBox.exec();
4075  };
4076  };
4077 };
4078 
4079 
4080 
4081 // marking points:
4082 void SgPlot::startSelecting(const QPoint& point, bool isInverse)
4083 {
4084  QScrollBar *xScrollBar = plotScroller_->horizontalScrollBar();
4085  QScrollBar *yScrollBar = plotScroller_->verticalScrollBar();
4086  QRect rect(xScrollBar->value(), yScrollBar->value(),
4087  xScrollBar->pageStep(), yScrollBar->pageStep());
4088 
4090 
4091  int l, dx=0, dy=0;
4092  l = plotScroller_->maximumViewportSize().width();
4093  if (area_->width() < l)
4094  dx = -(int)round(0.5*l*(1.0 - scaleX_));
4095  l = plotScroller_->maximumViewportSize().height();
4096  if (area_->height() < l)
4097  dy = -(int)round(0.5*l*(1.0 - scaleY_));
4098 
4099  area_->setRulerFromPoint(point + QPoint(dx, dy));
4100  area_->setRulerToPoint(point + QPoint(dx, dy));
4101  area_->update(rect);
4102 };
4103 
4104 
4105 
4106 //
4107 void SgPlot::doSelecting(const QPoint& point, bool isInverse)
4108 {
4109  QScrollBar *xScrollBar = plotScroller_->horizontalScrollBar();
4110  QScrollBar *yScrollBar = plotScroller_->verticalScrollBar();
4111  QRect rect(xScrollBar->value(), yScrollBar->value(),
4112  xScrollBar->pageStep(), yScrollBar->pageStep());
4113 
4114  int l, dx=0, dy=0;
4115  l = plotScroller_->maximumViewportSize().width();
4116  if (area_->width() < l)
4117  dx = -(int)round(0.5*l*(1.0 - scaleX_));
4118  l = plotScroller_->maximumViewportSize().height();
4119  if (area_->height() < l)
4120  dy = -(int)round(0.5*l*(1.0 - scaleY_));
4121 
4123  area_->setRulerToPoint(point + QPoint(dx, dy));
4124  QPoint pointLT; // left top
4125  QPoint pointRB; // right bottom
4126  pointLT.setX(std::min(area_->getRulerFromPoint().x(),
4127  std::min(area_->getRulerToPoint().x(), area_->getRulerToPointPrev().x())));
4128  pointLT.setY(std::min(area_->getRulerFromPoint().y(),
4129  std::min(area_->getRulerToPoint().y(), area_->getRulerToPointPrev().y())));
4130  pointRB.setX(std::max(area_->getRulerFromPoint().x(),
4131  std::max(area_->getRulerToPoint().x(), area_->getRulerToPointPrev().x())));
4132  pointRB.setY(std::max(area_->getRulerFromPoint().y(),
4133  std::max(area_->getRulerToPoint().y(), area_->getRulerToPointPrev().y())));
4134  area_->update(QRect(pointLT-QPoint(5,5), pointRB+QPoint(5,5)));
4135 };
4136 
4137 
4138 
4139 //
4140 void SgPlot::stopSelecting(const QPoint&, bool)
4141 {
4142  QScrollBar *xScrollBar = plotScroller_->horizontalScrollBar();
4143  QScrollBar *yScrollBar = plotScroller_->verticalScrollBar();
4144  QRect rect(xScrollBar->value(), yScrollBar->value(),
4145  xScrollBar->pageStep(), yScrollBar->pageStep());
4146 
4148  area_->update(rect);
4149 };
4150 
4151 
4152 
4153 //
4155 {
4157 };
4158 
4159 
4160 
4161 //
4163 {
4164  bool isOutputDirExists(false);
4165  if (!path2Outputs_.isEmpty())
4166  {
4167  bool isOk(true);
4168  QDir d(path2Outputs_);
4169  if (!d.exists())
4170  isOk = d.mkpath("./"); // Qt, wtf?
4171  else
4172  isOutputDirExists = true;
4173  if (!isOk)
4175  "::save2Image(): cannot create directory " + path2Outputs_);
4176  else
4177  isOutputDirExists = true;
4178  };
4179 
4180  QString fileName = plotCarrier_->getFile2SaveBaseName()
4181  + QString("").sprintf("[%u:%u]", area_->getXColumn(), area_->getYColumn());
4182  if (isOutputDirExists)
4183  fileName = path2Outputs_ + "/" + fileName;
4184 
4185  QString fileSuffix("");
4186 
4187  switch (outputFormat_)
4188  {
4189  case OF_PS:
4190  case OF_PDF:
4191  fileSuffix = ".pdf";
4192  break;
4193  case OF_JPG:
4194  fileSuffix = ".jpg";
4195  break;
4196  case OF_PNG:
4197  fileSuffix = ".png";
4198  break;
4199  case OF_PPM:
4200  fileSuffix = ".ppm";
4201  break;
4202  default:
4204  "::save2Image(): unknown image type " + QString("").setNum(outputFormat_));
4205  fileSuffix = ".pdf";
4206  break;
4207  };
4208  //
4209  QPainter painter;
4210 
4212  {
4213 // PageOrientation
4214 // Resolution
4215 // PageSize
4216 //
4217 // pointSize
4218 // openPointIncrement
4219 // fontSize
4220 //
4221  QPdfWriter pdfWriter(fileName + ".pdf");
4222  pdfWriter.setPageOrientation(QPageLayout::Landscape);
4223  pdfWriter.setResolution(300);
4224  pdfWriter.setPageSize(QPageSize(QPageSize::Letter));
4225  pdfWriter.setCreator(libraryVersion.name());
4226 
4227  // make an output:
4228  painter.begin(&pdfWriter);
4229  area_->output4Print(&painter, pdfWriter.width(), pdfWriter.height(), 12, 6, 12);
4230  painter.end();
4231  }
4232  else
4233  {
4234 // width
4235 // height
4236 // or (from plot) * scale
4237 //
4238 // pointSize
4239 // openPointIncrement
4240 // fontSize
4241 //
4242  QImage image(2*QSize(area_->width(), area_->height()), QImage::Format_RGBA64);
4243  image.fill(QColor(255, 255, 255));
4244 
4245  painter.begin(&image);
4246  area_->output4Print(&painter, image.width(), image.height(), 5, 2, 16);
4247  painter.end();
4248  image.save(fileName + fileSuffix);
4249  };
4251  "::save2Image(): the plot has been saved into the file " + fileName + fileSuffix);
4252 };
4253 /*=====================================================================================================*/
4254 
4255 
4256 
4257 
4258 
4259 
4260 
4261 
4262 
4263 
4264 
4265 
4266 
4267 
4268 
4269 
4270 
4271 /*=====================================================================================================*/
SgLogger * logger
Definition: SgLogger.cpp:231
QString interval2Str(double days)
Definition: SgMJD.cpp:1370
SgVersion libraryVersion("SgLib", 0, 7, 5, "Tuscarora (rc1)", SgMJD(2022, 2, 18, 17, 34))
virtual void write(LogLevel, quint32, const QString &, bool=false)
Definition: SgLogger.cpp:88
@ IO_TXT
Definition: SgLogger.h:65
Definition: SgMJD.h:59
@ F_YYYYMMDDHHMMSSSS
Long verbose: Fri, the 2nd of Apr, 2010; 17hr 02min 43.6400sec.
Definition: SgMJD.h:67
@ F_Date
RFC2822 date format realized by Qt (Qt::RFC2822Date)
Definition: SgMJD.h:86
@ F_Time
SINEX, short version: 10:092.
Definition: SgMJD.h:95
@ F_TimeShort
Time, seconds are integer: 17:02:43.
Definition: SgMJD.h:97
QString toString(Format format=F_Verbose) const
Definition: SgMJD.cpp:1007
double toDouble() const
Definition: SgMJD.h:533
unsigned int nRow() const
Definition: SgMatrix.h:352
void setElement(unsigned int i, unsigned int j, double d)
Definition: SgMatrix.h:402
double getElement(unsigned int i, unsigned int j) const
Definition: SgMatrix.h:385
unsigned int nCol() const
Definition: SgMatrix.h:360
SetsOfData sets2plot_
Definition: SgGuiPlotter.h:452
double maxY_
Definition: SgGuiPlotter.h:406
bool isPlotPoints_
Definition: SgGuiPlotter.h:442
QPen * rulerPen_
Definition: SgGuiPlotter.h:431
bool isRangeSymmetrical_
Definition: SgGuiPlotter.h:450
int visibleHeight_
Definition: SgGuiPlotter.h:357
void setSets2plot(SetsOfData sod)
Definition: SgGuiPlotter.h:335
@ UserMode_INQUIRING
Definition: SgGuiPlotter.h:268
@ UserMode_DESELECTING
Definition: SgGuiPlotter.h:273
@ UserMode_MEASURING
Definition: SgGuiPlotter.h:269
@ UserMode_SELECTING
Definition: SgGuiPlotter.h:272
@ UserMode_RERANGING
Definition: SgGuiPlotter.h:270
@ UserMode_SCROLLING
Definition: SgGuiPlotter.h:267
QString * yLabel_
Definition: SgGuiPlotter.h:393
static QString yLabel4Unknown_
Definition: SgGuiPlotter.h:395
void defineAreas(QPainter *)
void setUserMode(UserMode mode)
void setRulerFromPoint(QPoint point)
Definition: SgGuiPlotter.h:322
double userDefinedMinX_
Definition: SgGuiPlotter.h:412
QPoint rulerToPointPrev_
Definition: SgGuiPlotter.h:469
bool isPlotImpulses_
Definition: SgGuiPlotter.h:445
bool isXTicsMJD_
Definition: SgGuiPlotter.h:383
const QPoint & getRulerFromPoint() const
Definition: SgGuiPlotter.h:303
int yFrameBegin_
Definition: SgGuiPlotter.h:368
void setBPSaturation(int)
double f_Ay_
Definition: SgGuiPlotter.h:421
void setIsPlotPoints(bool is)
Definition: SgGuiPlotter.h:317
int height() const
Definition: SgGuiPlotter.h:311
void drawFrames(QPainter *)
QCursor cursorScrolling_
Definition: SgGuiPlotter.h:463
void drawRangeSelector(QPainter *)
double xTicsStep_
Definition: SgGuiPlotter.h:380
void output4Print(QPainter *, int, int, int, int, int)
QCursor cursorMeasuring_
Definition: SgGuiPlotter.h:464
void setIsPlotErrBars(bool is)
Definition: SgGuiPlotter.h:319
QBrush * branchSelectedBrushes_
Definition: SgGuiPlotter.h:434
SetsOfData rangeLimits_
Definition: SgGuiPlotter.h:451
QPen * framePen_
Definition: SgGuiPlotter.h:425
void setIsRangeSymmetrical(bool is)
Definition: SgGuiPlotter.h:333
void setUserDefinedRanges(double, double, double, double)
QPoint rulerFromPoint_
Definition: SgGuiPlotter.h:467
virtual void resizeEvent(QResizeEvent *)
QPen * zeroPen_
Definition: SgGuiPlotter.h:428
SetsOfData getRangeLimits() const
Definition: SgGuiPlotter.h:307
void drawPointInfo(QPainter *)
void drawXmjdTics(QPainter *)
int yLabelHeight_
Definition: SgGuiPlotter.h:362
double minY_
Definition: SgGuiPlotter.h:408
bool isXTicsBiased_
Definition: SgGuiPlotter.h:382
double userDefinedMaxY_
Definition: SgGuiPlotter.h:411
void output4Files(const QString &path)
bool isYTicsBiased_
Definition: SgGuiPlotter.h:390
int yLabelWidth_
Definition: SgGuiPlotter.h:361
int xLabelWidth_
Definition: SgGuiPlotter.h:359
void setIsPlotImpulses(bool is)
Definition: SgGuiPlotter.h:320
int labelsHeight_
Definition: SgGuiPlotter.h:360
void setXColumn(unsigned int xColumn)
int rightMargin_
Definition: SgGuiPlotter.h:355
double reverseCalcY(int y) const
Definition: SgGuiPlotter.h:534
static QString xLabel4Unknown_
Definition: SgGuiPlotter.h:394
void drawData(QPainter *, const QRect &)
double f_By_
Definition: SgGuiPlotter.h:422
void setHave2HasZero(bool is)
Definition: SgGuiPlotter.h:330
QPen * branchSelectedPens_
Definition: SgGuiPlotter.h:433
double f_Ax_
Definition: SgGuiPlotter.h:419
unsigned int xColumn_
Definition: SgGuiPlotter.h:402
void setBPValue(int)
const QPoint & getRulerToPoint() const
Definition: SgGuiPlotter.h:304
int xFrameBegin_
Definition: SgGuiPlotter.h:366
QBrush * rulerBrush_
Definition: SgGuiPlotter.h:432
void setYColumn(unsigned int yColumn)
QCursor cursorDefault_
Definition: SgGuiPlotter.h:462
double yTicsBias_
Definition: SgGuiPlotter.h:389
QPoint rulerToPoint_
Definition: SgGuiPlotter.h:468
bool isPlotLines_
Definition: SgGuiPlotter.h:443
void dataChanged()
Definition: SgGuiPlotter.h:344
void initBranchPens()
void drawYTics(QPainter *)
unsigned int getXColumn() const
Definition: SgGuiPlotter.h:300
QPen * branchPens_
Definition: SgGuiPlotter.h:426
QString * xLabel_
Definition: SgGuiPlotter.h:392
virtual ~SgPlotArea()
void unsetUserDefinedRanges()
double xTicsBias_
Definition: SgGuiPlotter.h:381
void setIsPlotLines(bool is)
Definition: SgGuiPlotter.h:318
void setBPHuePhase(int)
double maxX_
Definition: SgGuiPlotter.h:405
QPen * ignoredPen_
Definition: SgGuiPlotter.h:435
const QPoint & getRulerToPointPrev() const
Definition: SgGuiPlotter.h:305
void setVisibleWidth(int width)
Definition: SgGuiPlotter.h:325
UserMode getUserMode() const
Definition: SgGuiPlotter.h:302
void drawXTics(QPainter *)
bool isStdVar_
Definition: SgGuiPlotter.h:449
SetsOfData getSets2plot() const
Definition: SgGuiPlotter.h:308
void setIsLimitsOnVisible(bool is)
Definition: SgGuiPlotter.h:331
double userDefinedMinY_
Definition: SgGuiPlotter.h:413
void drawRuler(QPainter *)
void calcTransforms()
int bpSaturation_
Definition: SgGuiPlotter.h:438
void queryPoint(const QPoint &, SgPlotBranch *&, int &)
double yTicsStep_
Definition: SgGuiPlotter.h:388
int calcY(double y) const
Definition: SgGuiPlotter.h:513
unsigned int yColumn_
Definition: SgGuiPlotter.h:403
unsigned int getYColumn() const
Definition: SgGuiPlotter.h:301
SgPlotCarrier * plotCarrier_
Definition: SgGuiPlotter.h:455
virtual QString className() const
Definition: SgGuiPlotter.h:341
void setRulerToPoint(QPoint point)
Definition: SgGuiPlotter.h:323
void drawPointSelector(QPainter *)
int calcX(double x) const
Definition: SgGuiPlotter.h:499
bool useUserDefinedRanges_
Definition: SgGuiPlotter.h:414
QPen * ticLinesPen_
Definition: SgGuiPlotter.h:430
virtual void paintEvent(QPaintEvent *)
int visibleWidth_
Definition: SgGuiPlotter.h:356
void setRangeLimits(SetsOfData rl)
Definition: SgGuiPlotter.h:334
void drawWholePlot(QPainter *, const QRect &)
bool isLimitsOnVisible_
Definition: SgGuiPlotter.h:448
void setIsStdVar(bool is)
Definition: SgGuiPlotter.h:332
double f_Bx_
Definition: SgGuiPlotter.h:420
bool have2HasZero_
Definition: SgGuiPlotter.h:458
SgPlotArea(SgPlotCarrier *, QWidget *parent=0, Qt::WindowFlags f=0)
void calcLimits()
void setBranchColors()
void setVisibleHeight(int height)
Definition: SgGuiPlotter.h:326
bool isPlotErrBars_
Definition: SgGuiPlotter.h:444
double userDefinedMaxX_
Definition: SgGuiPlotter.h:410
double minX_
Definition: SgGuiPlotter.h:407
QBrush * ignoredBrush_
Definition: SgGuiPlotter.h:436
int width() const
Definition: SgGuiPlotter.h:310
UserMode userMode_
Definition: SgGuiPlotter.h:461
QPen * barPen_
Definition: SgGuiPlotter.h:429
bool isXTicsMJD() const
Definition: SgGuiPlotter.h:306
double reverseCalcX(int x) const
Definition: SgGuiPlotter.h:527
QBrush * branchBrushes_
Definition: SgGuiPlotter.h:427
const QString & getName() const
Definition: SgGuiPlotter.h:92
QVector< QString > extKeys_
Definition: SgGuiPlotter.h:114
void flagExtKey(const QString &eKey, bool on)
unsigned int getDataAttr(unsigned int) const
bool isPointInRanges(int idx, unsigned int limits) const
SgMatrix * data_
Definition: SgGuiPlotter.h:110
const QString & getExtKey(int idx)
Definition: SgGuiPlotter.h:104
QVector< bool > extKeysVisible_
Definition: SgGuiPlotter.h:115
unsigned int numOfRows_
Definition: SgGuiPlotter.h:111
QMap< int, QString > alternativeTitleName_
Definition: SgGuiPlotter.h:109
unsigned int numOfRows() const
Definition: SgGuiPlotter.h:82
void xorDataAttr(unsigned int, unsigned int)
void addDataAttr(unsigned int, unsigned int)
SgMatrix * data()
Definition: SgGuiPlotter.h:83
bool getIsBrowsable() const
Definition: SgGuiPlotter.h:90
bool hasExtKeys() const
Definition: SgGuiPlotter.h:100
void setDataAttr(unsigned int, unsigned int)
void delDataAttr(unsigned int, unsigned int)
SgPlotBranch(unsigned int, unsigned int, unsigned int, const QString &, bool hasExtKeys=false)
QString & getAlternativeTitleName(int idx=-1)
Definition: SgGuiPlotter.h:93
bool isPointVisible(int idx, unsigned int limits) const
QVector< QString * > * columnNames()
Definition: SgGuiPlotter.h:164
void createBranch(unsigned int numberOfRows, const QString &branchName, bool hasExtKeys=false)
int getStdVarIdx(int columnIdx) const
Definition: SgGuiPlotter.h:234
QList< SgPlotBranch * > * listOfBranches()
Definition: SgGuiPlotter.h:163
QList< SgPlotBranch * > listOfBranches_
Definition: SgGuiPlotter.h:191
unsigned int numOfValuesColumns() const
Definition: SgGuiPlotter.h:165
void setNameOfColumn(unsigned int, const QString &)
SgPlotCarrier(unsigned int, unsigned int, const QString &)
AxisType getAxisType(int columnIdx) const
Definition: SgGuiPlotter.h:225
QVector< QString * > columnNames_
Definition: SgGuiPlotter.h:198
QString & getName(int idx=-1)
Definition: SgGuiPlotter.h:171
int * dataStdVarIdx_
Definition: SgGuiPlotter.h:200
unsigned int numOfSigmasColumns_
Definition: SgGuiPlotter.h:197
QString file2SaveBaseName_
Definition: SgGuiPlotter.h:193
QMap< int, QString > name_
Definition: SgGuiPlotter.h:190
const QString & getFile2SaveBaseName() const
Definition: SgGuiPlotter.h:173
unsigned int numOfValuesColumns_
Definition: SgGuiPlotter.h:196
unsigned int numOfSigmasColumns() const
Definition: SgGuiPlotter.h:166
QString className() const
Definition: SgGuiPlotter.h:182
bool isOK() const
Definition: SgGuiPlotter.h:167
int numOfColumns() const
Definition: SgGuiPlotter.h:242
void startInquire(const QPoint &)
QAction * normalSizeAction_
Definition: SgGuiPlotter.h:812
void zoomXOut()
QButtonGroup * bgSets2plot_
Definition: SgGuiPlotter.h:780
void doInquire(const QPoint &)
virtual void resizeEvent(QResizeEvent *)
void dataStructureChanged()
void pointInfoRequested(SgPlot *, SgPlotBranch *, int, int, int)
void startMeasuring(const QPoint &)
double scaleX_
Definition: SgGuiPlotter.h:759
void rescaleArea(double, double, int=-1, int=-1)
void processKeyReleaseEvent(QKeyEvent *)
void oUserDefinedChanged(bool)
void processMouseReleaseEvent(QMouseEvent *)
void dmPointsChanged(bool)
void xAxisChanged(int)
void markNextExtKey()
void setFilterNames(const QList< QString > &)
QCheckBox * cbWStdVar_
Definition: SgGuiPlotter.h:794
QAction * zoomInAction_
Definition: SgGuiPlotter.h:806
void modifyRangeLimits(int)
QList< QAction * > filterAuxActions_
Definition: SgGuiPlotter.h:784
void save2Image()
QAction * zoomYOutAction_
Definition: SgGuiPlotter.h:811
QPushButton * pbZommIn_
Definition: SgGuiPlotter.h:798
void stopMeasuring()
QCheckBox * cbLines_
Definition: SgGuiPlotter.h:788
void changeYaxis(int)
void fillBranchesNames()
void markPrevBranch()
QListView * lvBranches_
Definition: SgGuiPlotter.h:781
void branchChanged()
void zoomYOut()
virtual QString className() const
Definition: SgGuiPlotter.h:655
QPushButton * pbZommOut_
Definition: SgGuiPlotter.h:799
QPushButton * pbZommXIn_
Definition: SgGuiPlotter.h:800
void processMouseDoubleClickEvent(QMouseEvent *)
void markAllExtKeysAsSelected()
QList< QAction * > filterActions_
Definition: SgGuiPlotter.h:783
QCheckBox * cbPoints_
Definition: SgGuiPlotter.h:787
SgPlot(SgPlotCarrier *, const QString &, QWidget *=0, unsigned int=0)
QPushButton * pbZommYIn_
Definition: SgGuiPlotter.h:802
QComboBox * cbYAxis_
Definition: SgGuiPlotter.h:779
void dataContentChanged()
QWidget * control()
void zoomXIn()
void processWheelEvent(QWheelEvent *)
void fillAxisNames()
void oWStdVar(bool)
QAction * zoomXInAction_
Definition: SgGuiPlotter.h:807
QPoint oldCursorPosition_
Definition: SgGuiPlotter.h:774
OutputFormat outputFormat_
Definition: SgGuiPlotter.h:761
void startReRanging(const QPoint &)
virtual ~SgPlot()
QAction * zoomXOutAction_
Definition: SgGuiPlotter.h:810
void changeXaxisTemp2(int)
void stopReRanging(bool)
void markAllBranchesAsDeselected()
QPushButton * pbZommXOut_
Definition: SgGuiPlotter.h:801
QCheckBox * cbErrBars_
Definition: SgGuiPlotter.h:789
double scaleY_
Definition: SgGuiPlotter.h:760
void queryData(const QPoint &)
void stopScrollViewport()
QComboBox * cbXAxis_
Definition: SgGuiPlotter.h:778
double minZoomX_
Definition: SgGuiPlotter.h:768
static const double scaleFactor_
Definition: SgGuiPlotter.h:755
SgPlotArea * area_
Definition: SgGuiPlotter.h:757
void doMeasuring(const QPoint &)
void startSelecting(const QPoint &, bool=false)
void modifySets2plot(int)
void colorVChanged(int)
void yAxisChanged(int)
void zoomNormalView()
void changeXaxisTemp(int)
SgPlotScroller * plotScroller_
Definition: SgGuiPlotter.h:756
void setFilterExtNames(const QList< QString > &)
void dmLinesChanged(bool)
void stopSelecting(const QPoint &, bool=false)
QPushButton * pbZommYOut_
Definition: SgGuiPlotter.h:803
void doReRanging(const QPoint &)
void save2File()
void processFilterExtMinus()
QAction * zoomYInAction_
Definition: SgGuiPlotter.h:808
void changeXaxis(int)
void processFilterAuxMinus(const QPoint &)
void doScrollViewport(const QPoint &)
bool isExtKeyViewInSpecialMode_
Definition: SgGuiPlotter.h:819
QCheckBox * cbImpulses_
Definition: SgGuiPlotter.h:790
QFrame * controls_
Definition: SgGuiPlotter.h:758
void processFilterMinus()
void changeYaxisTemp2(int)
void processMousePressEvent(QMouseEvent *)
void setFilterAuxNames(const QList< QString > &)
void markAllExtKeysAsDeselected()
void dmImpulsesChanged(bool)
unsigned int modes_
Definition: SgGuiPlotter.h:764
void processFilterAuxPlus(const QPoint &)
void doSelecting(const QPoint &, bool=false)
double maxZoomY_
Definition: SgGuiPlotter.h:769
void processKeyPressEvent(QKeyEvent *)
double minZoomY_
Definition: SgGuiPlotter.h:770
QCheckBox * cbRangeVisible_
Definition: SgGuiPlotter.h:793
void processFilterPlus()
QCheckBox * cbSymmetrical_
Definition: SgGuiPlotter.h:795
void colorHChanged(int)
void changeYaxisTemp(int)
void processFilterExtPlus()
unsigned int currentKeyModifier_
Definition: SgGuiPlotter.h:814
QAction * zoomOutAction_
Definition: SgGuiPlotter.h:809
QButtonGroup * bgRangeLimits_
Definition: SgGuiPlotter.h:796
void userPressedAKey(SgPlot *, Qt::KeyboardModifiers, int)
void zoomYIn()
QList< QAction * > filterExtActions_
Definition: SgGuiPlotter.h:785
bool isBranchViewInSpecialMode_
Definition: SgGuiPlotter.h:782
void dmErrBarsChanged(bool)
void startScrollViewport(const QPoint &)
void zoomOut()
void markPrevExtKey()
QCheckBox * cbUserDefined_
Definition: SgGuiPlotter.h:792
@ PM_Q_PNT_EXT_PROC
Definition: SgGuiPlotter.h:601
@ PM_WO_AXIS_NAMES
Definition: SgGuiPlotter.h:597
@ PM_HAS_HAVE_ZERO
Definition: SgGuiPlotter.h:594
@ PM_WO_DOTS
Definition: SgGuiPlotter.h:598
@ PM_ERRBARS
Definition: SgGuiPlotter.h:600
@ PM_IMPULSE
Definition: SgGuiPlotter.h:595
@ PM_FILTERS_ENABLED
Definition: SgGuiPlotter.h:602
@ PM_WO_BRANCH_NAMES
Definition: SgGuiPlotter.h:596
@ PM_EXT_KEY_SELECT
Definition: SgGuiPlotter.h:603
void extKeyChanged()
void markAllBranchesAsSelected()
void stopInquire()
SgPlotCarrier * plotCarrier_
Definition: SgGuiPlotter.h:765
QList< QString > extKeys_
Definition: SgGuiPlotter.h:817
void processMouseMoveEvent(QMouseEvent *)
void oVisRang(bool)
void zoomIn()
void colorSChanged(int)
QListView * lvExtKeys_
Definition: SgGuiPlotter.h:818
void setRangeSymmetrical(bool)
void markNextBranch()
double maxZoomX_
Definition: SgGuiPlotter.h:767
QString path2Outputs_
Definition: SgGuiPlotter.h:762
QString name(NameFormat fmt=NF_Human) const
Definition: SgVersion.cpp:54