Exemplo n.º 1
0
void BeerStatsFrame::paintEvent(QPaintEvent *event)
{
    QPainter painter(this);

    painter.setRenderHint(QPainter::Antialiasing);

    frameWidth = width();
    frameHeight = height();

    if (CurrentKeg == NULL)
    {
        drawNone(painter, QString("empty"));
        return;
    }

    drawFooter(painter);

    int panel = -xOffset / frameWidth;
    int offset = (int)xOffset % frameWidth;

    drawContent(painter, panel, offset);
    if (offset != 0)
        drawContent(painter, panel + 1, offset + frameWidth);

    int panelX = currentPanel * -frameWidth;

    if (dragging == false && xOffset != panelX)
    {
        xOffset = (9*xOffset + panelX)/10.0;
        if ((int)(xOffset-0.5) == panelX)
            xOffset = panelX;
        update();
    }
}
Exemplo n.º 2
0
void		MonitorModule::draw( int posX, int posY, int width, IMonitorDisplay const & win ) {
    const int	bufSize = 1024;
    static char	tmp[bufSize];

    win.printBox(posX, posY, width, _height);

    if (_title.size()) {
        win.printHLine(posX, posY + 2, width);
        int diff = width - 2 - _title.size();
        if (diff > 0) {
            win.print(posX + 1 + diff / 2, posY + 1, _title.c_str(), RED);
            drawContent(posX + 1, posY + 3, width - 1, _height - 3, win);
        }
        else if (diff == 0) {
            win.print(posX + 1, posY + 1, _title.c_str(), RED);
            drawContent(posX + 1, posY + 3, width - 1, _height - 3, win);
        }
        else if (bufSize >= 2 && width - 2 < bufSize) {
            memcpy(tmp, _title.c_str(), bufSize);
            tmp[width - 2] = '.';
            tmp[width - 1] = '\0';
            win.print(posX + 1, posY + 1, tmp, RED);
            drawContent(posX + 1, posY + 1, width - 1, _height - 3, win);
        }
    }
    else
        drawContent(posX + 1, posY + 1, width - 1, _height - 1, win);
}
//--------------------------------------------------------------
void ofxMtActionsObject::render(){
	glColor3f(1,1,1);
	glPushMatrix();
		glTranslatef(x, y, 0);
		glRotatef(180.0f*rotation/PI, 0, 0, 1);
		drawContent();
		//ofRect(0, 0, width, height);
		//ofRect(-width/2, -height/2, width, height);
	glPopMatrix();


	if(drawTouchCounts) {
		glColor3f(1,1,1);
		glPushMatrix();
		glTranslatef(x + 30, y, 0);
		ofDrawBitmapString(ofToString((int)touches.size())+ " touches \n"
						   + "priority level : " + ofToString(priorityLevel) + "\n"
						   + "highest sessionId : " + ofToString(highestSessionID)
						   , 0, 15+width/2);
		glPopMatrix();
	}

	if (DEBUG) {
		ofSetColor(255, 255, 255);
		ofRect(centroid.x - 5, centroid.y - 5, 10, 10);
	}


}
Exemplo n.º 4
0
void MaEditorConsensusArea::paintEvent(QPaintEvent *e) {
    QSize s = size() * devicePixelRatio();
    QSize sas = ui->getSequenceArea()->size() * devicePixelRatio();

    if (sas.width() != s.width()) { //this can happen due to the manual layouting performed by MSAEditor -> just wait for the next resize+paint
        return;
    }

    assert(s.width() == sas.width());

    if (cachedView->size() != s) {
        delete cachedView;
        cachedView = new QPixmap(s);
        cachedView->setDevicePixelRatio(devicePixelRatio());
        completeRedraw = true;
    }

    if (completeRedraw) {
        QPainter pCached(cachedView);
        pCached.fillRect(cachedView->rect(), Qt::white);
        drawContent(pCached);
        completeRedraw = false;
    }

    QPainter painter(this);
    painter.drawPixmap(0, 0, *cachedView);

    QWidget::paintEvent(e);
}
Exemplo n.º 5
0
void Display::draw()
{
    if(!redraw || paused)
        return;

    glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
    glLoadIdentity();
    glTranslatef(0, 0, -3);

    if(mousestate.buttons[MOUSE_LEFT])
    {
        float ax = (float)mousestate.dy*180.0/winHeight;
        float ay = (float)mousestate.dx*180.0/winWidth;
        glRotatef(rotation[0]-ax, 1.0, 0.0, 0.0);
        glRotatef(rotation[1]-ay, 0.0, 1.0, 0.0);
    }
    else
    {
        glRotatef(rotation[0], 1.0, 0.0, 0.0);
        glRotatef(rotation[1], 0.0, 1.0, 0.0);
    }

    drawContent();
    glutSwapBuffers();
    redraw = false;
}
//----------------------------------------------------------------------------//
void RenderingSurface::draw()
{
    d_target->activate();

    drawContent();

    d_target->deactivate();
}
Exemplo n.º 7
0
QPixmap AbstractContent::toPixmap(const QSize & size, Qt::AspectRatioMode ratio)
{
    // allocate a fixed size pixmap and draw the content over it
    QPixmap pixmap(size);
    pixmap.fill(Qt::transparent);
    QPainter painter(&pixmap);
    drawContent(&painter, pixmap.rect(), ratio);
    painter.end();
    return pixmap;
}
Exemplo n.º 8
0
void TimeLineCells::paintEvent( QPaintEvent* event )
{
    Q_UNUSED( event );

    Object* object = mEditor->object();
    Layer* layer = mEditor->layers()->currentLayer();

    Q_ASSUME( object != nullptr && layer != nullptr );

    QPainter painter( this );

    bool isPlaying = mEditor->playback()->isPlaying();
    if ( ( !isPlaying && !timeLine->scrubbing ) || m_pCache == NULL )
    {
        drawContent();
    }
    if ( m_pCache )
    {
        painter.drawPixmap( QPoint( 0, 0 ), *m_pCache );
    }

    if ( m_eType == TIMELINE_CELL_TYPE::Tracks )
    {
        if (!isPlaying) {
            paintOnionSkin(painter);
        }

        // --- draw the position of the current frame
        if ( mEditor->currentFrame() > frameOffset )
        {
            painter.setBrush( QColor( 255, 0, 0, 128 ) );
            painter.setPen( Qt::NoPen );
            painter.setFont( QFont( "helvetica", 10 ) );
            //painter.setCompositionMode(QPainter::CompositionMode_Source); // this causes the message: QPainter::setCompositionMode: PorterDuff modes not supported on device
            QRect scrubRect;
            scrubRect.setTopLeft( QPoint( getFrameX( mEditor->currentFrame() - 1 ), 0 ) );
            scrubRect.setBottomRight( QPoint( getFrameX( mEditor->currentFrame() ), height() ) );
            if ( shortScrub )
            {
                scrubRect.setBottomRight( QPoint( getFrameX( mEditor->currentFrame() ), 19 ) );
            }
            painter.drawRect( scrubRect );
            painter.setPen( QColor( 70, 70, 70, 255 ) );
            int incr = 0;
            if ( mEditor->currentFrame() < 10 )
            {
                incr = 4;
            }
            else { incr = 0; }
            painter.drawText( QPoint( getFrameX( mEditor->currentFrame() - 1 ) + incr, 15 ),
                              QString::number( mEditor->currentFrame() ) );
        }
    }
}
	void KviCanvasEllipticItem::draw(QPainter &p)
	{
		if(isEnabled())
		{
			QBrush b = p.brush();
			if(m_properties["bHasBackground"].asBool())p.setBrush(m_properties["clrBackground"].asColor());
			else p.setBrush(QBrush());
			p.setPen(pen());
			drawContent(p);
			p.setBrush(b);
		}

		if(isSelected())drawSelection(p);
	}
