Plotter::Plotter( QWidget *parent ):
    QwtPlot( parent )
{
    // Assign a title
    setTitle( "WAVE DATA" );

    QwtPlotCanvas *canvas = new QwtPlotCanvas();
    canvas->setFrameStyle( QFrame::Box | QFrame::Plain );
    canvas->setLineWidth( 1 );
    canvas->setPalette( Qt::white );

    setCanvas( canvas );

    alignScales();

    // Insert grid
    d_grid = new QwtPlotGrid();
    d_grid->attach( this );

    // Axis
    setAxisTitle( QwtPlot::xBottom, "Time" );
//    setAxisScale( QwtPlot::xBottom, -d_interval, 0.0 );

    setAxisTitle( QwtPlot::yLeft, "Amplitude" );
//    setAxisScale( QwtPlot::yLeft, -1.0, 1.0 );

    resize(600, 350);
}
Пример #2
0
void Z3DCanvasRenderer::deinitialize()
{
  setCanvas(NULL);
  CHECK_GL_ERROR;

  Z3DRenderProcessor::deinitialize();
}
Пример #3
0
BarChart::BarChart( QWidget *parent ):
    QwtPlot( parent )
{
    const struct 
    {
        const char *distro;
        const int hits;
        QColor color;

    } pageHits[] =
    {
        { "Arch", 1114, QColor( "DodgerBlue" ) },
        { "Debian", 1373, QColor( "#d70751" ) },
        { "Fedora", 1638, QColor( "SteelBlue" ) },
        { "Mageia", 1395, QColor( "Indigo" ) },
        { "Mint", 3874, QColor( 183, 255, 183 ) },
        { "openSuSE", 1532, QColor( 115, 186, 37 ) },
        { "Puppy", 1059, QColor( "LightSkyBlue" ) },
        { "Ubuntu", 2391, QColor( "FireBrick" ) }
    };

    setAutoFillBackground( true );
    setPalette( QColor( "Linen" ) );

    QwtPlotCanvas *canvas = new QwtPlotCanvas();
    canvas->setLineWidth( 2 );
    canvas->setFrameStyle( QFrame::Box | QFrame::Sunken );
    canvas->setBorderRadius( 10 );

    QPalette canvasPalette( QColor( "Plum" ) );
    canvasPalette.setColor( QPalette::Foreground, QColor( "Indigo" ) );
    canvas->setPalette( canvasPalette );

    setCanvas( canvas );

    setTitle( "DistroWatch Page Hit Ranking, April 2012" );

    d_barChartItem = new DistroChartItem();

    QVector< double > samples;

    for ( uint i = 0; i < sizeof( pageHits ) / sizeof( pageHits[ 0 ] ); i++ )
    {
        d_distros += pageHits[ i ].distro;
        samples += pageHits[ i ].hits;

        d_barChartItem->addDistro( 
            pageHits[ i ].distro, pageHits[ i ].color );
    }

    d_barChartItem->setSamples( samples );

    d_barChartItem->attach( this );

    insertLegend( new QwtLegend() );

    setOrientation( 0 );
    setAutoReplot( false );
}
Пример #4
0
/**
 * Modview contructor.
 */
ModView::ModView(char *name, QWidget *parent) : QCanvasView(0,parent)
{
     modCanvas=new ModCanvas(name,this);
     setCanvas(modCanvas);
     resize(sizeHint());
     setMaximumSize(sizeHint());
     setMinimumSize(sizeHint());
}
Пример #5
0
    Plot( QWidget *parent = NULL ):
        QwtPlot( parent )
    {
        QwtPlotCanvas *canvas = new QwtPlotCanvas();
        canvas->setLineWidth( 1 );
        canvas->setFrameStyle( QFrame::Box | QFrame::Plain );

        setCanvas( canvas );
    }
