当前位置: 首页>>代码示例>>C++>>正文


C++ PlotSettings::spanX方法代码示例

本文整理汇总了C++中PlotSettings::spanX方法的典型用法代码示例。如果您正苦于以下问题:C++ PlotSettings::spanX方法的具体用法?C++ PlotSettings::spanX怎么用?C++ PlotSettings::spanX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PlotSettings的用法示例。


在下文中一共展示了PlotSettings::spanX方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: drawGrid

void plotter::drawGrid(QPainter *painter)
{
    QRect rect(Margin, Margin,
               width() - 2 * Margin, height() - 2 * Margin);
    if (!rect.isValid())
        return;

    PlotSettings settings = zoomStack[curZoom];
    QPen quiteDark=palette().dark().color().dark();

    //chepia del libro de QT
    for (int i = 0; i <= settings.numXTicks; ++i) {

         int x = rect.left() + (i * (rect.width() - 1)
                                  / settings.numXTicks);
         double label = settings.minX + (i * settings.spanX()
                                           / settings.numXTicks);
         painter->setPen(quiteDark);
         //painter->drawLine(x, rect.bottom(), x, rect.bottom() + 5);
         painter->drawText(x - 50, rect.bottom() + 5, 100, 20,
                              Qt::AlignHCenter | Qt::AlignTop,
                              QString::number(label));
    }
    for (int j = 0; j <= settings.numYTicks; ++j) {
        int y = rect.bottom() - (j * (rect.height() - 1)
                                   / settings.numYTicks);
        double label = settings.minY + (j * settings.spanY()
                                          / settings.numYTicks);
        painter->setPen(quiteDark);
        //painter->drawLine(rect.left() - 5, y, rect.left(), y);
        painter->drawText(rect.left() - Margin, y - 10, Margin - 5, 20,
                             Qt::AlignRight | Qt::AlignVCenter,
                             QString::number(label));
    }
    painter->drawRect(rect.adjusted(0, 0, -1, -1));


    //esto si es mio :)
    quiteDark.setBrush(Qt::red);
    quiteDark.setStyle(Qt::DashLine);
    painter->setPen(quiteDark);
    int x=rect.left() + ((-settings.minX*settings.numXTicks/settings.spanX()) * (rect.width() - 1)
                         / settings.numXTicks);
    painter->drawLine(x, rect.top(), x, rect.bottom());

    int y=rect.bottom() + ((-settings.minY*settings.numYTicks/settings.spanY()) * (rect.width() - 1)
                         / settings.numYTicks);
    painter->drawLine(rect.left(), y, rect.right(), y);
}
开发者ID:nbermudezs,项目名称:data-structure-class,代码行数:49,代码来源:plotter.cpp

示例2: getPath

QPainterPath GraphParametric::getPath(const QRect &plotRect, const PlotSettings &settings)
{
    double pdx=settings.spanX()/plotRect.width();
    double pdy=settings.spanY()/plotRect.height();
    double min=graphSettings.getMin();
    double max=graphSettings.getMax();
    int steps_count = graphSettings.getStepsCount();
    if (steps_count == 0)
        steps_count = 500;
    double dt=(max-min)/steps_count;
    QPainterPath path;
    if (!xVals)
        xVals = createFValsStruct(f, min, dt, steps_count+1, graphSettings.getMaxGap());
    if (!yVals)
        yVals = createFValsStruct(fY, min, dt, steps_count+1, graphSettings.getMaxGap());
    double t=min;
    for (int j=0; j<xVals->count; j++)
    {
        if (xVals->actions[j] == LINE && yVals->actions[j] == LINE)
        {
            path.lineTo(QPointF(plotRect.left() + (xVals->values[j]-settings.minX)/pdx,
                                plotRect.bottom() - (yVals->values[j]-settings.minY)/pdy));
        }
        else if (xVals->actions[j] == MOVE || yVals->actions[j] == MOVE)
        {
            path.moveTo(QPointF(plotRect.left() + (xVals->values[j]-settings.minX)/pdx,
                                plotRect.bottom() - (yVals->values[j]-settings.minY)/pdy));
        }
        t += dt;
    }
    return path;
}
开发者ID:AlexanderMuzalev,项目名称:Math-Representer,代码行数:32,代码来源:graph.cpp

示例3: drawGrid