Exemplo n.º 10
0
void TimelineWidget::paintEvent(QPaintEvent* event) {
    QPainter painter(this);

    QRectF fullRect = contentsRect();
    QRectF contentRect(0, 0, fullRect.width() - 1, fullRect.height() - LegendHeight);
    QRectF legendRect(0, fullRect.bottom() - LegendHeight, fullRect.right(), fullRect.bottom());

    painter.save();
    drawContent(painter, contentRect);
    painter.restore();

    painter.save();
    painter.translate(0, fullRect.height() - LegendHeight);
    drawLegend(painter, QRectF(legendRect));
    painter.restore();
}
Exemplo n.º 11
0
void AbstractContent::paint(QPainter * painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/)
{
    // find out whether to draw the selection
    const bool drawSelection = RenderOpts::HQRendering ? false : isSelected();

    // change opacity
    qreal opacity = contentOpacity();
    if (opacity < 1.0)
        painter->setOpacity(opacity);

    if (m_frame) {
        // draw the Frame
        m_frame->drawFrame(painter, m_frameRect.toRect(), drawSelection, contentOpaque());

        // use clip path for contents, if set
        if (m_frame->clipContents())
            painter->setClipPath(m_frame->contentsClipPath(m_contentRect));
    }

#if 0
    if (RenderOpts::OpenGLWindow && drawSelection)
        painter->setCompositionMode(QPainter::CompositionMode_Plus);
#endif

    // paint the inner contents
    const QRect tcRect = QRect(0, 0, m_contentRect.width(), m_contentRect.height());
    painter->translate(m_contentRect.topLeft());
    drawContent(painter, tcRect, Qt::IgnoreAspectRatio);

    // restore opacity
    if (opacity < 1.0)
        painter->setOpacity(1.0);

    // overlay a selection
    if (drawSelection && !m_frame) {
        painter->setRenderHint(QPainter::Antialiasing, true);
        QPen selPen(RenderOpts::hiColor, 2.0);
        selPen.setJoinStyle(Qt::MiterJoin);
        painter->setPen(selPen);
        painter->setBrush(Qt::NoBrush);
        painter->drawRect(tcRect.adjusted(1, 1, -1, -1));
    }
}
Exemplo n.º 12
0
void scrBase::draw() {
	if (enabled) {
		
		if (_lock != 0)
			if (!_lock->tryLock())
				return;
		drawContent();
		
		ofRectangle liveBounds = getLiveBounds();
		ofNotifyEvent(evtDraw, liveBounds, this);
		
		if (_lock != 0)
			_lock->unlock();
		
	}
	
	if (_hasChrome && g_isInterfaceEnabled)
		drawChrome();
}
Exemplo n.º 13
0
    /**
     * Draws the entire UI in two halves, one for the left eye and one for the right. The
     * Oculus Rift optical distortion effect is applied using a shader.
     *
     * @todo unwarpedTarget and unwarpedTexture should be cleared/deleted when Oculus
     * Rift mode is disabled (or whenever they are not needed).
     */
    void vrDrawOculusRift()
    {
        OculusRift &ovr = vrCfg.oculusRift();

        vrCfg.enableFrustumShift(false);

        // Use a little bit of multisampling to smooth out the magnified jagged edges.
        // Note: Independent of the window FSAA setting because this is beneficial even
        // when FSAA is disabled.
        unwarpedFB.setSampleCount(1); //vrCfg.riftFramebufferSampleCount());

        // Set render target to offscreen temporarily.
        GLState::push()
                .setTarget(unwarpedFB)
                .setViewport(Rectangleui::fromSize(unwarpedFB.size()));
        unwarpedFB.unsetActiveRect(true);

        GLTextureFramebuffer::Size const fbSize = unwarpedFB.size();

        // Left eye view on left side of screen.
        for (int eyeIdx = 0; eyeIdx < 2; ++eyeIdx)
        {
            ovr.setCurrentEye(eyeIdx);
            if (ovr.currentEye() == OculusRift::LeftEye)
            {
                // Left eye on the left side of the screen.
                unwarpedFB.setActiveRect(Rectangleui(0, 0, fbSize.x/2, fbSize.y), true);
            }
            else
            {
                // Right eye on the right side of screen.
                unwarpedFB.setActiveRect(Rectangleui(fbSize.x/2, 0, fbSize.x/2, fbSize.y), true);
            }
            drawContent();
        }

        unwarpedFB.unsetActiveRect(true);
        GLState::pop();

        vrCfg.enableFrustumShift(); // restore default
    }