SweepInspector::SweepInspector(QWidget *parent) : QwtPlot(parent), data(NULL), d_curve(NULL), picker(NULL) {
  setObjectName( "SweepData" );
  setTitle( "RF Sweep" );
  setAxisTitle( QwtPlot::xBottom, "Frequency");
  setAxisTitle( QwtPlot::yLeft, QString( "Power Level (dBm)"));
  setAutoReplot(true);

  enableAxis(QwtPlot::xBottom, true);
  enableAxis(QwtPlot::yLeft, true);
  enableAxis(QwtPlot::xTop, false);
  enableAxis(QwtPlot::yRight, false);

  canvas = new QwtPlotCanvas();
  canvas->setPalette( Qt::black );
  canvas->setBorderRadius(0);
  setCanvas(canvas);

  //Allow zooming / panning
  zoomer = new QwtPlotZoomer( canvas );
  zoomer->setRubberBandPen( QColor( Qt::white ) );
  zoomer->setTrackerPen( QColor( Qt::white ) );
  connect(zoomer, SIGNAL(zoomed(const QRectF &)), this, SLOT(zoomed(const QRectF &)));

  panner = new QwtPlotPanner( canvas );
  panner->setMouseButton( Qt::MidButton );

  //Show the X/Y markers that follow the mouse
  picker = new QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft, QwtPlotPicker::CrossRubberBand, QwtPicker::AlwaysOn, canvas);
  picker->setStateMachine( new QwtPickerTrackerMachine() );
  picker->setRubberBandPen( QColor( Qt::cyan ) );
  picker->setTrackerPen( QColor( Qt::cyan ) );

  //FreqdBmPicker *er = new FreqdBmPicker(QwtPlot::xBottom, QwtPlot::yLeft, QwtPlotPicker::CrossRubberBand, QwtPicker::AlwaysOn, canvas);

  //Setup grid
  grid = new QwtPlotGrid();
  grid->enableXMin( true );
  grid->enableYMin( true );
  QColor color(Qt::gray); color.setAlpha(128);
  grid->setMajorPen( color, 1, Qt::DotLine );
  grid->setMinorPen( color, 1, Qt::DotLine );
  grid->attach( this );

  //format in kHz, MHz, GHz, not raw values
  setAxisScaleDraw(QwtPlot::xBottom, new FreqScaleDraw);
  setAxisAutoScale(QwtPlot::xBottom, true);
  //setAxisScale(QwtPlot::xBottom, 1, 4.4e9, 4.4e9 / 5.0);
  //setAxisScale(QwtPlot::yLeft, -135, 20, 20.0);

  setAxisScale(QwtPlot::yRight, 0, 10, 1);
  setAxisScale(QwtPlot::xTop, 0, 10, 1);
  
  repaint();
  replot();
}
Пример #7
0
void Item::removeItem()
{
	if (b_deleted)
		return;
	b_deleted = true;
	
	hide();
	setCanvas(0l);
	emit removed(this);
	p_itemDocument->appendDeleteList(this);
}
Пример #8
0
RootWImage::RootWImage(TCanvas& myCanvas, int witdh, int height, string relativehtmlDirectory) {
  imageCounter_++;
  myCanvas_ = NULL;
  setCanvas(myCanvas);
  setZoomedSize(witdh, height);
  setRelativeHtmlDirectory(relativehtmlDirectory);
  targetDirectory_ = "";
  comment_ = "";
  name_ = "img";
  allowedExtensions_ = DEFAULTALLOWEDEXTENSIONS;
  setDefaultExtensions();
}
Пример #9
0
void CanvasRenderer::deinitialize() throw (tgt::Exception) {
   ShdrMgr.dispose(shader_);
   shader_ = 0;
   if (errorTex_)
       TexMgr.dispose(errorTex_);
   errorTex_ = 0;
   LGL_ERROR;

   setCanvas(0);
   LGL_ERROR;

   RenderProcessor::deinitialize();
}
Пример #10
0
ReportCanvasView::ReportCanvasView(ReportWindow * rw, Q3Canvas * canvas, QWidget * parent, const char * name)
  : Q3CanvasView(parent, name) {
    //qDebug("ReportCanvasView::ReportCanvasView(QCanvas*,QWidget*,const char*)");

    _rw = rw;

    viewport()->setMouseTracking(TRUE);

    setVScrollBarMode(AlwaysOff);
    setHScrollBarMode(AlwaysOff);

    setCanvas(canvas);
}
bool CAPresentationHandler::openDocument (const QString& uri)
{
    QString error;
    QString mimetype = KMimeType::findByPath (uri)->name();
    KoDocumentEntry documentEntry = KoDocumentEntry::queryByMimeType(mimetype);
    KoPart *part = documentEntry.createKoPart(&error);

    if (!part) {
        kDebug() << "Doc can't be openend" << error;
        return false;
    }

    d->document = qobject_cast<KPrDocument*> (part->document());
    d->document->openUrl (KUrl (uri));

    KoCanvasBase* paCanvas = dynamic_cast<KoCanvasBase*>(part->canvasItem(d->document));
    KoPACanvasItem* paCanvasItem = dynamic_cast<KoPACanvasItem*> (paCanvas);
    if (!paCanvasItem) {
        kDebug() << "Failed to fetch a canvas item";
        return false;
    }

    if (paCanvasItem) {
        d->paView = new CAPAView (documentController()->canvasController(), dynamic_cast<KoPACanvasBase*> (paCanvas),
                                  d->document);
        paCanvasItem->setView (d->paView);

        documentController()->canvasController()->setZoomHandler (static_cast<KoZoomHandler*> (paCanvasItem->viewConverter()));
        d->paView->connectToZoomController();

        // update the canvas whenever we scroll, the canvas controller must emit this signal on scrolling/panning
        connect (documentController()->canvasController()->canvasControllerProxyObject(),
                 SIGNAL(moveDocumentOffset(QPoint)), paCanvasItem, SLOT(slotSetDocumentOffset(QPoint)));
        // whenever the size of the document viewed in the canvas changes, inform the zoom controller
        connect (paCanvasItem, SIGNAL(documentSize(QSize)), this, SLOT(tellZoomControllerToSetDocumentSize(QSize)));

        paCanvasItem->update();
    }

    setCanvas (paCanvas);
    KoToolManager::instance()->addController (documentController()->canvasController());

    connect(documentController()->canvasController(), SIGNAL(needsCanvasResize(QSizeF)), SLOT(resizeCanvas(QSizeF)));
    connect (documentController()->canvasController(), SIGNAL(needCanvasUpdate()), SLOT(updateCanvas()));

    d->paDocumentModel = new CAPADocumentModel(this, d->document);
    emit totalNumberOfSlidesChanged();
    QTimer::singleShot(0, this, SLOT(nextSlide()));

    return true;
}
Пример #12
0
bool CASpreadsheetHandler::openDocument (const QString& uri)
{
    QString error;
    QString mimetype = KMimeType::findByPath (uri)->name();
    KoPart *part = KMimeTypeTrader::createInstanceFromQuery<KoPart>(mimetype,
                      QLatin1String("Calligra/Part"), 0, QString(), QVariantList(), &error);

    if (!part) {
        kDebug() << "Doc can't be openend" << error;
        return false;
    }

    d->document = static_cast<Calligra::Sheets::Doc*> (part->document());
    d->document->openUrl (KUrl (uri));

    setCanvas (dynamic_cast<KoCanvasBase*>(part->canvasItem(d->document)));
    KoToolManager::instance()->addController (documentController()->canvasController());
    d->canvasItem = dynamic_cast<Calligra::Sheets::CanvasItem*> (canvas());

    if (!d->canvasItem) {
        kDebug() << "Failed to fetch a canvas item";
        return false;
    }

    KoZoomHandler* zoomHandler = new KoZoomHandler();
    documentController()->canvasController()->setZoomHandler (zoomHandler);
    KoZoomController* zoomController = documentController()->canvasController()->zoomController();
    zoomController->setZoom (KoZoomMode::ZOOM_CONSTANT, 1.0);

    documentController()->canvasController()->setCanvasMode (KoCanvasController::Spreadsheet);

    if (d->canvasItem) {
        // update the canvas whenever we scroll, the canvas controller must emit this signal on scrolling/panning
        connect (documentController()->canvasController()->canvasControllerProxyObject(),
                 SIGNAL(moveDocumentOffset(QPoint)), d->canvasItem, SLOT(setDocumentOffset(QPoint)));
        // whenever the size of the document viewed in the canvas changes, inform the zoom controller
        connect (d->canvasItem, SIGNAL(documentSizeChanged(QSize)), this, SLOT(tellZoomControllerToSetDocumentSize(QSize)));
        d->canvasItem->update();
    }

    connect (documentController()->canvasController(), SIGNAL(needsCanvasResize(QSizeF)), SLOT(resizeCanvas(QSizeF)));
    connect (documentController()->canvasController(), SIGNAL(needCanvasUpdate()), SLOT(updateCanvas()));

    updateCanvas();
    documentController()->canvasController()->zoomToFit();
    emit sheetCountChanged();

    return true;
}
Пример #13
0
TVPlot::TVPlot( QWidget *parent ):
    QwtPlot( parent )
{
    setTitle( "Watching TV during a weekend" );

    QwtPlotCanvas *canvas = new QwtPlotCanvas();
    canvas->setPalette( Qt::gray );
    canvas->setBorderRadius( 10 );
    setCanvas( canvas );

    plotLayout()->setAlignCanvasToScales( true );

    setAxisTitle( QwtPlot::yLeft, "Number of People" );
    setAxisTitle( QwtPlot::xBottom, "Number of Hours" );

    QwtLegend *legend = new QwtLegend;
    legend->setDefaultItemMode( QwtLegendData::Checkable );
    insertLegend( legend, QwtPlot::RightLegend );

    populate();

    connect( legend, SIGNAL( checked( const QVariant &, bool, int ) ),
        SLOT( showItem( const QVariant &, bool ) ) );

    replot(); // creating the legend items

    QwtPlotItemList items = itemList( QwtPlotItem::Rtti_PlotHistogram );
    for ( int i = 0; i < items.size(); i++ )
    {
        if ( i == 0 )
        {
            const QVariant itemInfo = itemToInfo( items[i] );

            QwtLegendLabel *legendLabel =
                qobject_cast<QwtLegendLabel *>( legend->legendWidget( itemInfo ) );
            if ( legendLabel )
                legendLabel->setChecked( true );

            items[i]->setVisible( true );
        }
        else
        {
            items[i]->setVisible( false );
        }
    }

    setAutoReplot( true );
}
Пример #14
0
CNavigationDiagramView::CNavigationDiagramView(QWidget *parent, const char *name):QCanvasView(parent, name){
	m_pqActiveItem = NULL;
	QCanvas *myCanvas = new QCanvas(this);
	myCanvas->resize(800, 600);
	setCanvas(myCanvas);

	m_pFromDiagramMarker = new CFromDiagramMarker(myCanvas);
	m_pFromDiagramMarker->move(0.4 * myCanvas->width(), 0.5 * myCanvas->height());
	m_pFromDiagramMarker->show();

	m_pAtDiagramMarker = new CAtDiagramMarker(myCanvas);
	m_pAtDiagramMarker->move(0.6 * myCanvas->width(), 0.5 * myCanvas->height());
	m_pAtDiagramMarker->show();

	myCanvas->update();
}
/**
 * MIPSarch contructor.
 * Creates and sets the MIPSarchcanvas to be displayed, and some
 * GUI functionalities.
 */