void plotter::drawGrid(QPainter *painter)
{
    QRect rect(xMargin, Margin, width()-2*xMargin, height() -2*Margin);
    if(!rect.isValid()) return;

    PlotSettings settings = zoomStack[curZoom];
    QPen quiteDark = palette().dark().color().light();
    QPen light = palette().light().color();

    for(int i=0; i<=settings.numXTicks;++i)
    {
        int x = rect.left() + (i*(rect.width()-1)/settings.numXTicks);
        double label = settings.minX + (i*settings.spanX()/settings.numXTicks);
        painter->setPen(quiteDark);
        painter->drawLine(x,rect.top(),x,rect.bottom());
        painter->setPen(light);
        painter->drawLine(x,rect.bottom(),x,rect.bottom()-5);
        painter->drawText(x,rect.bottom()+5,100,20,Qt::AlignLeft, QString::number(label));
    }

    for(int j=0; j<=settings.numYTicks;++j)
    {
        int y = rect.bottom() - (j*(rect.height()-1)/settings.numYTicks);
        double label = settings.minY + (j*settings.spanY()/settings.numYTicks);
        painter->setPen(quiteDark);
        painter->drawLine(rect.left(),y,rect.right(),y);
        painter->setPen(light);
        painter->drawLine(rect.left()+5 ,y, rect.left(),y);
        painter->drawText(rect.left()- xMargin -20, y-10, 100,20,
                          Qt::AlignVCenter|Qt::AlignRight, QString::number(label));
    }
    painter->drawRect(rect.adjusted(0,0,-1,-1));

}
开发者ID:TiKunze,项目名称:mne-cpp,代码行数:34,代码来源:plotter.cpp

示例4: mouseReleaseEvent

void plotter::mouseReleaseEvent(QMouseEvent *event)
{
    if ((event->button() == Qt::LeftButton) && rubberBandIsShown) {
        rubberBandIsShown = false;
        updateRubberBandRegion();
        unsetCursor();

        QRect rect = rubberBandRect.normalized();
        if (rect.width() < 4 || rect.height() < 4)
            return;
        rect.translate(-Margin, -Margin);

        PlotSettings prevSettings = zoomStack[curZoom];
        PlotSettings settings;
        double dx = prevSettings.spanX() / (width() - 2 * Margin);
        double dy = prevSettings.spanY() / (height() - 2 * Margin);
        settings.minX = prevSettings.minX + dx * rect.left();
        settings.maxX = prevSettings.minX + dx * rect.right();
        settings.minY = prevSettings.maxY - dy * rect.bottom();
        settings.maxY = prevSettings.maxY - dy * rect.top();
        settings.adjust();

        zoomStack.resize(curZoom + 1);
        zoomStack.append(settings);
        zoomIn();
    }
}
开发者ID:nbermudezs,项目名称:data-structure-class,代码行数:27,代码来源:plotter.cpp

示例5: drawCurves

void plotter::drawCurves(QPainter *painter)
{
    static const QColor colorForIds[6] = {
        Qt::blue, Qt::green, Qt::red, Qt::cyan, Qt::magenta, Qt::yellow
    };
    PlotSettings settings = zoomStack[curZoom];
    QRect rect(Margin, Margin,
               width() - 2 * Margin, height() - 2 * Margin);
    if (!rect.isValid())
        return;

    painter->setClipRect(rect.adjusted(+1, +1, -1, -1));

    //Esto lo deje asi porque en teoria serviria para graficar varias funciones en un mismo plot
    QMapIterator<int, QVector<QPointF> > i(curveMap);
    while (i.hasNext()) {
        i.next();

        int id = i.key();
        QVector<QPointF> data = i.value();
        QPolygonF polyline(data.count());
        for (int j = 0; j < data.count(); ++j) {
            double dx = data[j].x() - settings.minX;
            double dy = data[j].y() - settings.minY;
            double x = rect.left() + (dx * (rect.width() - 1)
                                         / settings.spanX());
            double y = rect.bottom() - (dy * (rect.height() - 1)
                                           / settings.spanY());
            polyline[j] = QPointF(x, y);
        }
        painter->setPen(colorForIds[uint(id) % 6]);
        painter->drawPolyline(polyline);
    }
}
开发者ID:nbermudezs,项目名称:data-structure-class,代码行数:34,代码来源:plotter.cpp

示例6: drawCurves

