GraphView::GraphView(
int min,
int max,
QWidget* parent,
const char* name, Qt
::WFlags f
) : Q3ScrollView(parent,name,f|Qt::WResizeNoErase|Qt::WStaticContents),
vscale(1.0),
hscale(1.0),
oVscale(1.0),
oHscale(1.0),
hZoom(1.0),
vZoom(1.0), manscale(false), marker(100),
zoomPop(this),
crossCursor(Qt::CrossCursor),waitCursor(Qt::WaitCursor)
{
leftMark=0; rightMark=0; doingStatistics=false;statsInProgress=0;
if(max < min) max = min;
minval = min;
maxval = max;
setDragAutoScroll(true);
valsPerReport=1;
xLine = 0;
viewport
()->setEraseColor
(QColor("white"));
update_from_move = false;
yAxis = new Axis(minval, maxval, true, this);
xAxis = new Axis(this);
xAxisHeight
= ((QWidget*)xAxis
)->sizeHint
().
height();
yAxisWidth
= ((QWidget*)yAxis
)->sizeHint
().
width();
//hide - the rectangle outside the axis - down and left
hide
->setBackgroundColor
(QColor("white"));
hide->lower();
hide->stackUnder(yAxis);
hide->stackUnder(xAxis);
setMargins(yAxisWidth,0,0,xAxisHeight);
QRect r
= viewport
()->geometry
();
yAxis->setGeometry(r.x()-yAxisWidth,r.y(),yAxisWidth,r.height());
hide->setGeometry(r.x()-yAxisWidth,r.y()+r.height(),yAxisWidth-1,xAxisHeight);
xAxis->setGeometry(r.x()-1,r.y()+r.height(),r.width()+1,xAxisHeight);
conX = contentsX();
conY = contentsY();
resizeContents(1, (int)((maxval-minval)*vscale));
center(0,0); //ensureVisible
size = 0;
visibleSize = visibleWidth();
newScrolling= false;
updSize = 1;
connect(this, SIGNAL( horizontalSliderReleased() ), this, SLOT(processNewXPosition() ) );
viewport()->setCursor(Qt::CrossCursor);
reloadCounter=0;
gVector.push_back(this);
}
//in resize event i am trying to draw line on yaxis, but i don't see the output.
// resize the axis widgets
QRect r
= viewport
()->geometry
();
yAxis->setOffset(contentsY());
yAxis->setGeometry(r.x()-yAxisWidth,r.y(),yAxisWidth,r.height());
xAxis->setOffset(contentsX());
xAxis->setGeometry(r.x()-1,r.y()+r.height(),r.width()+1,xAxisHeight);
hide->setGeometry(r.x()-yAxisWidth,r.y()+r.height(),yAxisWidth-1,xAxisHeight);
QSize os
= re
->oldSize
();
if(os.width() < r.width() && r.width() > ((int)size/hscale-contentsX())) {
int y = ((int)((double)maxval - (double)contentsY()/vscale))%marker;
if(marker*vscale>5){
painter.
setPen(QColor("grey"));
for(; y < r.height(); y+=marker) {
double yd = y * vscale;
painter.drawLine(os.width(),(int)yd,r.width()-1,(int)yd);
update();//added newly for graph issue
}
}
}
setContentsPos ( contentsX(), contentsY()+os.height()-r.height() );
}
GraphView::GraphView(
int min, int max, QWidget* parent, const char* name, Qt::WFlags f
) : Q3ScrollView(parent,name,f|Qt::WResizeNoErase|Qt::WStaticContents),
vscale(1.0),
hscale(1.0),
oVscale(1.0),
oHscale(1.0),
hZoom(1.0),
vZoom(1.0), manscale(false), marker(100),
zoomPop(this),
crossCursor(Qt::CrossCursor),waitCursor(Qt::WaitCursor)
{
leftMark=0; rightMark=0; doingStatistics=false;statsInProgress=0;
if(max < min) max = min;
minval = min;
maxval = max;
setDragAutoScroll(true);
valsPerReport=1;
xLine = 0;
viewport()->setEraseColor(QColor("white"));
update_from_move = false;
yAxis = new Axis(minval, maxval, true, this);
xAxis = new Axis(this);
xAxisHeight = ((QWidget*)xAxis)->sizeHint().height();
yAxisWidth = ((QWidget*)yAxis)->sizeHint().width();
//hide - the rectangle outside the axis - down and left
hide = new QWidget(this);
hide->setBackgroundColor(QColor("white"));
hide->lower();
hide->stackUnder(yAxis);
hide->stackUnder(xAxis);
setMargins(yAxisWidth,0,0,xAxisHeight);
QRect r = viewport()->geometry();
yAxis->setGeometry(r.x()-yAxisWidth,r.y(),yAxisWidth,r.height());
hide->setGeometry(r.x()-yAxisWidth,r.y()+r.height(),yAxisWidth-1,xAxisHeight);
xAxis->setGeometry(r.x()-1,r.y()+r.height(),r.width()+1,xAxisHeight);
conX = contentsX();
conY = contentsY();
resizeContents(1, (int)((maxval-minval)*vscale));
center(0,0); //ensureVisible
size = 0;
visibleSize = visibleWidth();
newScrolling= false;
updSize = 1;
connect(this, SIGNAL( horizontalSliderReleased() ), this, SLOT(processNewXPosition() ) );
viewport()->setCursor(Qt::CrossCursor);
reloadCounter=0;
gVector.push_back(this);
}
//in resize event i am trying to draw line on yaxis, but i don't see the output.
void GraphView::viewportResizeEvent( QResizeEvent* re) {
// resize the axis widgets
QRect r = viewport()->geometry();
yAxis->setOffset(contentsY());
yAxis->setGeometry(r.x()-yAxisWidth,r.y(),yAxisWidth,r.height());
xAxis->setOffset(contentsX());
xAxis->setGeometry(r.x()-1,r.y()+r.height(),r.width()+1,xAxisHeight);
hide->setGeometry(r.x()-yAxisWidth,r.y()+r.height(),yAxisWidth-1,xAxisHeight);
QSize os = re->oldSize();
if(os.width() < r.width() && r.width() > ((int)size/hscale-contentsX())) {
QPainter painter(viewport());
int y = ((int)((double)maxval - (double)contentsY()/vscale))%marker;
if(marker*vscale>5){
painter.setPen(QColor("grey"));
for(; y < r.height(); y+=marker) {
double yd = y * vscale;
painter.drawLine(os.width(),(int)yd,r.width()-1,(int)yd);
update();//added newly for graph issue
}
}
}
setContentsPos ( contentsX(), contentsY()+os.height()-r.height() );
}
To copy to clipboard, switch view to plain text mode
Bookmarks