MIPSarch::MIPSarch( mips &m, QWidget* parent,  const char* name, Qt::WFlags fl )
    : Q3CanvasView(0, parent, name, fl )
{   
    archCanvas=new MIPSarchCanvas(m,this);
    setCanvas(archCanvas);

    setIcon(QPixmap("mips.xpm"));

    resize(QSize(896+5,455+5));
    setMaximumSize(QSize(896+5,455+5));

    cursor=new QCursor(Qt::PointingHandCursor);
    setCursor(*cursor);

    viewport()->setMouseTracking(true);
    setFocusPolicy(Qt::StrongFocus);
}
Пример #16
0
//BEGIN class PinItem
PinItem::PinItem( FlowCodeDocument* _view, QPoint position, bool _onLeft, PinSettings * pinSettings )
	: KtlQCanvasRectangle(0)
{
	m_pinSettings = pinSettings;
	view = _view;
	onLeft = _onLeft;
	
	connect( m_pinSettings, SIGNAL(settingsChanged()), this, SLOT(updateDrawing()) );
	
	if ( QFontInfo(m_font).pixelSize() > 11 ) // It has to be > 11, not > 12, as (I think) pixelSize() rounds off the actual size
		m_font.setPixelSize(12);
	
	setCanvas( view->canvas() );
	
	move ( position.x(), position.y() );
	initItem();
	setZ( (ICNDocument::Z::RaisedItem + ICNDocument::Z::ResizeHandle)/2 + 1 ); // Hackish, but whatever
}
Пример #17
0
Plot::Plot( QWidget *parent ):
    QwtPlot( parent )
{
    QwtPlotCanvas *canvas = new QwtPlotCanvas();
    canvas->setBorderRadius( 10 );
    setCanvas( canvas );

#if 0
    QwtPlotGrid *grid = new QwtPlotGrid();
    grid->setPen( Qt::DotLine );
    grid->attach( this );
#endif

    d_spectrogram = new QwtPlotSpectrogram();
    d_spectrogram->setRenderThreadCount( 0 ); // use system specific thread count

    d_spectrogram->setColorMap( new ColorMap() );

    d_spectrogram->setData( new RasterData() );
    d_spectrogram->attach( this );

    const QwtInterval zInterval = d_spectrogram->data()->interval( Qt::ZAxis );
    // A color bar on the right axis
    QwtScaleWidget *rightAxis = axisWidget( QwtPlot::yRight );
    rightAxis->setColorBarEnabled( true );
    rightAxis->setColorBarWidth( 40 );
    rightAxis->setColorMap( zInterval, new ColorMap() );

    setAxisScale( QwtPlot::yRight, zInterval.minValue(), zInterval.maxValue() );
    enableAxis( QwtPlot::yRight );

    plotLayout()->setAlignCanvasToScales( true );

    setAxisScale( QwtPlot::xBottom, 0.0, 3.0 );
    setAxisMaxMinor( QwtPlot::xBottom, 0 );
    setAxisScale( QwtPlot::yLeft, 0.0, 3.0 );
    setAxisMaxMinor( QwtPlot::yLeft, 0 );

    QwtPlotMagnifier *magnifier = new QwtPlotMagnifier( canvas );
    magnifier->setAxisEnabled( QwtPlot::yRight, false );

    QwtPlotPanner *panner = new QwtPlotPanner( canvas );
    panner->setAxisEnabled( QwtPlot::yRight, false );
}
Пример #18
0
Plot::Plot(QWidget *parent):
    QwtPlot( parent )
{
    setAutoFillBackground( true );
    setPalette( QPalette( QColor( 165, 193, 228 ) ) );
    updateGradient();

    setTitle( "График аппроксимации" );
    insertLegend( new QwtLegend(), QwtPlot::RightLegend );

    // axes
    setAxisTitle( xBottom, "" );
    setAxisScale( xBottom, 0.0, 60.0 );

    setAxisTitle( yLeft, "Функция принадлежности -->" );
    setAxisScale( yLeft, -0.1, 1.1 );

    // canvas
    QwtPlotCanvas *canvas = new QwtPlotCanvas();
    canvas->setLineWidth( 1 );
    canvas->setFrameStyle( QFrame::Box | QFrame::Plain );
    canvas->setBorderRadius( 15 );

    QPalette canvasPalette( Qt::white );
    canvasPalette.setColor( QPalette::Foreground, QColor( 133, 190, 232 ) );
    canvas->setPalette( canvasPalette );

    setCanvas( canvas );

    // panning with the left mouse button
    //( void ) new QwtPlotPanner( canvas );

    // zoom in/out with the wheel
    ( void ) new QwtPlotMagnifier( canvas );

    zoom = new QwtPlotZoomer(canvas);
    zoom->setRubberBandPen(QPen(Qt::red));

    clear();

    //  ...a horizontal line at y = 0...

<<<<<<< HEAD
Пример #19
0
PlotZoz::PlotZoz(QWidget *)
{
    // Прозрачность полотна
    QwtPlotCanvas *canvas = new QwtPlotCanvas();
    canvas->setFrameStyle(QFrame::NoFrame);
    canvas->setPaintAttribute(QwtPlotCanvas::BackingStore, false);
    canvas->setPaintAttribute(QwtPlotCanvas::Opaque, false);
    canvas->setAttribute(Qt::WA_OpaquePaintEvent, false);
    canvas->setAutoFillBackground( false );
    setCanvas(canvas);
    plotLayout()->setAlignCanvasToScales(true);

    // Отключаем щкалы деления
    for (int i=0; i<QwtPlot::axisCnt; i++) {
        axisScaleDraw(i)->enableComponent(QwtScaleDraw::Ticks, false);
        axisScaleDraw(i)->enableComponent(QwtScaleDraw::Backbone, false);
    }

    pltSpectrogram = new PlotSpectr();
    pltRasterData = new PlotRasterData();

    pltGrid = new QwtPlotGrid;
    pltGrid->enableXMin(true);       // разрешаем отображение линий сетки, соответствующих вспомогательным делениям нижней шкалы
    pltGrid->enableYMin(true);       // разрешаем отображение линий сетки, соответствующих вспомогательным делениям нижней шкалы
    pltGrid->setMajorPen(QPen(Qt::gray,0,Qt::DotLine));  // черный для основных делений
    pltGrid->setMinorPen(QPen(Qt::gray,0,Qt::DotLine));  // серый для вспомогательных
    pltGrid->attach(this);

    setAxisMaxMajor(0,20);
    setAxisMaxMinor(0,0);
    setAxisMaxMajor(1,20);
    setAxisMaxMinor(1,0);
    setAxisMaxMajor(2,20);
    setAxisMaxMinor(2,0);
    setAxisMaxMajor(3,20);
    setAxisMaxMinor(3,0);

    canvas->setCursor(Qt::ArrowCursor);
    setMouseTracking(true);
    for (int i=0; i<QwtPlot::axisCnt; i++)
        axisWidget(i)->setMouseTracking(true);
}
Пример #20
0
Plot::Plot( QWidget *parent ):
    QwtPlot( parent )
{
    setAutoReplot( false );

    setTitle( "Movable Items" );

    const int margin = 5;
    setContentsMargins( margin, margin, margin, margin );

    setAutoFillBackground( true );
    setPalette( QColor( "DimGray" ).lighter( 110 ) );

    QwtPlotCanvas *canvas = new QwtPlotCanvas();
#if 0
    // a gradient making a replot slow on X11
    canvas->setStyleSheet(
        "border: 2px solid Black;"
        "border-radius: 15px;"
        "background-color: qlineargradient( x1: 0, y1: 0, x2: 0, y2: 1,"
            "stop: 0 LemonChiffon, stop: 0.5 PaleGoldenrod, stop: 1 LemonChiffon );"
    );
#else
    canvas->setStyleSheet(
        "border: 2px inset DimGray;"
        "border-radius: 15px;"
        "background: LemonChiffon;"
    );
#endif

    setCanvas( canvas );
    insertLegend( new Legend(), QwtPlot::RightLegend );

    populate();

    updateAxes();
    for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ )
        setAxisAutoScale( axis, false );

    d_editor = new Editor( this );
    ( void ) new QwtPlotMagnifier( canvas );
}
Пример #21
0
Spectrograph::Spectrograph(QWidget *parent):
    QwtPlot(parent)
{
    //real-time plotting
    d_directPainter = new QwtPlotDirectPainter();

    setAutoReplot( false );
    //all plot widgets will be displayed on the canvas
    setCanvas( new QwtPlotCanvas() );

    plotLayout()->setAlignCanvasToScales( true );
    //set plot title and range
    setAxisTitle( QwtPlot::xBottom, "Frequency (MHz)" );
    setAxisTitle( QwtPlot::yLeft, "Amplitude (dB)" );
    setAxisScale( QwtPlot::xBottom, 0, RESULT_LENGTH );
    setAxisScale( QwtPlot::yLeft, -90, -10);

    //black background
    setCanvasBackground(QColor(0,0,0));

    //add grid
    QwtPlotGrid *grid = new QwtPlotGrid();
    grid->setPen( Qt::white, 0.0, Qt::DotLine );
    grid->enableX( true );
    grid->enableXMin( true );
    grid->enableY( true );
    grid->enableYMin( false );
    grid->attach( this );//attach grid to plot

    //add curve
    d_curve = new QwtPlotCurve();
    d_curve->setStyle( QwtPlotCurve::Lines );
    d_curve->setPen(Qt::yellow);
    d_curve->setPaintAttribute( QwtPlotCurve::ClipPolygons, false );
    d_curve->attach( this );//attach curve to plot

    for(int i=0; i<RESULT_LENGTH; ++i) {
        d_x[i] = i;
    }

}
OscilloscopePlot::OscilloscopePlot( QWidget *parent ):
    QwtPlot( parent ),
    d_paintedPoints( 0 ),
    d_interval( 0.0, 10.0 ),
    d_timerId( -1 )
{
    d_directPainter = new QwtPlotDirectPainter();

    setAutoReplot( false );
    setCanvas( new Canvas() );

    plotLayout()->setAlignCanvasToScales( true );

    setAxisTitle( QwtPlot::xBottom, "Time [s]" );
    setAxisScale( QwtPlot::xBottom, d_interval.minValue(), d_interval.maxValue() );
    setAxisScale( QwtPlot::yLeft, -200.0, 200.0 );

    QwtPlotGrid *grid = new QwtPlotGrid();
    grid->setPen( Qt::gray, 0.0, Qt::DotLine );
    grid->enableX( true );
    grid->enableXMin( true );
    grid->enableY( true );
    grid->enableYMin( false );
    grid->attach( this );

    d_origin = new QwtPlotMarker();
    d_origin->setLineStyle( QwtPlotMarker::Cross );
    d_origin->setValue( d_interval.minValue() + d_interval.width() / 2.0, 0.0 );
    d_origin->setLinePen( Qt::gray, 0.0, Qt::DashLine );
    d_origin->attach( this );

    d_curve = new QwtPlotCurve();
    d_curve->setStyle( QwtPlotCurve::Lines );
    d_curve->setPen( canvas()->palette().color( QPalette::WindowText ) );
    d_curve->setRenderHint( QwtPlotItem::RenderAntialiased, true );
    d_curve->setPaintAttribute( QwtPlotCurve::ClipPolygons, false );
    d_curve->setData( new CurveData() );
    d_curve->attach( this );
}
Пример #23
0
Plot::Plot( QWidget *parent ):
    QwtPlot( parent ),
    d_interval( 10.0 ), // seconds
    d_timerId( -1 )
{
    // Assign a title
    setTitle( "Testing Refresh Rates" );

    QwtPlotCanvas *canvas = new QwtPlotCanvas();
    canvas->setFrameStyle( QFrame::Box | QFrame::Plain );
    canvas->setLineWidth( 1 );
    canvas->setPalette( Qt::white );

    setCanvas( canvas );

    alignScales();

    // Insert grid
    d_grid = new QwtPlotGrid();
    d_grid->attach( this );

    // Insert curve
    d_curve = new QwtPlotCurve( "Data Moving Right" );
    d_curve->setPen( Qt::black );
    d_curve->setData( new CircularBuffer( d_interval, 10 ) );
    d_curve->attach( this );

    // Axis
    setAxisTitle( QwtPlot::xBottom, "Seconds" );
    setAxisScale( QwtPlot::xBottom, -d_interval, 0.0 );

    setAxisTitle( QwtPlot::yLeft, "Values" );
    setAxisScale( QwtPlot::yLeft, -1.0, 1.0 );

    d_clock.start();

    setSettings( d_settings );
}
Пример #24
0
	void OpenGLWindow::gameLoop(){
		SDL_Event event;
		bool isRunning = true;
		//start the game loop
		while(isRunning){
			//check and handle for any events
			while(SDL_PollEvent(&event)){
				switch(event.type){
					//exit on escape key
					case SDL_KEYUP: if(event.key.keysym.sym == SDLK_ESCAPE) isRunning = false; break;
					//exit on close button pressed
					case SDL_QUIT: isRunning = false; break;
					//resize on resizing the window
					case SDL_VIDEORESIZE: 	setWidth(event.resize.w); setHeight(event.resize.h);
											setCanvas( SDL_SetVideoMode( width(), height() , 32 , flags() ) );
											(*_resizeFunc)(event.resize.w,event.resize.h); break;
				}
				//call additional event handler provided by user
				_eventHandler(event);
			}
			//render screen
			(*_renderFunc)();
		}
	}