void Plotter::drawCurves(QPainter *painter)
{
    //设置为静态变量,可以使得函数调用时不用每次都进行初始化。
    static const QColor colorForIds[6] =
    {
        Qt::red, Qt::green, Qt::blue, Qt::cyan, Qt::magenta, Qt::yellow
    };

    PlotSettings settings = zoomStack[curZoom];
    QRect rect(Margin, Margin, width() - 2 * Margin, height() - 2 * Margin);
    if (!rect.isValid())
        return;

    /*We start by calling setClipRect() to set the QPainter's clip region to the
      rectangle that contains the curves (excluding the margins and the frame around the graph).
      QPainter will then ignore drawing operations on pixels outside the area.
     */
    painter->setClipRect(rect.adjusted(+1, +1, -1, -1));
    QMapIterator<int, QVector<QPointF> > i(curveMap);
    while (i.hasNext())
    {
        i.next();
        int id = i.key();
        const QVector<QPointF> &data = i.value();
        QPolygonF polyline(data.count());
        for (int j = 0; j < data.count(); ++j)
        {
            double dx = data[j].x() - settings.minX;
            double dy = data[j].y() - settings.minY;
            double x = rect.left() + (dx * (rect.width() - 1)
                                         / settings.spanX());
            double y = rect.bottom() - (dy * (rect.height() - 1)
                                           / settings.spanY());
            polyline[j] = QPointF(x, y);
        }
        painter->setPen(colorForIds[uint(id) % 6]);
        painter->drawPolyline(polyline);
    }
}
开发者ID:kernelhcy,项目名称:hcyprojects,代码行数:39,代码来源:plotter.cpp

示例7: drawCurves

void Plotter::drawCurves(QPainter *painter)
{
    static const QColor colorForIds[6] = {
        red, green, blue, cyan, magenta, yellow
    };
    PlotSettings settings = zoomStack[curZoom];
    QRect rect(Margin, Margin,
               width() - 2 * Margin, height() - 2 * Margin);

    painter->setClipRect(rect.x() + 1, rect.y() + 1,
                         rect.width() - 2, rect.height() - 2);

    map<int, CurveData>::const_iterator it = curveMap.begin();
    while (it != curveMap.end()) {
        int id = (*it).first;
        const CurveData &data = (*it).second;
        int numPoints = 0;
        int maxPoints = data.size() / 2;
        QPointArray points(maxPoints);

        for (int i = 0; i < maxPoints; ++i) {
            double dx = data[2 * i] - settings.minX;
            double dy = data[2 * i + 1] - settings.minY;
            double x = rect.left() + (dx * (rect.width() - 1)
                                         / settings.spanX());
            double y = rect.bottom() - (dy * (rect.height() - 1)
                                           / settings.spanY());
            if (fabs(x) < 32768 && fabs(y) < 32768) {
                points[numPoints] = QPoint((int)x, (int)y);
                ++numPoints;
            }
        }
        points.truncate(numPoints);
        painter->setPen(colorForIds[(uint)id % 6]);
        painter->drawPolyline(points);
        ++it;
    }
}
开发者ID:EleVenPerfect,项目名称:OTHERS,代码行数:38,代码来源:plotter.cpp

示例8: drawGrid

void Plotter::drawGrid(QPainter *painter)
{
    QRect rect(Margin, Margin,
               width() - 2 * Margin, height() - 2 * Margin);
    PlotSettings settings = zoomStack[curZoom];
    QPen quiteDark = colorGroup().dark().light();
    QPen light = colorGroup().light();

    for (int i = 0; i <= settings.numXTicks; ++i) {
        int x = rect.left() + (i * (rect.width() - 1)
                                 / settings.numXTicks);
        double label = settings.minX + (i * settings.spanX()
                                          / settings.numXTicks);
        painter->setPen(quiteDark);
        painter->drawLine(x, rect.top(), x, rect.bottom());
        painter->setPen(light);
        painter->drawLine(x, rect.bottom(), x, rect.bottom() + 5);
        painter->drawText(x - 50, rect.bottom() + 5, 100, 15,
                          AlignHCenter | AlignTop,
                          QString::number(label));
    }
    for (int j = 0; j <= settings.numYTicks; ++j) {
        int y = rect.bottom() - (j * (rect.height() - 1)
                                   / settings.numYTicks);
        double label = settings.minY + (j * settings.spanY()
                                          / settings.numYTicks);
        painter->setPen(quiteDark);
        painter->drawLine(rect.left(), y, rect.right(), y);
        painter->setPen(light);
        painter->drawLine(rect.left() - 5, y, rect.left(), y);
        painter->drawText(rect.left() - Margin, y - 10,
                          Margin - 5, 20,
                          AlignRight | AlignVCenter,
                          QString::number(label));
    }
    painter->drawRect(rect);
}
开发者ID:EleVenPerfect,项目名称:OTHERS,代码行数:37,代码来源:plotter.cpp

