@@ -120,10 +120,7 @@ GraphWidget::GraphWidget(QWidget* parent): QGraphicsView(parent)
120120 this ->setMinimumHeight (150 );
121121
122122 this ->setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
123- // this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); //fjass
124- // this->verticalScrollBar()->setMaximumWidth(1);
125- this ->verticalScrollBar ()->setMinimumWidth (100 );
126- // this->verticalScrollBar()->hide();
123+ this ->setVerticalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
127124
128125 updateScaleFactors ();
129126
@@ -213,9 +210,10 @@ GraphWidget::GraphWidget(QWidget* parent): QGraphicsView(parent)
213210 setZoom (true );
214211
215212
216- // #if QT_VERSION >= 0x040300
217- // setOptimizationFlags(QGraphicsView::DontAdjustForAntialiasing|QGraphicsView::DontSavePainterState);
218- // #endif
213+ #if QT_VERSION >= 0x040300
214+ setOptimizationFlags (QGraphicsView::DontAdjustForAntialiasing|QGraphicsView::DontSavePainterState);
215+ // setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
216+ #endif
219217}
220218
221219void GraphWidget::originalZoom ()
@@ -658,21 +656,28 @@ qreal GraphWidget::gridDist(qreal &min, qreal &max, qreal dist)
658656 {
659657
660658 distance = (max - min) / 10 .;
659+ // distance = (max - min) / 8.;
661660
662661 qreal tmp = distance;
663662
664663 while (tmp < 1 )
665664 tmp *= 10 ;
665+ // tmp *= 8;
666666
667667
668668 while (tmp > 10 )
669669 tmp /= 10 ;
670+ // while(tmp > 8)
671+ // tmp /= 8;
670672
671673
672674 if (tmp > 5 )
675+ // if(tmp > 4)
673676 distance = 10 *distance/tmp;
677+ // distance = 8*distance/tmp;
674678 else if (tmp > 2 )
675679 distance = 5 *distance/tmp;
680+ // distance = 4*distance/tmp;
676681 else if (tmp > 1 )
677682 distance = 2 *distance/tmp;
678683 else
@@ -809,6 +814,11 @@ void GraphWidget::createGrid(bool numbersOnly)
809814 graphicsScene->grid ->addToGroup (l);
810815 }
811816 QGraphicsTextItem* tmp2 = graphicsScene->xRulerScene ->addText (QVariant (x).toString ());
817+ if (abs (x) < xMinorDist)
818+ {
819+ tmp2->setPlainText (" 0" );
820+ x = 0 ;
821+ }
812822 tmp2->setPos (gvBottom->mapToScene (mapFromScene (x, yMax)).x ()-tmp2->boundingRect ().width ()/2 , gvBottom->sceneRect ().y ());
813823 tmp2->moveBy (0 , -tmp2->boundingRect ().height ()/2 .);
814824 tmp2->show ();
@@ -841,6 +851,7 @@ void GraphWidget::createGrid(bool numbersOnly)
841851 }
842852 }
843853 QGraphicsTextItem* tmp2 = graphicsScene->yRulerScene ->addText (QString (" 1e" ) +QVariant (y).toString ());
854+
844855 tmp2->setPos (gvLeft->mapToScene ( gvLeft->sceneRect ().x () ,mapFromScene (xMax, y).y ()+tmp2->boundingRect ().height ()/2 ));
845856
846857 tmp2->scale (1 , -1 );
@@ -866,13 +877,18 @@ void GraphWidget::createGrid(bool numbersOnly)
866877 }
867878 for (qreal y = yMin-yMajorDist; y < 1.5 * yMajorDist + yMax ; y+= yMajorDist)
868879 {
869- if (abs (y) < 1e-16 )
870- y = 0 ;
880+ // if(abs(y) < 1e-16)
881+ // y = 0;
871882 if (!numbersOnly)
872883 {
873884 graphicsScene->grid ->addToGroup (new Line2D (xMin2, y, xMax2, y, pen2));
874885 }
875886 QGraphicsTextItem* tmp2 = graphicsScene->yRulerScene ->addText (QVariant (y).toString ());
887+ if (abs (y) < yMinorDist)
888+ {
889+ tmp2->setPlainText (" 0" );
890+ y = 0 ;
891+ }
876892 tmp2->setPos (gvLeft->mapToScene ( gvLeft->sceneRect ().x () ,mapFromScene (xMax, y).y ()+tmp2->boundingRect ().height ()/2 ));
877893
878894 tmp2->scale (1 , -1 );
@@ -1576,6 +1592,8 @@ void GraphWidget::plotPtolemyDataStream()
15761592
15771593 LegendLabel* ll;
15781594
1595+ legendFrame->setMinimumWidth (0 );
1596+
15791597 for (quint32 i = 0 ; i < variableCount; ++i)
15801598 {
15811599 ds >> tmp;
@@ -1607,12 +1625,22 @@ void GraphWidget::plotPtolemyDataStream()
16071625
16081626
16091627 yVars.push_back (tmp);
1610- ll = new LegendLabel (color, tmp,legendFrame, !(interpolation_ == INTERPOLATION_NONE), points);
1628+ ll = new LegendLabel (color, tmp,legendFrame, !(interpolation_ == INTERPOLATION_NONE), points, 21 );
16111629 ll->graphWidget = this ;
16121630
1613- ll->setMaximumHeight (21 );
1631+ // ll->setMaximumHeight(21);
1632+ // ll->setMinimumWidth(0);
1633+
1634+ // if(!legendLayout->count() || true)
1635+ // {
1636+ // legendFrame->setMinimumWidth(ll->minimumWidth()+5);
1637+ legendFrame->setMinimumWidth (max (ll->fontMetrics ().width (tmp)+41 +4 , legendFrame->minimumWidth ()));
1638+ // QMessageBox::information(0, QVariant(legendFrame->minimumWidth()).toString(), QVariant(legendFrame->width()).toString());
1639+ // }
16141640 legendLayout->addWidget (ll);
16151641 ll->show ();
1642+
1643+
16161644
16171645 temporaryCurves[tmp] = (new Curve (variables[currentXVar], variables[tmp], color, ll));
16181646 ll->setCurve (temporaryCurves[tmp]);
0 commit comments