Пример #25
0
CpuPlot::CpuPlot( QWidget *parent ):
    QwtPlot( parent ),
    dataCount( 0 ) {

        setAutoReplot( false );

        QwtPlotCanvas *canvas = new QwtPlotCanvas();
        canvas->setBorderRadius( 10 );

        setCanvas( canvas );

        plotLayout()->setAlignCanvasToScales( true );

        QwtLegend *legend = new QwtLegend;
        legend->setDefaultItemMode( QwtLegendData::Checkable );
        insertLegend( legend, QwtPlot::RightLegend );

        setAxisTitle( QwtPlot::xBottom, "System Uptime [h:m:s]" );
        setAxisScaleDraw( QwtPlot::xBottom,
                new TimeScaleDraw( cpuStat.upTime() ) );
        setAxisScale( QwtPlot::xBottom, 0, HISTORY );
        //setAxisLabelRotation( QwtPlot::xBottom, -50.0 );
        setAxisLabelRotation( QwtPlot::xBottom, 0.0 );
        setAxisLabelAlignment( QwtPlot::xBottom, Qt::AlignLeft | Qt::AlignBottom );

        /*
           In situations, when there is a label at the most right position of the
           scale, additional space is needed to display the overlapping part
           of the label would be taken by reducing the width of scale and canvas.
           To avoid this "jumping canvas" effect, we add a permanent margin.
           We don't need to do the same for the left border, because there
           is enough space for the overlapping label below the left scale.
           */

        QwtScaleWidget *scaleWidget = axisWidget( QwtPlot::xBottom );
        const int fmh = QFontMetrics( scaleWidget->font() ).height();
        scaleWidget->setMinBorderDist( 0, fmh / 2 );

        setAxisTitle( QwtPlot::yLeft, "Cpu Usage [%]" );
        setAxisScale( QwtPlot::yLeft, 0, 100 );


        //attach方法将元素关联到qwtplot空间上
        Background *bg = new Background();
        bg->attach( this );

        CpuPieMarker *pie = new CpuPieMarker();
        pie->attach( this );

        CpuCurve *curve;


        curve = new CpuCurve( "System" );
        curve->setColor( Qt::red );
        curve->attach( this );

        data[System].curve = curve;

        curve = new CpuCurve( "User" );
        curve->setColor( Qt::blue );
        curve->setZ( curve->z() - 1 );
        curve->attach( this );
        data[User].curve = curve;

        curve = new CpuCurve( "Total" );
        curve->setColor( Qt::black );
        curve->setZ( curve->z() - 2 );
        curve->attach( this );
        data[Total].curve = curve;

        curve = new CpuCurve( "Idle" );
        curve->setColor( Qt::darkCyan );
        curve->setZ( curve->z() - 3 );
        curve->attach( this );
        data[Idle].curve = curve;

        showCurve( data[System].curve, true );
        showCurve( data[User].curve, true );
        showCurve( data[Total].curve, false );
        showCurve( data[Idle].curve, false );

        for ( int i = 0; i < HISTORY; i++ )
            timeData[HISTORY - 1 - i] = i;

        ( void )startTimer( 1000 ); // 1 second

        connect( legend, SIGNAL( checked( const QVariant &, bool, int ) ),
                SLOT( legendChecked( const QVariant &, bool ) ) );
    }