示例9: getObjectRect

QRect ScatterView::getObjectRect(long int row)
{
	if(!table) return QRect();

	QRect rect(LMargin, TMargin, this->width() - (LMargin+RMargin), this->height() - (BMargin+TMargin));
	PlotSettings settings = *mySettings;

	//double valueX = table->GetValue(row,columnNumForX).ToDouble();
    double valueX = table->data(table->index(row, columnNumForX, QModelIndex())).toDouble();
	//double valueY = table->GetValue(row,columnNumForY).ToDouble();
    double valueY = table->data(table->index(row, columnNumForY, QModelIndex())).toDouble();
	//Adjust for normalization:
	if(settings.normalize == true)
	{
		valueX = -1 + 2* (valueX - settings.d_minX)/(settings.d_maxX - settings.d_minX);
		valueY = -1 + 2* (valueY - settings.d_minY)/(settings.d_maxY - settings.d_minY);
	}

    double dx = valueX - settings.minX;
	double dy = valueY - settings.minY;
	double x = rect.left() + (dx * (rect.width() - 1) / settings.spanX());
	double y = rect.bottom() - (dy * (rect.height() - 1) / settings.spanY());
	return QRect(int(x-2),int(y-2),5,5);
}
开发者ID:JumperWang,项目名称:farsight-clone,代码行数:24,代码来源:ScatterView.cpp

示例10: drawGrid

//***************************************************************************************************
//The drawGrid() function draws the grid behind the curves and the axes. The area on which we draw
//the grid is specified by rect. If the widget isn't large enough to accommodate the graph, we return
//immediately.
//The first for loop draws the grid's vertical lines and the ticks along the x axis. The second for loop
//draws the grid's horizontal lines and the ticks along the y axis. At the end, we draw a rectangle
//along the margins. The drawText() function is used to draw the numbers corresponding to the tick
//marks on both axes.
//The calls to drawText() have the following syntax:
//painter->drawText(x, y, width, height, alignment, text);
//where (x, y, width, height) define a rectangle, alignment the position of the text within that
//rectangle, and text the text to draw.
//***************************************************************************************************
void ScatterView::drawGrid(QPainter *painter)
{	
	//This rectangle is the graph area
	QRect rect(LMargin, TMargin, this->width() - (LMargin+RMargin), this->height() - (BMargin+TMargin));
	if (!rect.isValid())
		return;
	//Retrieve current plotSettings
	//PlotSettings settings = PlotSettings();
	PlotSettings settings = *mySettings;
	QPen quiteDark = palette().dark().color().light();
	QPen light = palette().light().color();
	//Draw vertical lines
	for (int i = 0; i <= settings.numXTicks; ++i) 
	{
		int x = rect.left() + (i * (rect.width() - 1) / settings.numXTicks);
		double label = settings.minX + (i * settings.spanX() / settings.numXTicks);
		//painter->setPen(quiteDark);
		painter->setPen(QPen(QBrush(Qt::black),1,Qt::DotLine));
		painter->drawLine(x, rect.top(), x, rect.bottom());
		//painter->setPen(light);
		painter->drawLine(x, rect.bottom(), x, rect.bottom() + 5);
		painter->setPen(QPen(QBrush(Qt::black),1));
		painter->drawText(x - 50, rect.bottom() + 5, 100, 15, Qt::AlignHCenter | Qt::AlignTop, QString::number(label));
	}
	for (int j = 0; j <= settings.numYTicks; ++j) 
	{
		int y = rect.bottom() - (j * (rect.height() - 1) / settings.numYTicks);
		double label = settings.minY + (j * settings.spanY() / settings.numYTicks);
		//painter->setPen(quiteDark);
		painter->setPen(QPen(QBrush(Qt::black),1,Qt::DotLine));
		painter->drawLine(rect.left(), y, rect.right(), y);
		//painter->setPen(light);
		painter->drawLine(rect.left() - 5, y, rect.left(), y);
		painter->setPen(QPen(QBrush(Qt::black),1));
		painter->drawText(rect.left() - LMargin, y - 10, LMargin - 5, 20,
			Qt::AlignRight | Qt::AlignVCenter,
			QString::number(label));
	}
	painter->drawRect(rect.adjusted(0, 0, -1, -1));
	
	//Now draw the labels for the x and y axis:
	QString xName;
	QString yName;
	if(table)
	{
		//xName = QString( table->GetColumnName(columnNumForX) );
		xName = table->headerData(columnNumForX, Qt::Horizontal).toString();
		//yName = QString( table->GetColumnName(columnNumForY) );
		yName = table->headerData(columnNumForY, Qt::Horizontal).toString();
	}
	else
	{
		xName = QString("x");
		yName = QString("y");
	}

    QFont fp = painter->font();
    fp.setBold(true);
    painter->setFont(fp);
	painter->setPen(Qt::blue);
	painter->drawText(rect.left(),rect.bottom() + 20, rect.width(), 20, Qt::AlignHCenter, xName);
	painter->save();
	painter->rotate(-90);
	painter->drawText(-1*rect.bottom(), rect.top() - TMargin, rect.height(), 20, Qt::AlignHCenter, yName);
	painter->restore();
}
开发者ID:JumperWang,项目名称:farsight-clone,代码行数:79,代码来源:ScatterView.cpp