Exemplo n.º 14
0
void	AWin::updateButton()
{
  std::list<Button*>::iterator	it;
  std::list<Button*>::iterator	itEnd;
  std::list<Button*>		button;
  int				x;
  int				y;

  button = getButton();
  it = button.begin();
  itEnd = button.end();
  x = _window.getSize().x / 2;
  y = _window.getSize().y / 2;
  while (it != itEnd)
    {
      (*it)->setPosU(x - 150, y - 50);
      (*it)->setPosD(x + 150, y + 50);
      y += 100;
      it++;
    }
  drawContent();
  _window.display();
}
Exemplo n.º 15
0
void TimeLineCells::updateContent()
{
    drawContent();
    update();
}
Exemplo n.º 16
0
void
KbfxPlasmaCanvasItem::draw ( QPainter & pe )
{
	drawContent ( &pe );
}
void UI::MandatoryNumericScreenFieldFormatter::draw(const ScreenField& f) const
{
    drawContent(f);
}
Exemplo n.º 18
0
bool	AWin::gestEvent(sf::Event event)
{
  std::list<Button*>::iterator  it;
  std::list<Button*>::iterator  itNew;
  std::list<Button*>::iterator  itEnd;
  std::list<Button*>    but;
  int   mX;
  int   mY;
  int   i;
  bool	newCur = false;

  but = getButton();
  if(event.type == sf::Event::Closed)
    {
      getWindow().close();
      return (false);
    }
  if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Escape)
    return (false);
  if (event.type == sf::Event::MouseMoved)
    {
      mX = event.mouseMove.x;
      mY = event.mouseMove.y;
      it = but.begin();
      itEnd = but.end();
      while (it != itEnd && but.size() > 0)
        {
          if ((*it)->isIn(mX, mY) == true)
	    {
	      itNew = it;
	      (*it)->setTarget(true);
	      newCur = true;
	    }
	  it++;
        }
      it = but.begin();
      while (it != itEnd && newCur == true && but.size() > 0)
	{
	  if (it != itNew)
	    (*it)->setTarget(false);
	  it++;
	}
    }
  if (event.type == sf::Event::MouseButtonReleased)
    {
      it = but.begin();
      itEnd = but.end();
      mX = event.mouseButton.x;
      mY = event.mouseButton.y;
      std::cout << mX <<"," << mY << std::endl;
      std::cout << event.type << std::endl;
      while (it != itEnd &&but.size() > 0)
        {
          if ((*it)->isIn(mX, mY) == true)
	    {
	      while (getButton().size() > 0)
		getButton().pop_back();
	      if ((*it) != NULL)
		if ((*it)->getWin() != NULL)
		  {
		    (*it)->getWin()->mainDraw();
		    return (false);
		  }
	    }
	  it++;
        }
    }
  if (event.type == sf::Event::Resized)
    updateButton();
  if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Down)
    upDown();
  if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Up)
    upUp();
  if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Return)
    {    
      launchWindow();
      return (false);
    }  
  getWindow().clear();
  drawContent();
  getWindow().display();
  usleep(1000);
  return (true);
}
Exemplo n.º 19
0
    void draw()
    {
        // Release the row-interleaved FB if not being used.
        rowInterNeedRelease = true;

        switch (vrCfg.mode())
        {
        // A) Single view type stereo 3D modes here:
        case VRConfig::Mono:
            // Non-stereoscopic frame.
            drawContent();
            break;

        case VRConfig::LeftOnly:
            // Left eye view
            vrCfg.setCurrentEye(VRConfig::LeftEye);
            drawContent();
            break;

        case VRConfig::RightOnly:
            // Right eye view
            vrCfg.setCurrentEye(VRConfig::RightEye);
            drawContent();
            break;

        // B) Split-screen type stereo 3D modes here:
        case VRConfig::TopBottom: // Left goes on top
            // Left eye view on top of screen.
            vrCfg.setCurrentEye(VRConfig::LeftEye);
            target().setActiveRect(Rectangleui(0, 0, width(), height()/2), true);
            drawContent();
            // Right eye view on bottom of screen.
            vrCfg.setCurrentEye(VRConfig::RightEye);
            target().setActiveRect(Rectangleui(0, height()/2, width(), height()/2), true);
            drawContent();
            break;

        case VRConfig::SideBySide: // Squished aspect
            // Left eye view on left side of screen.
            vrCfg.setCurrentEye(VRConfig::LeftEye);
            target().setActiveRect(Rectangleui(0, 0, width()/2, height()), true);
            drawContent();
            // Right eye view on right side of screen.
            vrCfg.setCurrentEye(VRConfig::RightEye);
            target().setActiveRect(Rectangleui(width()/2, 0, width()/2, height()), true);
            drawContent();
            break;

        case VRConfig::Parallel: // Normal aspect
            // Left eye view on left side of screen.
            vrCfg.setCurrentEye(VRConfig::LeftEye);
            target().setActiveRect(Rectangleui(0, 0, width()/2, height()), true);
            drawContent();
            // Right eye view on right side of screen.
            vrCfg.setCurrentEye(VRConfig::RightEye);
            target().setActiveRect(Rectangleui(width()/2, 0, width()/2, height()), true);
            drawContent();
            break;

        case VRConfig::CrossEye: // Normal aspect
            // Right eye view on left side of screen.
            vrCfg.setCurrentEye(VRConfig::RightEye);
            target().setActiveRect(Rectangleui(0, 0, width()/2, height()), true);
            drawContent();
            // Left eye view on right side of screen.
            vrCfg.setCurrentEye(VRConfig::LeftEye);
            target().setActiveRect(Rectangleui(width()/2, 0, width()/2, height()), true);
            drawContent();
            break;

        case VRConfig::OculusRift:
            vrDrawOculusRift();
            break;

        // Overlaid type stereo 3D modes below:
        case VRConfig::GreenMagenta:
            // Left eye view
            vrCfg.setCurrentEye(VRConfig::LeftEye);
            GLState::push().setColorMask(gl::WriteGreen | gl::WriteAlpha); // Left eye view green
            drawContent();
            // Right eye view
            vrCfg.setCurrentEye(VRConfig::RightEye);
            GLState::current().setColorMask(gl::WriteRed | gl::WriteBlue | gl::WriteAlpha); // Right eye view magenta
            drawContent();
            GLState::pop();
            break;

        case VRConfig::RedCyan:
            // Left eye view
            vrCfg.setCurrentEye(VRConfig::LeftEye);
            GLState::push().setColorMask(gl::WriteRed | gl::WriteAlpha); // Left eye view red
            drawContent();
            // Right eye view
            vrCfg.setCurrentEye(VRConfig::RightEye);
            GLState::current().setColorMask(gl::WriteGreen | gl::WriteBlue | gl::WriteAlpha); // Right eye view cyan
            drawContent();
            GLState::pop();
            break;

        case VRConfig::QuadBuffered:
            if (self().window().format().stereo())
            {
                /// @todo Fix me!

                // Left eye view
                vrCfg.setCurrentEye(VRConfig::LeftEye);
                drawContent();
                //canvas().framebuffer().swapBuffers(canvas(), gl::SwapStereoLeftBuffer);

                // Right eye view
                vrCfg.setCurrentEye(VRConfig::RightEye);
                drawContent();
                //canvas().framebuffer().swapBuffers(canvas(), gl::SwapStereoRightBuffer);
            }
            else
            {
                // Normal non-stereoscopic frame.
                drawContent();
            }
            break;

        case VRConfig::RowInterleaved: {
#if !defined (DENG_MOBILE)
            // Use absolute screen position of window to determine whether the
            // first scan line is odd or even.
            QPoint ulCorner(0, 0);
            ulCorner = self().window().mapToGlobal(ulCorner); // widget to screen coordinates
            bool const rowParityIsEven = ((int(ulCorner.y()) % 2) == 0);

            rowInterNeedRelease = false;

            // Draw the left eye view.
            rowInterLeftFB.glInit();
            rowInterLeftFB.resize(GLFramebuffer::Size(width(), height()));
            rowInterLeftFB.colorTexture().setFilter(gl::Linear, gl::Linear, gl::MipNone);
            rowInterLeftFB.colorTexture().glApplyParameters();
            GLState::push()
                    .setTarget(rowInterLeftFB)
                    .setViewport(Rectangleui::fromSize(rowInterLeftFB.size()));
            vrCfg.setCurrentEye(rowParityIsEven? VRConfig::LeftEye : VRConfig::RightEye);
            drawContent();
            GLState::pop();

            // Draw right the eye view.
            rowInterRightFB.glInit();
            rowInterRightFB.resize(GLFramebuffer::Size(width(), height()));
            rowInterRightFB.colorTexture().setFilter(gl::Linear, gl::Linear, gl::MipNone);
            rowInterRightFB.colorTexture().glApplyParameters();
            GLState::push()
                    .setTarget(rowInterRightFB)
                    .setViewport(Rectangleui::fromSize(rowInterRightFB.size()));
            vrCfg.setCurrentEye(rowParityIsEven ? VRConfig::RightEye : VRConfig::LeftEye);
            drawContent();
            GLState::pop();

            // Draw right eye view to the screen from FBO color texture
            vrInitRowInterleaved();
            rowInterUniformTex  = rowInterLeftFB.colorTexture();
            rowInterUniformTex2 = rowInterRightFB.colorTexture();
            rowInterDrawable.draw();
#endif
            break;
          }

        case VRConfig::ColumnInterleaved: /// @todo implement column interleaved stereo 3D after row intleaved is working correctly...
        case VRConfig::Checkerboard: /// @todo implement checker stereo 3D after row intleaved is working correctly ...
        default:
            // Non-stereoscopic frame.
            drawContent();
            break;
        }

        if (rowInterNeedRelease)
        {
            // release unused FBOs
            rowInterRightFB.glDeinit();
        }

        // Restore default VR dynamic parameters
        target().unsetActiveRect(true);
        vrCfg.setCurrentEye(VRConfig::NeitherEye);

        LIBGUI_ASSERT_GL_OK();
    }