Пример #26
0
Plot::Plot( QWidget *parent ):
    QwtPlot( parent)
{
    setPalette( Qt::black );

    // we want to have the axis scales like a frame around the
    // canvas
    plotLayout()->setAlignCanvasToScales( true );
    for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ )
        axisWidget( axis )->setMargin( 0 );

    QwtPlotCanvas *canvas = new QwtPlotCanvas();
    canvas->setAutoFillBackground( false );
    canvas->setFrameStyle( QFrame::NoFrame );
    setCanvas( canvas );

    setAxisScale( QwtPlot::yLeft, 0.0, 10.0 );

    // a title
    QwtText title( "Picker Demo" );
    title.setColor( Qt::white );
    title.setRenderFlags( Qt::AlignHCenter | Qt::AlignTop );

    QFont font;
    font.setBold( true );
    title.setFont( font );

    QwtPlotTextLabel *titleItem = new QwtPlotTextLabel();
    titleItem->setText( title );
    titleItem->attach( this );

#if 1
    // section

    //QColor c( "PaleVioletRed" );

    QwtPlotZoneItem* zone = new QwtPlotZoneItem();
    zone->setPen( Qt::darkGray );
    zone->setBrush( QColor( "#834358" ) );
    zone->setOrientation( Qt::Horizontal );
    zone->setInterval( 3.8, 5.7 );
    zone->attach( this );