示例11: drawCurves

void Plotter::drawCurves(QPainter *painter)
{
	//printf("Inside DrawCurves\n");


    static const QColor colorForIds[7] = {Qt::red,Qt::green,Qt::cyan,Qt::magenta,Qt::yellow,Qt::blue,Qt::white};
    PlotSettings settings = zoomStack[curZoom];
    if( m_moveFlag == true)
    {
        settings.maxX = m_ZoomSettings->maxX;
        settings.maxY = m_ZoomSettings->maxY;
        settings.minX = m_ZoomSettings->minX;
        settings.minY = m_ZoomSettings->minY;
        settings.m_nOffset = m_ZoomSettings->m_nOffset;
        settings.numXTicks = m_ZoomSettings->numXTicks;
        settings.numYTicks = m_ZoomSettings->numYTicks;
    }
    QRect rect(Margin,Margin,width()-(2*Margin),height()-(2*Margin));
    //qDebug()<<"Draw Curves:"<< settings.m_nOffset;
    if(m_bshowZoomRect == true)
    {
        painter->setPen(colorForIds[6]);
        painter->drawRect(rubberBandRect);
    }

    if(!rect.isValid())
        return;
    painter->setClipRect(rect.adjusted(+1,+1,-1,-1));
    QMapIterator<int, QVector<QPointF> > i(curveMap);
//    printf("Rect Left: %d\n",rect.left());
//    printf("Rect Height: %d\n",rect.height());
//    printf("Rect width: %d\n",rect.width());
//    printf("Rect Bottom: %d\n",rect.bottomLeft().y());
//    printf("Rect Top: %d\n",rect.top());
    double dx,dy;
    while(i.hasNext()){

        i.next();
        int id = i.key();
        QVector<QPointF> data = i.value();
        QPolygonF polyline(data.count());
        double y =0.0,x=0.0;
        int l_nCounter =0;
        //printf("MinY:%f\n",settings.minY);
        //printf("Offset:%f\n",m_nOffset);
        for(int j=0; j< data.count();++j)
        {
             dx = data[j].x();
             dy = data[j].y();
             if(m_bUniPolar == true)
             {
                 float l_nDiv = (dy/2.0);
                 printf("UniPolar %f->%f\n",l_nDiv,dy - l_nDiv);
             }
             if(( data[j].x()>=settings.minX && data[j].x()<=settings.maxX))
             {
                 //printf("X:%f Y:%f\n",dx,dy);
             }
            y =0.0,x=0.0;
            if(m_ZoomFlag == false)
            {
                if(m_bVIMode == true)
                    x = (rect.width()/2+ (dx*(((rect.width()-1)))/(settings.spanX())));
                else
                    x = (rect.left()+ (dx*(((rect.width()-1)))/(settings.spanX())));

                if( m_bUniPolar == true){
                    y = ((Margin+rect.bottom()) - (((dy/2.0)+settings.m_nOffset)*((rect.height()-1))/(settings.spanY())));
                    printf(" Coord-Y %f\n",dy/2.0);
                }
                else
                    y = ((Margin+rect.height()) - (((dy-settings.minY)+settings.m_nOffset)*((rect.height()-1))/(settings.spanY())));
                	//y = ((Margin+rect.height()/2) - ((dy*rect.height()-1)/4.096));/*((rect.height()-1))));*/
                	//y = (Margin+rect.height()/2) - (dy);
               // printf(" Coord- X & Y %f %f\n",x,y);
               // qDebug() << dy;
            }
            else if(m_ZoomFlag == true)
            {
                x = (rect.left() + ((dx-settings.minX)*(((rect.width()-1)))/(settings.spanX())));
                y = ((Margin+rect.height()) - (((dy-settings.minY)+settings.m_nOffset)*((rect.height()-1))/(settings.spanY())));
            }
            if(( data[j].x()>=settings.minX && data[j].x()<=settings.maxX)&&(( data[j].y()>=settings.minY && data[j].y()<=settings.maxY)))
            {
                polyline[j] = QPointF(x,y);
                l_nCounter++;
            }
        }
        QPolygonF zoomPolyline(l_nCounter);
        y =0.0,x=0.0;
        int l_nIndex1 =0;
        for(int l_nIndex=0;l_nIndex< data.count();l_nIndex++)
        {
            QPointF(x,y);
            x = polyline.at(l_nIndex).x();
            y = polyline.at(l_nIndex).y();
            if(x!=0.0 || y!=0.0 )
            {
                zoomPolyline[l_nIndex1] = QPointF(x,y);
                l_nIndex1++;
//.........这里部分代码省略.........
开发者ID:Qmax,项目名称:PT6,代码行数:101,代码来源:plotter.cpp

示例12: drawGrid

void Plotter::drawGrid(QPainter *painter)
{
	//printf("Inside DrawGrid\n");
	//qDebug() << "Inside DrawGrid";
    QRect rect(Margin,Margin,width()-2*Margin,height()-2*Margin);
    if(!rect.isValid())
        return;
    QPen pen;
    QColor objColor(80,80,80,255);
    pen.setBrush(Qt::gray);
    pen.setStyle(Qt::DotLine);
    pen.setColor(objColor);
    pen.setCapStyle(Qt::RoundCap);
    pen.setJoinStyle(Qt::RoundJoin);
    painter->setPen(pen);
    //QPoint *pixPoint = new QPoint();
    PlotSettings settings = zoomStack[curZoom];
    if(m_bGrid)
    {
        for(int i=0;i<settings.numXTicks;i++)
        {
            int x = rect.left() + (i * (rect.width()) / settings.numXTicks);
            double label = settings.minX + (i*settings.spanX()/settings.numXTicks);
            //printf("X Axis:%f\n",label);
            for(float l_nPoint=1;l_nPoint<rect.height();l_nPoint+=2.0)
                painter->drawPoint(QPointF(x,rect.top()+l_nPoint));
            //painter->drawLine(x,rect.bottom(),x,rect.bottom()+5);
            painter->drawText(x-50,rect.bottom()+5,100,20, Qt::AlignHCenter|Qt::AlignTop,QString::number(label,5,2));
        }
        for(int j=0;j<settings.numYTicks;j++)
        {

            int y = rect.bottom() - (j * (rect.height()) / settings.numYTicks);
            double label = (settings.minY+settings.m_nOffset) + (j*settings.spanY()/settings.numYTicks);
           // qDebug()<<"Label:"<<label;
            //double label = (settings.m_nOffset)+(-4 *settings.maxY) + (j*settings.maxY);
            //printf("Y Axis:%f\n",label);
            for(float l_nPoint=0;l_nPoint<rect.width();l_nPoint+=2.0)
                painter->drawPoint(QPointF(rect.left()+l_nPoint,y));
            //painter->drawLine(rect.left(),y,rect.right(),y);
            painter->drawText(rect.left()-Margin,y-10,Margin, 20,Qt::AlignRight|Qt::AlignVCenter,QString::number(label,'e',2));
        }

    pen.setStyle(Qt::SolidLine);
    painter->setPen(pen);
    //int Value =0;
    
        for(int i=0;i<rect.height();i+=((rect.height()/settings.numYTicks)/5))
        {
            if(i!=0 && i%5!=0){
                //painter->drawLine(Margin+rect.width()/2-3,Margin+i,Margin+rect.width()/2+3,Margin+i);
            }
        }
        for(int j=0;j<rect.width();j+=(rect.width()/settings.numXTicks)/5 )
        {
            if(j!=0 && j%5!=0){
                //painter->drawLine(Margin+j,Margin+rect.height()/2-3,Margin+j,Margin+rect.height()/2+3);
            }
        }
    }
    if(m_bGrid == false){
        pen.setStyle(Qt::SolidLine);
        pen.setBrush(Qt::gray);
        pen.setWidth(1);
        painter->setPen(pen);
        painter->drawLine(Margin+rect.width()/2,Margin,Margin+rect.width()/2,Margin+rect.height());
        painter->drawLine(Margin,Margin+rect.height()/2-1,Margin+rect.width(),Margin+rect.height()/2-1);
    }
    if(m_bVILabels == true)
    {
        painter->drawText(Margin+rect.width()/2,0,20,20,Qt::AlignHCenter|Qt::AlignTop,QString::number(3.5));
        painter->drawText(0,Margin+rect.height()/2,20,20,Qt::AlignHCenter|Qt::AlignTop,QString::number(3.5));
        painter->drawText(Margin+rect.width()-20,Margin+rect.height()/2,20,20,Qt::AlignHCenter|Qt::AlignTop,QString::number(3.5));
        painter->drawText(Margin+rect.height(),Margin+rect.height()-20,20,20,Qt::AlignHCenter|Qt::AlignTop,QString::number(3.5));

    }
    painter->drawRect(rect.adjusted(+1,+1,-1,-1));
    //printf("outSide DrawGrid\n");
    //painter->drawRect(rect.adjusted(+0,+0,-1,-1));
}
开发者ID:Qmax,项目名称:PT6,代码行数:80,代码来源:plotter.cpp

示例13: keyPressEvent

void Plotter::keyPressEvent(QKeyEvent *event)
{
    switch(event->key())
    {
    case Qt::Key_Right:
        if(rubberBandRect.x() < this->width()-(rubberBandRect.width()-10))
        {
        rubberBandRect.setLeft(rubberBandRect.x() + 10);
        rubberBandRect.setWidth(rubberBandRect.width()+10);
        updateRubberBandRegion();
        }
        break;
    case Qt::Key_Left:
        if(rubberBandRect.x() > 10){
        rubberBandRect.setLeft(rubberBandRect.x() - 10);
        rubberBandRect.setWidth(rubberBandRect.width()-10);
        updateRubberBandRegion();

    }
        break;
    case Qt::Key_Down:
        if(rubberBandRect.y() < this->height()-rubberBandRect.height()){
        rubberBandRect.setTop(rubberBandRect.y() + 10);
        rubberBandRect.setHeight(rubberBandRect.height()+10);
        updateRubberBandRegion();

    }
        break;
    case Qt::Key_Up:
        if(rubberBandRect.y() >0){
        rubberBandRect.setTop(rubberBandRect.y() - 10);
        rubberBandRect.setHeight(rubberBandRect.height()-10);
        updateRubberBandRegion();

    }
        break;
     default: QWidget::keyPressEvent(event);
    }
    QRect rect = rubberBandRect.normalized();
    if(rect.width() < 4 || rect.height() < 4 )
    {
        return;
    }
    rect.translate(-Margin,-Margin);
    PlotSettings prevSettings = zoomStack[curZoom];
    PlotSettings settings;
    settings.m_nOffset = prevSettings.m_nOffset;
    double dx = prevSettings.spanX() / (width()-2*Margin);
    double dy = prevSettings.spanY() / (height()-2*Margin);
    settings.minX = prevSettings.minX + dx * rect.left();
    settings.maxX = prevSettings.minX + dx * rect.right();
    settings.minY = prevSettings.maxY - dy * rect.bottom();
    settings.maxY = prevSettings.maxY - dy * rect.top();
    settings.adjust();
    PlotSettings *pTemp = new PlotSettings();
    pTemp = &settings;
    zoomStack.resize(curZoom + 1);
    zoomStack.append(settings);
    refreshPixmap();
    emit moveWindow(rubberBandRect,settings);
}
开发者ID:Qmax,项目名称:PT6,代码行数:61,代码来源:plotter.cpp


注:本文中的PlotSettings::spanX方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。