void MList::setOptimizationFlag(ListOptimizationFlag optimizationFlag, bool enabled) { Q_D(MList); if (enabled) setOptimizationFlags(ListOptimizationFlags(d->optimizationFlags) | optimizationFlag); else setOptimizationFlags(ListOptimizationFlags(d->optimizationFlags) & ~optimizationFlag); }
GrDapView::GrDapView(QWidget *parent) : QGraphicsView(parent) { scene_space = 4; zoomSlider = 250; rotateSlider = 0; visor_height = 76; visor_mode = QPainter::CompositionMode_Darken; visor_color = QColor(255, 0, 0, 255); visor_img.load(":/img16/sinimg.png"); scene = new QGraphicsScene(this); setAlignment(Qt::AlignCenter); // setAcceptDrops(true); setAutoFillBackground(true); setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); setBackgroundBrush(Qt::darkGray); setBackgroundRole(QPalette::Dark); setCacheMode(QGraphicsView::CacheBackground); setDragMode(QGraphicsView::ScrollHandDrag); setOptimizationFlags(QGraphicsView::DontSavePainterState); setViewportUpdateMode(QGraphicsView::FullViewportUpdate);//SmartViewportUpdate FullViewportUpdate setTransformationAnchor(QGraphicsView::AnchorUnderMouse); setFrameShape(QFrame::NoFrame); setNewScene(400, 400, true); }
FormEditorGraphicsView::FormEditorGraphicsView(QWidget *parent) : QGraphicsView(parent) { setTransformationAnchor(QGraphicsView::AnchorUnderMouse); setResizeAnchor(QGraphicsView::AnchorViewCenter); setCacheMode(QGraphicsView::CacheNone); // setCacheMode(QGraphicsView::CacheBackground); setViewportUpdateMode(QGraphicsView::SmartViewportUpdate); setOptimizationFlags(QGraphicsView::DontSavePainterState); // setViewportUpdateMode(QGraphicsView::NoViewportUpdate); setRenderHint(QPainter::Antialiasing, false); setFrameShape(QFrame::NoFrame); setAutoFillBackground(true); setBackgroundRole(QPalette::Window); const int checkerbordSize= 20; QPixmap tilePixmap(checkerbordSize * 2, checkerbordSize * 2); tilePixmap.fill(Qt::white); QPainter tilePainter(&tilePixmap); QColor color(220, 220, 220); tilePainter.fillRect(0, 0, checkerbordSize, checkerbordSize, color); tilePainter.fillRect(checkerbordSize, checkerbordSize, checkerbordSize, checkerbordSize, color); tilePainter.end(); setBackgroundBrush(tilePixmap); viewport()->setMouseTracking(true); }
SchemaEditor::SchemaEditor(QWidget *parent, SchemaGui *schemaGui, Engine * engine, PanelScrollView *panelScrollView) : QGraphicsView(schemaGui, parent), _contextMenuPos(0,0), _contextGear(NULL), _engine(engine), _schemaGui(schemaGui), _scale(1), _panelScrollView(panelScrollView), _maxZValue(1), _selectionChangeBypass(false) { _schemaGui->setSchemaEditor(this); setDragMode(QGraphicsView::RubberBandDrag); setRenderHint(QPainter::Antialiasing, true); setFrameStyle(Sunken | StyledPanel); setOptimizationFlags(QGraphicsView::DontSavePainterState | QGraphicsView::IndirectPainting); setViewportUpdateMode(QGraphicsView::FullViewportUpdate); setTransformationAnchor(QGraphicsView::AnchorUnderMouse); // render with OpenGL if(0) setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers))); resetTransform(); setAcceptDrops(TRUE); }
VLCStatsView::VLCStatsView( QWidget *parent ) : QGraphicsView( parent ) { QColor history(0, 0, 0, 255), total(237, 109, 0, 160), content(109, 237, 0, 160); scale( 1.0, -1.0 ); /* invert our Y axis */ setOptimizationFlags( QGraphicsView::DontAdjustForAntialiasing ); setAlignment( Qt::AlignLeft ); setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); viewScene = new QGraphicsScene( this ); historyShape = viewScene->addPolygon( QPolygonF(), QPen(Qt::NoPen), QBrush(history) ); totalbitrateShape = viewScene->addPolygon( QPolygonF(), QPen(Qt::NoPen), QBrush(total) ); setScene( viewScene ); reset(); QPen linepen( Qt::DotLine ); linepen.setCosmetic( true ); linepen.setBrush( QBrush( QColor( 33, 33, 33 ) ) ); for ( int i=0; i<3; i++ ) rulers[i] = viewScene->addLine( QLineF(), linepen ); }
GraphWidget::GraphWidget(QWidget *parent) : timerId(0) { myMainwindow = dynamic_cast<QoccMainWindow*>(parent); QGraphicsScene *scene = new QGraphicsScene(this); scene->setItemIndexMethod(QGraphicsScene::NoIndex); scene->setSceneRect(0, 0, 8000, 8000); setScene(scene); //setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers))); //setViewport(new QGLWidget()); setRenderHint(QPainter::Antialiasing, false); //setDragMode(QGraphicsView::RubberBandDrag); setOptimizationFlags(QGraphicsView::DontSavePainterState); setViewportUpdateMode(QGraphicsView::SmartViewportUpdate); setCacheMode(CacheBackground); //setRenderHint(QPainter::Antialiasing); setTransformationAnchor(AnchorUnderMouse); setResizeAnchor(AnchorViewCenter); scale(qreal(0.8), qreal(0.8)); setMinimumSize(400, 400); setWindowTitle(tr("Elastic Nodes")); }
EditorGraphicsView::EditorGraphicsView(QWidget * parent) : QGraphicsView(parent) , m_canZoom(true) , m_scaleFactor(1.) , m_autoResize(false) { setInteractive(true); setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform ); setCacheMode(QGraphicsView::CacheBackground); setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); setOptimizationFlags(QGraphicsView::DontSavePainterState); setViewportUpdateMode(QGraphicsView::SmartViewportUpdate); setTransformationAnchor(AnchorUnderMouse); setResizeAnchor(AnchorViewCenter); //setFrameStyle(QFrame::NoFrame); //setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); //setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setBackgroundBrush(Qt::gray); setDragMode(QGraphicsView::RubberBandDrag); // use own style for drawing the RubberBand (opened on the viewport) viewport()->setStyle(new RubberBandStyle); }
TreeViewport::TreeViewport(QWidget* parent ): QGraphicsView(parent), m_zoom(0) { setRenderHints(QPainter::Antialiasing | QPainter::HighQualityAntialiasing | QPainter::SmoothPixmapTransform); setDragMode(QGraphicsView::RubberBandDrag); setOptimizationFlags(QGraphicsView::DontSavePainterState); //setViewportUpdateMode(QGraphicsView::SmartViewportUpdate); //setViewportUpdateMode(QGraphicsView::FullViewportUpdate); }
ScaledGraphicsView(QWidget *parent=0) : QGraphicsView(parent) { setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform ); setCacheMode(QGraphicsView::CacheBackground); setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); setOptimizationFlags(QGraphicsView::DontSavePainterState); setViewportUpdateMode(QGraphicsView::SmartViewportUpdate); setTransformationAnchor(AnchorUnderMouse); setResizeAnchor(AnchorViewCenter); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); }
MapView::MapView() { setRenderHint(QPainter::Antialiasing, false); setDragMode(QGraphicsView::RubberBandDrag); setOptimizationFlags(QGraphicsView::DontSavePainterState); setViewportUpdateMode(QGraphicsView::SmartViewportUpdate); scene = new QGraphicsScene(this); setCacheMode(CacheBackground); setScene(scene); scene->setSceneRect(-320,-240,640,480); setWindowTitle(tr("Seismic Map")); dm = NULL; }
MainGraphicsView::MainGraphicsView(QWidget * parent) : QGraphicsView(parent) , m_canZoom(true) , m_zoomChanging(false) { setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers))); setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform ); setCacheMode(QGraphicsView::CacheBackground); setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); setOptimizationFlags(QGraphicsView::DontSavePainterState); setViewportUpdateMode(QGraphicsView::SmartViewportUpdate); setTransformationAnchor(AnchorUnderMouse); setResizeAnchor(AnchorViewCenter); setBackgroundBrush(Qt::lightGray); setDragMode(QGraphicsView::ScrollHandDrag); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); }
// // PannerView // PannerView::PannerView(DotGraphView * parent, const char * name) : QGraphicsView(parent), m_drawContents(true), m_parent(parent) { m_movingZoomRect = false; // why doesn't this avoid flicker ? // viewport()->setBackgroundMode(Qt::NoBackground); setBackgroundMode(Qt::NoBackground); // if there are ever graphic glitches to be found, remove this again setOptimizationFlags(QGraphicsView::DontAdjustForAntialiasing | QGraphicsView::DontClipPainter | QGraphicsView::DontSavePainterState); setToolTip(i18n("View of the complete graph. Click and drag to move the visible part.")); setWhatsThis(i18n("<h1>View of the Complete Graph</h1>" "<p>Single clicking somewhere without the red square will move the center of the " "view to where the mouse was clicked.</p><p>Clicking and dragging within the red square " "will cause the view to follow the movement.</p>")); }
CanvasView::CanvasView(QGraphicsScene *scene, QWidget *parent) : QGraphicsView(scene, parent){ setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); //slowly rendering while resizing setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); setOptimizationFlags(QGraphicsView::DontSavePainterState); scene->setBackgroundBrush(Qt::gray); scene->setItemIndexMethod(QGraphicsScene::NoIndex); _bg = scene->addRect(0, 0, 2000, 2000, QPen(), QBrush(QColor(255, 255, 255))); _bg->setZValue(-1); setScene(scene); // use scrollhand drag mode to enable panning setDragMode(ScrollHandDrag); }
CSceneWidget::CSceneWidget(qint32 compkey, qint32 width, qint32 height, QWidget *parent) : QGraphicsView(parent), _compkey(compkey), _currentItem(NULL), m_currentImage(NULL), _resizeBegin(false), m_gridEnabled(false), m_cellWidth(10), _timerId(0), _aspectRatioMode(Qt::KeepAspectRatio) { initSceneMenu(); initItemsMenu(); QGraphicsScene *scene = new QGraphicsScene(this); scene->setItemIndexMethod(QGraphicsScene::NoIndex); scene->setSceneRect(0,0,width,height); setScene(scene); setSceneRect(0,0,width,height); setTransformationAnchor(AnchorUnderMouse); setCacheMode(CacheBackground); setViewportUpdateMode(BoundingRectViewportUpdate); setOptimizationFlags(QGraphicsView::DontAdjustForAntialiasing | QGraphicsView::DontClipPainter | QGraphicsView::DontSavePainterState); setMouseTracking(true); CGraphicsItem *background = new CGraphicsItem(_compkey); background->setPos(0,0); background->setSize(QSize(width,height)); background->setImageFitMode(CGraphicsItem::ImageStretch/*ImageFit*/); scene->addItem(background); //scene->addWidget(new QLabel("use +/- for zoming")); // TODO: tempory removed SettingsManager setting("Video"); setEnabledOpenGl(setting.getBoolValue("OpenGL")); _timerId = startTimer(1000 / 25); }
FormEditorGraphicsView::FormEditorGraphicsView(QWidget *parent) : QGraphicsView(parent), m_isPanning(false) { setTransformationAnchor(QGraphicsView::AnchorUnderMouse); setResizeAnchor(QGraphicsView::AnchorViewCenter); setAlignment(Qt::AlignCenter); setCacheMode(QGraphicsView::CacheNone); setViewportUpdateMode(QGraphicsView::MinimalViewportUpdate); setOptimizationFlags(QGraphicsView::DontSavePainterState); // setViewportUpdateMode(QGraphicsView::NoViewportUpdate); setRenderHint(QPainter::Antialiasing, false); setFrameShape(QFrame::NoFrame); setAutoFillBackground(true); setBackgroundRole(QPalette::Window); activateCheckboardBackground(); viewport()->setMouseTracking(true); }
FormEditorGraphicsView::FormEditorGraphicsView(QWidget *parent) : QGraphicsView(parent) { setTransformationAnchor(QGraphicsView::AnchorUnderMouse); setResizeAnchor(QGraphicsView::AnchorViewCenter); setAlignment(Qt::AlignCenter); setCacheMode(QGraphicsView::CacheNone); setViewportUpdateMode(QGraphicsView::MinimalViewportUpdate); setOptimizationFlags(QGraphicsView::DontSavePainterState); setRenderHint(QPainter::Antialiasing, false); setRenderHint(QPainter::SmoothPixmapTransform, true); setFrameShape(QFrame::NoFrame); setAutoFillBackground(true); setBackgroundRole(QPalette::Window); activateCheckboardBackground(); // as mousetracking only works for mouse key it is better to handle it in the // eventFilter method so it works also for the space scrolling case as expected QCoreApplication::instance()->installEventFilter(this); }
OutputWindow::OutputWindow() : QGraphicsView(new QGraphicsScene()) , m_url("") , m_pollDviz(false) , m_updateTime(1000) , m_isDataPoll(false) , m_slideId(-1) , m_slideName("") //, m_startStopButton(0) , m_countValue(0) , m_drw(0) , m_blinkCount(0) { // Setup graphics view setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform ); setCacheMode(QGraphicsView::CacheBackground); setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); setOptimizationFlags(QGraphicsView::DontSavePainterState); setViewportUpdateMode(QGraphicsView::SmartViewportUpdate); setTransformationAnchor(AnchorUnderMouse); setResizeAnchor(AnchorViewCenter); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); // Add pixmap item for background QPixmap bluePixmap(32,23); bluePixmap.fill(Qt::blue); m_pixmap = scene()->addPixmap(bluePixmap); // Background behind text m_counterBgRect = scene()->addRect(0,0,100,60,QPen(), Qt::black); m_counterBgRect->setZValue(99); // Add text (for use with clock) QFont font("Monospace", 50, 600); m_counterText = new QGraphicsSimpleTextItem("0"); m_counterText->setFont(font); m_counterText->setPen(QPen(Qt::black)); m_counterText->setBrush(Qt::white); m_counterText->setPos(0, -13); m_counterText->setZValue(100); scene()->addItem(m_counterText); // Background behind text m_overlayBgRect = scene()->addRect(0,300,100,60,QPen(), Qt::black); m_overlayBgRect->setZValue(99); // Add text (for use with clock) //QFont font("Monospace", 50, 600); m_overlayText = new QGraphicsSimpleTextItem("Hello, World!"); m_overlayText->setFont(font); m_overlayText->setPen(QPen(Qt::black)); m_overlayText->setBrush(Qt::white); m_overlayText->setPos(0, 300-13); m_overlayText->setZValue(100); scene()->addItem(m_overlayText); m_blinkOverlay = false; connect(&m_blinkOverlayTimer, SIGNAL(timeout()), this, SLOT(blinkOverlaySlot())); GET_CONFIG(); QPoint windowPos(1024,0); QPoint windowSize(1024,768); //QPoint windowPos(10,10); //QPoint windowSize = QPoint(640,480); QString windowGeomString = config.value("geom","1024,0,1024,768").toString(); if(!windowGeomString.isEmpty()) { QStringList list = windowGeomString.split(","); windowPos = QPoint(list[0].toInt(), list[1].toInt()); windowSize = QPoint(list[2].toInt(), list[3].toInt()); } setWindowGeom(QRect(windowPos.x(),windowPos.y(),windowSize.x(),windowSize.y())); bool frameless = config.value("frameless","true").toString() == "true"; if(frameless) setWindowFlags(Qt::FramelessWindowHint);// | Qt::ToolTip); connect(&m_pollDvizTimer, SIGNAL(timeout()), this, SLOT(initDvizPoll())); //connect(&m_pollImageTimer, SIGNAL(timeout()), this, SLOT(initImagePoll())); setUpdateTime(m_updateTime); //setUrl("http://10.10.9.90:8081/image"); //setUrl(""); //setPollDviz(true); setInputSource(config.value("source","dviz://192.168.0.10:8081/image").toString()); // m_startStopButton = new QPushButton("Start Counter"); // connect(m_startStopButton, SIGNAL(clicked()), this, SLOT(toggleCounter())); connect(&m_counterTimer, SIGNAL(timeout()), this, SLOT(counterTick())); m_counterTimer.setInterval(1000); // // m_startStopButton->show(); //toggleCounter(); setCounterActive(false); setBlinkOverlay(config.value("blink-overlay","false").toString() == "true", config.value("blink-speed", 333).toInt()); //setOverlayVisible(config.value("overlay-visible", "true").toString() == "true"); setCounterVisible(config.value("counter-visible", "true").toString() == "true"); setCounterAlignment((Qt::Alignment)config.value("counter-alignment", (int)(Qt::AlignLeft | Qt::AlignTop)).toInt()); setOverlayAlignment((Qt::Alignment)config.value("overlay-alignment", (int)(Qt::AlignCenter | Qt::AlignBottom)).toInt()); setOverlayText(config.value("overlay-text").toString()); }
MapGraphicsView::MapGraphicsView() : QGraphicsView() { #ifndef Q_OS_WIN srand ( time(NULL) ); #endif m_scaleFactor = 1.; #ifndef QT_NO_OPENGL //setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers))); #endif setCacheMode(CacheBackground); //setViewportUpdateMode(BoundingRectViewportUpdate); //setRenderHint(QPainter::Antialiasing); //setTransformationAnchor(AnchorUnderMouse); #ifdef Q_OS_ANDROID setTransformationAnchor(QGraphicsView::AnchorViewCenter); #endif setResizeAnchor(AnchorViewCenter); setDragMode(QGraphicsView::ScrollHandDrag); setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform ); // if there are ever graphic glitches to be found, remove this again setOptimizationFlags(QGraphicsView::DontAdjustForAntialiasing | QGraphicsView::DontClipPainter | QGraphicsView::DontSavePainterState); //setCacheMode(QGraphicsView::CacheBackground); //setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); setViewportUpdateMode(QGraphicsView::SmartViewportUpdate); setOptimizationFlags(QGraphicsView::DontSavePainterState); setFrameStyle(QFrame::NoFrame); #ifdef Q_OS_ANDROID setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); #endif QWidget *viewport = new QWidget(); QVBoxLayout *vbox = new QVBoxLayout(viewport); QHBoxLayout *hbox; hbox = new QHBoxLayout(); { hbox->setSpacing(0); hbox->addStretch(1); m_hudLabel = new QLabel(); hbox->addWidget(m_hudLabel); vbox->addLayout(hbox); } vbox->addStretch(1); hbox = new QHBoxLayout(); { hbox->setSpacing(0); hbox->addStretch(1); m_statusLabel = new QLabel(); hbox->addWidget(m_statusLabel); m_statusLabel->hide(); hbox->addStretch(1); } vbox->addLayout(hbox); hbox = new QHBoxLayout(); { hbox->setSpacing(0); hbox->addStretch(1); QPushButton *btn; { btn = new QPushButton("-"); btn->setStyleSheet("QPushButton {" #ifdef Q_OS_ANDROID "background: url(':/data/images/android-zoom-minus-button.png'); width: 117px; height: 47px; " #else "background: url(':/data/images/zoom-minus-button.png'); width: 58px; height: 24px; " #endif "padding:0; margin:0; border:none; color: transparent; outline: none; }"); btn->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); btn->setAutoRepeat(true); btn->setMaximumSize(117,48); connect(btn, SIGNAL(clicked()), this, SLOT(zoomOut())); hbox->addWidget(btn); } { btn = new QPushButton("+"); btn->setStyleSheet("QPushButton {" #ifdef Q_OS_ANDROID "background: url(':/data/images/android-zoom-plus-button.png'); width: 117px; height: 47px; " #else "background: url(':/data/images/zoom-plus-button.png'); width: 58px; height: 24px; " #endif "padding:0; margin:0; border:none; color: transparent; outline: none; }"); btn->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); btn->setAttribute(Qt::WA_TranslucentBackground, true); btn->setAutoRepeat(true); btn->setMaximumSize(117,48); connect(btn, SIGNAL(clicked()), this, SLOT(zoomIn())); hbox->addWidget(btn); } hbox->addStretch(1); } vbox->addLayout(hbox); m_viewportLayout = vbox; setViewport(viewport); // Set a timer to update layout because it doesn't give buttons correct position right at the start QTimer::singleShot(500, this, SLOT(updateViewportLayout())); // Disable here because it interferes with the 'longpress' functionality in MapGraphicsScene // FlickCharm *flickCharm = new FlickCharm(this); // flickCharm->activateOn(this); }