#else
    // grid

    QwtPlotGrid *grid = new QwtPlotGrid();
    grid->setMajorPen( Qt::white, 0, Qt::DotLine );
    grid->setMinorPen( Qt::gray, 0 , Qt::DotLine );
    grid->attach( this );
#endif

    // curves

    QPolygonF points1;
    points1 << QPointF( 0.2, 4.4 ) << QPointF( 1.2, 3.0 )
            << QPointF( 2.7, 4.5 ) << QPointF( 3.5, 6.8 )
            << QPointF( 4.7, 7.9 ) << QPointF( 5.8, 7.1 );

    insertCurve( "Curve 1", "DarkOrange", points1 );

    QPolygonF points2;
    points2 << QPointF( 0.4, 8.7 ) << QPointF( 1.4, 7.8 )
            << QPointF( 2.3, 5.5 ) << QPointF( 3.3, 4.1 )
            << QPointF( 4.4, 5.2 ) << QPointF( 5.6, 5.7 );

    insertCurve( "Curve 2", "DodgerBlue", points2 );

    CurveTracker* tracker = new CurveTracker( this->canvas() );

    // for the demo we want the tracker to be active without
    // having to click on the canvas
    tracker->setStateMachine( new QwtPickerTrackerMachine() );
    tracker->setRubberBandPen( QPen( "MediumOrchid" ) );
}
Пример #27
0
void TimelineDocker::unsetCanvas()
{
    setCanvas(0);
}
Пример #28
0
Curve::Curve(int device_port, int ele_max,QColor color, QWidget *parent)
    : QwtPlot(parent),device_port(device_port),color(color),ele_max(ele_max)
{
    reset();

    setObjectName(tr("%1-%2 Real-Eletric").arg(device_port));
    setTitle(tr("实时电流"));

    setAxisTitle(QwtPlot::xBottom,"时间(s)");

    setAxisTitle(QwtPlot::yLeft,tr("电流(A)"));

    setAxisScale(QwtPlot::xBottom,x_min,x_max);

    setAxisScale(QwtPlot::yLeft,0.0,50.0);

    QwtPlotCanvas *canvas    = new QwtPlotCanvas;
    canvas->setPalette(QColor("#404040"));
    canvas->setBorderRadius(10);
    canvas->setFocusIndicator(QwtPlotCanvas::ItemFocusIndicator);
    setCanvas(canvas);

    insertLegend(new QwtLegend(),QwtPlot::RightLegend);

    QwtPlotZoomer *zoomer   = new QwtPlotZoomer(canvas);
    zoomer->setRubberBandPen(QPen(QColor(Qt::red),1));
    zoomer->setTrackerPen(QColor(Qt::red));

    zoomer->setMousePattern(QwtEventPattern::MouseSelect2,
                            Qt::RightButton,Qt::ControlModifier);
    zoomer->setMousePattern(QwtEventPattern::MouseSelect3,
                            Qt::RightButton);

    QwtPlotPanner *panner   = new QwtPlotPanner(canvas);
    panner->setMouseButton(Qt::MidButton);
    panner->setCursor(Qt::OpenHandCursor);
    panner->setEnabled(true);
    panner->setAxisEnabled(QwtPlot::yLeft,false);

    connect(panner,SIGNAL(panned(int,int)),this,SLOT(get_coord(int,int)));

    new QwtPlotMagnifier(this->canvas());

    QwtPlotPicker *m_picker = new QwtPlotPicker( QwtPlot::xBottom, QwtPlot::yLeft,
            QwtPlotPicker::HLineRubberBand , QwtPicker::AlwaysOn,
            this->canvas() );

    m_picker->setTrackerPen(QPen(Qt::red,1));
    QFont font;
    font.setPixelSize(15);
    m_picker->setTrackerFont(font);

    d_curve = new QwtPlotCurve(tr("支路%1").arg(device_port));
    d_curve->setSymbol(new QwtSymbol(QwtSymbol::Ellipse,Qt::blue,QPen(Qt::blue),QSize(5,5)));
    d_curve->setStyle(QwtPlotCurve::Lines);
    d_curve->setCurveAttribute( QwtPlotCurve::Fitted );
    d_curve->setPen(QPen(Qt::magenta));
    d_curve->setRenderHint(QwtPlotItem::RenderAntialiased,true);
    d_curve->attach(this);

    d_curve_Max = new QwtPlotCurve(tr("最大值"));
    d_curve_Max->setStyle(QwtPlotCurve::Lines);
    d_curve_Max->setCurveAttribute(QwtPlotCurve::Fitted);
    d_curve_Max->setPen(QPen(Qt::red));
    d_curve_Max->setRenderHint(QwtPlotItem::RenderAntialiased,true);
    d_curve_Max->attach(this);    
}
Пример #29
0
Plot::Plot(QWidget *parent):QwtPlot( parent )
{    setAutoReplot( false );

     setTitle( "FFT" );

     QwtPlotCanvas *canvas = new QwtPlotCanvas();
     canvas->setBorderRadius( 10 );

     setCanvas( canvas );
     setCanvasBackground( QColor( "MidnightBlue" ) );

     // legend
     QwtLegend *legend = new QwtLegend;
     insertLegend( legend, QwtPlot::BottomLegend );

     // grid
     QwtPlotGrid *grid = new QwtPlotGrid;
     grid->enableXMin( true );
     grid->setMajorPen( Qt::white, 0, Qt::DotLine );
     grid->setMinorPen( Qt::gray, 0 , Qt::DotLine );
     grid->attach( this );

     // axes
     //enableAxis( QwtPlot::yRight );
     setAxisTitle( QwtPlot::xBottom, "Frequency [kHz]" );
     setAxisTitle( QwtPlot::yLeft, "Amplitude " );
     //setAxisTitle( QwtPlot::yRight, "Phase [deg]" );




     setAxisMaxMajor( QwtPlot::xBottom, 6 );
     setAxisMaxMinor( QwtPlot::xBottom, 9 );


      //setAxisScale(QwtPlot::xBottom,0.01,100);

     //setAxisScaleEngine( QwtPlot::xBottom, ScaleEngine_Lin_X );


     // setAxisScaleEngine(QwtPlot::xBottom, new QwtLogScaleEngine );

     // curves


     d_curve1 = new QwtPlotCurve( "Amplitude Ch1" );
     d_curve1->setRenderHint( QwtPlotItem::RenderAntialiased );
     d_curve1->setPen( Qt::red );
     d_curve1->setLegendAttribute( QwtPlotCurve::LegendShowLine );
     d_curve1->setYAxis( QwtPlot::yLeft );
     d_curve1->attach( this );




     m_Channel2=true;

      if(m_Channel2){
         d_curve2 = new QwtPlotCurve( "Amplitude Ch2 " );
         d_curve2->setRenderHint( QwtPlotItem::RenderAntialiased );
         d_curve2->setPen( Qt::magenta );
         d_curve2->setLegendAttribute( QwtPlotCurve::LegendShowLine );
         d_curve2->setYAxis( QwtPlot::yLeft );
         d_curve2->attach( this );
      }

      d_average = new QwtPlotCurve( "Average Ch1" );
      d_average->setRenderHint( QwtPlotItem::RenderAntialiased );
      d_average->setPen( Qt::white );
      d_average->setLegendAttribute( QwtPlotCurve::LegendShowLine );
      d_average->setYAxis( QwtPlot::yLeft );
      d_average->attach( this );


     // marker
     d_marker1 = new QwtPlotMarker();
     d_marker1->setValue( 0.0, 0.0 );
     d_marker1->setLineStyle( QwtPlotMarker::VLine );
     d_marker1->setLabelAlignment( Qt::AlignRight | Qt::AlignBottom );
     d_marker1->setLinePen(  Qt::green, 0, Qt::DashDotLine );
     d_marker1->attach( this );

      if(m_Channel2){
        /*  d_marker2 = new QwtPlotMarker();
          d_marker2->setValue( 0.0, 0.0 );
          d_marker2->setLineStyle( QwtPlotMarker::VLine );
          d_marker2->setLabelAlignment( Qt::AlignRight | Qt::AlignBottom );
          d_marker2->setLinePen(  Qt::gray, 0, Qt::DashDotLine );
          d_marker2->attach( this );*/

          /*
         d_marker2 = new QwtPlotMarker();
         d_marker2->setLineStyle( QwtPlotMarker::HLine );
         d_marker2->setLabelAlignment( Qt::AlignRight | Qt::AlignBottom );
         d_marker2->setLinePen( QColor( 200, 150, 0 ), 0, Qt::DashDotLine );
         d_marker2->setSymbol( new QwtSymbol( QwtSymbol::Diamond,
            QColor( Qt::yellow ), QColor( Qt::green ), QSize( 8, 8 ) ) );
         d_marker2->attach( this );*/
      }

    //setDamp( 0.0 );

     setAutoReplot( true );


}
Пример #30
0
void LEPStyle::draw()
{
  if( _canv==0 )
    {
      setCanvas();
      setHist();
      _canv->Draw();
      if( _ymin==0 ) _ymin = 0.2;
      //  _ymax = _n*1.5; 
      if( _ymax==0 ) _ymax = _n+_upDy;
      _hist->SetMinimum( _ymin  );
      _hist->SetMaximum( _ymax );
      
      _hist->Draw();

      if( _cmsPrelim ) cmsPrelim( _intLumi );
    }

  //  size_t n_ = _entry.size();
  _n = _entry.size();
  
  if( _extraBand )
    {
      drawExtraBand();
    }
 
  if( _band )
    {
      Double_t xx_[5] = { _bxmin, _bxmax, _bxmax, _bxmin, _bxmin };
      float eps1_ = _eps1*(_ymax-_ymin);
      float eps2_ = _eps2*(_ymax-_ymin);
      Double_t yy_[5] = { _ymin+eps1_, _ymin+eps1_, _ymax-eps2_, _ymax-eps2_, _ymin+eps1_ };
      TPolyLine* pl_ = new TPolyLine( 5, xx_, yy_ );
      pl_->SetFillStyle(_bandFillStyle);
      pl_->SetFillColor(_bandFillColor);
      pl_->SetLineWidth(3);
      pl_->SetLineColor( kOrange );
      pl_->DrawClone("FSame");
      TLine* l_ = new TLine( _bx0, _ymin+eps1_, _bx0, _ymax-eps2_  );
      l_->SetLineWidth(4);
      l_->SetLineColor( kOrange );
      l_->DrawClone();


      if( _hasLegend )
	{

	  cout << "HELLO!!!!" << endl;
	  //      _y0 = 4.0;
	  if( _y0==0 ) _y0 = _n+2*_upDy/3.;
	  if( _dy==0 ) _dy = 0.06;
	  _x0 = _xmax - 0.05*(_xmax-_xmin);
	  
	  TLatex leg1_;
	  leg1_.SetTextSize(_scale*0.05);      
	  leg1_.SetTextAlign(31); 
	  leg1_.DrawLatex( _x0, _y0+_dy, _legend );
	  
	  
	  TLatex leg2_;
	  leg2_.SetTextSize(_scale*0.05);      
	  leg2_.SetTextAlign(23); 
	  leg2_.DrawLatex( _bx0, _y0-_dy, _theory );

	}

//       TLegend* legend=new TLegend(_x0,_y0, _x0+_dx, _y0+_dy );
//       legend->SetLineColor(0);
//       legend->SetFillColor(0);
      
//       //      legend->AddEntry(pl_,_legend,"lf");
//       legend->AddEntry(pl_,_legend,"");

//       legend->Draw("same");
      

    }

  for( size_t ii=0; ii<_entry.size(); ii++ )
    {
      if( _entry[ii]==("SPACE") ) continue;
      Float_t  xval_[1];
      Float_t  yval_[1];
      Float_t    ey_[1];
      Float_t estatup_[1];
      Float_t ecombup_[1];
      Float_t etotup_[1];
      Float_t estatlo_[1];
      Float_t ecomblo_[1];
      Float_t etotlo_[1];

      float yy_ = _n-(Float_t)ii;
      xval_[0] = _val[ii];
      yval_[0] = yy_;
      ey_[0] = 0;

      estatup_[0] = _statup[ii];
      ecombup_[0] = sqrt( pow( _statup[ii],2 ) + pow( _systup[ii],2 ) );
      etotup_[0] = ecombup_[0] + _lumi[ii];

      estatlo_[0] = _statlo[ii];
      ecomblo_[0] = sqrt( pow( _statlo[ii],2 ) + pow( _systlo[ii],2 ) );      
      etotlo_[0] = ecomblo_[0] + _lumi[ii];

      TGraphAsymmErrors* gtot_  = new TGraphAsymmErrors( 1, xval_, yval_, etotlo_, etotup_, ey_, ey_ );
      gtot_->SetLineColor( kGreen );
      TGraphAsymmErrors* gcomb_ = new TGraphAsymmErrors( 1, xval_, yval_, ecomblo_, ecombup_, ey_, ey_ );
      gcomb_->SetLineColor( kRed );
      TGraphAsymmErrors* gstat_ = new TGraphAsymmErrors( 1, xval_, yval_, estatlo_, estatup_, ey_, ey_ );
      gstat_->SetLineColor( kBlack );
      gstat_->SetLineWidth( 2 );
      gstat_->SetMarkerStyle( _marker[ii] );
      gstat_->SetMarkerSize( _size[ii] );
      gstat_->SetMarkerColor( _color[ii] );

      gcomb_->SetLineWidth( 2 );

      gtot_->SetLineWidth( 2 );

      if( _lumi[ii]>0 )
	gtot_->Draw();

      gcomb_->DrawClone();
      gstat_->DrawClone("P");



      if( !_writeText ) continue;

      //   align = 10*HorizontalAlign + VerticalAlign
      // For Horizontal alignment the following convention applies:
      //   1=left adjusted, 2=centered, 3=right adjusted
      // For Vertical alignment the following convention applies:
      //   1=bottom adjusted, 2=centered, 3=top adjusted
      float xtxt_ = _xmin + 0.05*(_xmax-_xmin);
      TLatex ltx1_;

      ltx1_.SetTextSize(_scale*_size1);      
      ltx1_.SetTextAlign(_align1);
      if( _specifyPlacement )
	ltx1_.DrawLatex( _xx1, yy_+_e1, _entry[ii] );
      else
	ltx1_.DrawLatex( xtxt_, yy_+E_+e_, _entry[ii] );

      TLatex ltx2_;

      char line_[512];

      TString str_;
      TString pmstr_(" #pm ");
      TString format_("%-4.");
      format_ += _ndigit[ii];
      format_ += "f";
      TString valstr_;
      TString statstr_;
      TString syststr_;
      TString lumistr_;

      sprintf( line_, format_.Data(), _val[ii] );
      // sprintf( line_,  "%-4.3f", _val[ii] );
      valstr_ = line_;

      if( fabs( _statup[ii]-_statlo[ii] )<0.01 )
	{
	  sprintf( line_, format_.Data(), _statlo[ii] );
	}
      else
	{
	  sprintf( line_, "#scale[0.7]{#splitline{+%-4.3f}{-%-4.3f}}_{ stat.}", _statup[ii], _statlo[ii] );
	}

      statstr_ = line_;
      str_ = valstr_ + pmstr_ + statstr_;
      str_ += "_{ ";
      str_ += _firstError;
      str_ += "}";

      if( _systup[ii]>0 )
	{
	  if( fabs( _systup[ii]-_systlo[ii] )<0.01 )
	    {
	      sprintf( line_, format_.Data(), _systlo[ii] );
	    }
	  else 
	    {
	      sprintf( line_, "#scale[0.7]{#splitline{+%-4.3f}{- %-4.3f}}_", _systup[ii], _systlo[ii] );
	    }
	  syststr_ = line_;
	  str_ += pmstr_;
	  str_ += syststr_;
	  str_ += "_{ ";
	  str_ += _secondError;
	  str_ += "}";
	}
  
      if( _lumi[ii]>0 )
	{
	  sprintf( line_, format_.Data(), _lumi[ii] );
	  lumistr_ = line_;
	  lumistr_ += "_{lumi.}";
	  str_ += pmstr_ + lumistr_;
	}

      //      TString str_(line_);
      
      str_ += _unit;
      cout << str_ << endl;
 
      ltx2_.SetTextSize(_scale*_size2);      
      ltx2_.SetTextAlign(_align2);
      if( _specifyPlacement )
	ltx2_.DrawLatex( _xx2, yy_+_e2, str_ );
      else
	ltx2_.DrawLatex( xtxt_+0.02*(_xmax-_xmin), yy_+E_-e_, str_ );
    }


  _hist->Draw("Same");

  _canv->RedrawAxis();
}