Esempio n. 1
0
	void HudWriter::draw(RenderEngine& render_engine)
	{
		if (!vertex_buffer_.empty() && ((drawMode() == DynamicDraw) || (drawMode() == StaticDraw) || (drawMode() == StreamDraw)) )
		{
			if (needsDataRefresh())
			{
				prepareDrawing(render_engine);
				needs_data_refresh = false;
			}

			render_engine.drawVertexArrayObject(vertex_vao_, vertex_buffer_);
		}
	}
Esempio n. 2
0
void PickingRenderer::renderVisualImage()
{
  glClearColor(0.2, 0.2, 0.2, 1.0);
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  glLineWidth(1.0);
  glPointSize(5.0);

  drawMode(GL_FILL);
  cube(vgl::Vec3f(0.3, 0.3, 0.3)); // Draw the faces
  drawMode(GL_LINE);
  cube(vgl::Vec3f(0.6, 0.6, 0.6)); // Draw the lines 
  drawMode(GL_POINT);
  cube(vgl::Vec3f(0.9, 0.9, 0.9)); // Draw the points
}
Esempio n. 3
0
void PickingRenderer::renderPickImage()
{
  glClearColor(0, 0, 0, 1);
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  glLineWidth(8.0);
  glPointSize(10.0);

  drawMode(GL_FILL);
  pickableCube(1); // Draw the faces
  drawMode(GL_LINE);
  pickableCube(2); // Draw the lines 
  drawMode(GL_POINT);
  pickableCube(3); // Draw the points
}
Esempio n. 4
0
void Segmenter::mouseMoveEvent (QGraphicsSceneMouseEvent * event)
{
    if (moveMode() || deleteMode()) {
        // call the base class implementation, which
        // forwards to event to items under the cursor
        this->QGraphicsScene::mouseMoveEvent(event);
    } else if (drawMode()) {
        // if we're not dragging and the marker is hidden
        // put the marker under the mouse and show it
        if (!event->buttons() & Qt::LeftButton && !m_markerdivider->isVisible()) {
            m_markerdivider->setPosition(event->scenePos());
            m_markerdivider->setVisible(true);
        }
        if (event->modifiers() & Qt::AltModifier) {
            m_captivedivider->setRotation(event->scenePos());
        } else {
            // prevent the 'jump' when the mouse and the item shift out of alignment
            // following a rotation by accounting for the direction of the mouse
            // and the displacement between them.  If in front of the item but moving
            // the mouse toward the object, leave the item stationary till we the
            // alignment goes away.
            qreal cdpos = m_captivedivider->mapRectToScene(m_captivedivider->boundingRect()).center().x();
            qreal diff = event->scenePos().x() - event->lastScenePos().x();
            if (diff > 0 && event->scenePos().x() < cdpos - 5) {

            } else if (diff < 0 && event->scenePos().x() > cdpos + 5) {

            } else {
                m_captivedivider->moveBy(diff, 0);
            }
        }
        update();        
    }
}
Esempio n. 5
0
void CDisplay::paintEvent(QPaintEvent *event)
{
    QPainter painter(this);

    // Draw background
    painter.fillRect(painter.window(),Qt::black);

    // Draw frequency
    drawFrequency(&painter);

    // Draw signal
    drawSignal(&painter);

    // Draw IF
    drawIF(&painter);

    // Draw Filter
    drawFilter(&painter);

    // Draw Step
    drawStepSize(&painter);

    // draw Mode
    drawMode(&painter);
}
Esempio n. 6
0
int main(void){
    square **map;
    int pause = 0;
    int c;
    //initialize
    init_curses();
    map = allocate_map();

    //Glider 
    /*
    map[5][5].cur = LIVE;
    map[5][6].cur = LIVE;
    map[5][7].cur = LIVE;
    map[4][7].cur = LIVE;
    map[3][6].cur = LIVE;
    */

    //Ocilator
    /*
    map[5][5].cur = LIVE;
    map[6][5].cur = LIVE;
    map[7][5].cur = LIVE;
    */

    for(;;){
        if((c = kbhit()) != 0){
            switch(c){
                case 32:
                    if(pause == 0) pause = 1;
                    else if(pause == 1) pause = 0;
                    break;
                case 27:
                    destruct(map);
                    return 0;
                case 100:
                    pause = 1;
                    drawMode(map);
                    break;
                case 112:
                    writeFile(map);
                    break;
                case 114:
                    readFile(map);
                    pause = 1;
                    break;
                case 99:
                    clearScr(map);
                    draw(map, 0);
                    pause = 1;
                    break;
            }
        }
        if(pause == 0)
            gameoflife(map);
        usleep(SECOND/FPS);
    }
    destruct(map);
    return 0;
}
Esempio n. 7
0
/**
 * The root node is treated separately; it cannot inherit values since it has no parent
 */
int UpdateNodesAndAttachments( Layer& rootNode,
                               BufferIndex updateBufferIndex,
                               ResourceManager& resourceManager,
                               RenderQueue& renderQueue,
                               Shader* defaultShader )
{
  DALI_ASSERT_DEBUG( rootNode.IsRoot() );

  // Short-circuit for invisible nodes
  if ( !rootNode.IsVisible( updateBufferIndex ) )
  {
    return 0;
  }

  // If the root node was not previously visible
  BufferIndex previousBuffer = updateBufferIndex ? 0u : 1u;
  if ( !rootNode.IsVisible( previousBuffer ) )
  {
    // The node was skipped in the previous update; it must recalculate everything
    rootNode.SetAllDirtyFlags();
  }

  int nodeDirtyFlags( rootNode.GetDirtyFlags() );

  if ( rootNode.GetInheritedShader() == NULL )
  {
    nodeDirtyFlags |= ShaderFlag;
  }

  int cumulativeDirtyFlags = nodeDirtyFlags;

  UpdateRootNodeShader( rootNode, nodeDirtyFlags, defaultShader );

  UpdateRootNodeOpacity( rootNode, nodeDirtyFlags, updateBufferIndex );

  UpdateRootNodeTransformValues( rootNode, nodeDirtyFlags, updateBufferIndex );

  DrawMode::Type drawMode( rootNode.GetDrawMode() );

  // recurse children
  NodeContainer& children = rootNode.GetChildren();
  const NodeIter endIter = children.End();
  for ( NodeIter iter = children.Begin(); iter != endIter; ++iter )
  {
    Node& child = **iter;
    cumulativeDirtyFlags |= UpdateNodesAndAttachments( child,
                                                       nodeDirtyFlags,
                                                       updateBufferIndex,
                                                       resourceManager,
                                                       renderQueue,
                                                       rootNode,
                                                       defaultShader,
                                                       drawMode );
  }

  return cumulativeDirtyFlags;
}
Esempio n. 8
0
void Segmenter::mouseReleaseEvent(QGraphicsSceneMouseEvent * event)
{
    m_markerdivider->setPosition(m_captivedivider->pos());
    // switch the tracked divider back to the marker    
    if (drawMode()) {
        //m_markerdivider->setPosition(event->scenePos());
        m_markerdivider->setVisible(true);
    }

    grabDivider(m_markerdivider);
}
Esempio n. 9
0
void EFPFragmentList::on_bondRadiusScale_valueChanged(int value)
{
   Layer::Primitive::DrawMode drawMode(m_efpFragmentList->m_drawMode);

   if (drawMode == Layer::Primitive::Tubes || 
       drawMode == Layer::Primitive::WireFrame) {
      m_efpFragmentListConfigurator.atomRadiusScale->setValue(
         m_efpFragmentListConfigurator.bondRadiusScale->value());
      m_efpFragmentList->setAtomScale(value/20.0);
   }
   m_efpFragmentList->setBondScale(value/20.0);
}
Esempio n. 10
0
void display()
{
    glViewport(0.0, 0.0, width, height);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();

    gluOrtho2D(ortho2D_minX, ortho2D_maxX, ortho2D_minY, ortho2D_maxY);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    drawMode();

    universe->Draw();

    glutSwapBuffers();
}
Esempio n. 11
0
void Segmenter::mousePressEvent (QGraphicsSceneMouseEvent * event)
{
    // left click in the scene with no mods - add a divider
    if (moveMode()) {
        this->QGraphicsScene::mousePressEvent(event);
    } else if (deleteMode()) {
        Divider* todelete = static_cast<Divider*>(this->itemAt(event->scenePos()));
        // TODO: Figure out why this causes a weird crash
        // it's supposed to test if we can delete an intermediate
        // point instead of the whole divider
        //if (!todelete->deletePointAt(event->scenePos())) {
        //    deleteDivider(todelete);
        //}
        deleteDivider(todelete);
    } else if (drawMode() && event->buttons() & Qt::LeftButton) {
        Divider* newdiv = addDivider(m_markerdivider->mapRectToScene(m_captivedivider->boundingRect()).center());
        // set the new div to match the marker poly
        newdiv->setPolygon(m_markerdivider->polygon());        
        // hide the marker and grab the new div - bit dodgy this...
        m_markerdivider->setVisible(false);
        grabDivider(newdiv);
    }
}
WorkoutWindow::WorkoutWindow(Context *context) :
    GcChartWindow(context), draw(true), context(context), active(false), recording(false)
{
    setContentsMargins(0,0,0,0);
    setProperty("color", GColor(CTRAINPLOTBACKGROUND));

    setControls(NULL);
    ergFile = NULL;

    QVBoxLayout *main = new QVBoxLayout;
    QHBoxLayout *layout = new QHBoxLayout;
    QVBoxLayout *editor = new QVBoxLayout;
    setChartLayout(main);

    connect(context, SIGNAL(configChanged(qint32)), this, SLOT(configChanged(qint32)));

    // the workout scene
    workout = new WorkoutWidget(this, context);

    // paint the TTE curve
    mmp = new WWMMPCurve(workout);

    // add a line between the dots
    line = new WWLine(workout);

    // block cursos
    bcursor = new WWBlockCursor(workout);

    // block selection
    brect = new WWBlockSelection(workout);

    // paint the W'bal curve
    wbline = new WWWBLine(workout, context);

    // telemetry
    telemetry = new WWTelemetry(workout, context);

    // add the power, W'bal scale
    powerscale = new WWPowerScale(workout, context);
    wbalscale = new WWWBalScale(workout, context);

    // lap markers
    lap = new WWLap(workout);

    // tte warning bar at bottom
    tte = new WWTTE(workout);

    // selection tool
    rect = new WWRect(workout);

    // guides always on top!
    guide = new WWSmartGuide(workout);

    // recording ...
    now = new WWNow(workout, context);

    // scroller, hidden until needed
    scroll = new QScrollBar(Qt::Horizontal, this);
    scroll->hide();

    // setup the toolbar
    toolbar = new QToolBar(this);
    toolbar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
    toolbar->setFloatable(true);
    toolbar->setIconSize(QSize(18 *dpiXFactor,18 *dpiYFactor));

    QIcon newIcon(":images/toolbar/new doc.png");
    newAct = new QAction(newIcon, tr("New"), this);
    connect(newAct, SIGNAL(triggered()), this, SLOT(newFile()));
    toolbar->addAction(newAct);

    QIcon saveIcon(":images/toolbar/save.png");
    saveAct = new QAction(saveIcon, tr("Save"), this);
    connect(saveAct, SIGNAL(triggered()), this, SLOT(saveFile()));
    toolbar->addAction(saveAct);

    QIcon saveAsIcon(":images/toolbar/saveas.png");
    saveAsAct = new QAction(saveAsIcon, tr("Save As"), this);
    connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs()));
    toolbar->addAction(saveAsAct);

    toolbar->addSeparator();

    //XXX TODO
    //XXXHelpWhatsThis *helpToolbar = new HelpWhatsThis(toolbar);
    //XXXtoolbar->setWhatsThis(helpToolbar->getWhatsThisText(HelpWhatsThis::ChartRides_Editor));

    // undo and redo deliberately at a distance from the
    // save icon, since accidentally hitting the wrong
    // icon in that instance would be horrible
    QIcon undoIcon(":images/toolbar/undo.png");
    undoAct = new QAction(undoIcon, tr("Undo"), this);
    connect(undoAct, SIGNAL(triggered()), workout, SLOT(undo()));
    toolbar->addAction(undoAct);

    QIcon redoIcon(":images/toolbar/redo.png");
    redoAct = new QAction(redoIcon, tr("Redo"), this);
    connect(redoAct, SIGNAL(triggered()), workout, SLOT(redo()));
    toolbar->addAction(redoAct);
    
    toolbar->addSeparator();

    QIcon drawIcon(":images/toolbar/edit.png");
    drawAct = new QAction(drawIcon, tr("Draw"), this);
    connect(drawAct, SIGNAL(triggered()), this, SLOT(drawMode()));
    toolbar->addAction(drawAct);

    QIcon selectIcon(":images/toolbar/select.png");
    selectAct = new QAction(selectIcon, tr("Select"), this);
    connect(selectAct, SIGNAL(triggered()), this, SLOT(selectMode()));
    toolbar->addAction(selectAct);

    selectAct->setEnabled(true);
    drawAct->setEnabled(false);

    toolbar->addSeparator();

    QIcon cutIcon(":images/toolbar/cut.png");
    cutAct = new QAction(cutIcon, tr("Cut"), this);
    cutAct->setEnabled(true);
    toolbar->addAction(cutAct);
    connect(cutAct, SIGNAL(triggered()), workout, SLOT(cut()));

    QIcon copyIcon(":images/toolbar/copy.png");
    copyAct = new QAction(copyIcon, tr("Copy"), this);
    copyAct->setEnabled(true);
    toolbar->addAction(copyAct);
    connect(copyAct, SIGNAL(triggered()), workout, SLOT(copy()));

    QIcon pasteIcon(":images/toolbar/paste.png");
    pasteAct = new QAction(pasteIcon, tr("Paste"), this);
    pasteAct->setEnabled(false);
    toolbar->addAction(pasteAct);
    connect(pasteAct, SIGNAL(triggered()), workout, SLOT(paste()));

    toolbar->addSeparator();

    QIcon propertiesIcon(":images/toolbar/properties.png");
    propertiesAct = new QAction(propertiesIcon, tr("Properties"), this);
    connect(propertiesAct, SIGNAL(triggered()), this, SLOT(properties()));
    toolbar->addAction(propertiesAct);

    QIcon zoomInIcon(":images/toolbar/zoom in.png");
    zoomInAct = new QAction(zoomInIcon, tr("Zoom In"), this);
    connect(zoomInAct, SIGNAL(triggered()), this, SLOT(zoomIn()));
    toolbar->addAction(zoomInAct);

    QIcon zoomOutIcon(":images/toolbar/zoom out.png");
    zoomOutAct = new QAction(zoomOutIcon, tr("Zoom Out"), this);
    connect(zoomOutAct, SIGNAL(triggered()), this, SLOT(zoomOut()));
    toolbar->addAction(zoomOutAct);

    // stretch the labels to the right hand side
    QWidget *empty = new QWidget(this);
    empty->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
    toolbar->addWidget(empty);


    xlabel = new QLabel("00:00");
    toolbar->addWidget(xlabel);

    ylabel = new QLabel("150w");
    toolbar->addWidget(ylabel);

    IFlabel = new QLabel("0 Intensity");
    toolbar->addWidget(IFlabel);

    TSSlabel = new QLabel("0 Stress");
    toolbar->addWidget(TSSlabel);

#if 0 // not yet!
    // get updates..
    connect(context, SIGNAL(telemetryUpdate(RealtimeData)), this, SLOT(telemetryUpdate(RealtimeData)));
    telemetryUpdate(RealtimeData());
#endif

    // editing the code...
    code = new CodeEditor(this);
    code->setContextMenuPolicy(Qt::NoContextMenu); // no context menu
    code->installEventFilter(this); // filter the undo/redo stuff
    code->hide();

    // WATTS and Duration for the cursor
    main->addWidget(toolbar);
    editor->addWidget(workout);
    editor->addWidget(scroll);
    layout->addLayout(editor);
    layout->addWidget(code);
    main->addLayout(layout);

    // make it look right
    saveAct->setEnabled(false);
    undoAct->setEnabled(false);
    redoAct->setEnabled(false);

    // watch for erg file selection
    connect(context, SIGNAL(ergFileSelected(ErgFile*)), this, SLOT(ergFileSelected(ErgFile*)));

    // watch for erg run/stop
    connect(context, SIGNAL(start()), this, SLOT(start()));
    connect(context, SIGNAL(stop()), this, SLOT(stop()));

    // text changed
    connect(code, SIGNAL(textChanged()), this, SLOT(qwkcodeChanged()));
    connect(code, SIGNAL(cursorPositionChanged()), workout, SLOT(hoverQwkcode()));

    // scrollbar
    connect(scroll, SIGNAL(sliderMoved(int)), this, SLOT(scrollMoved()));

    // set the widgets etc
    configChanged(CONFIG_APPEARANCE);
}
Esempio n. 13
0
WorkoutWindow::WorkoutWindow(Context *context) :
    GcWindow(context), draw(true), context(context), active(false)
{
    setContentsMargins(0,0,0,0);
    setProperty("color", GColor(CTRAINPLOTBACKGROUND));

    setControls(NULL);

    QVBoxLayout *layout = new QVBoxLayout(this);

    connect(context, SIGNAL(configChanged(qint32)), this, SLOT(configChanged(qint32)));

    // the workout scene
    workout = new WorkoutWidget(this, context);

    // paint the W'bal curve
    mmp = new WWMMPCurve(workout);

    // add the power, W'bal scale
    powerscale = new WWPowerScale(workout, context);
    wbalscale = new WWWBalScale(workout, context);

    // tte warning bar at bottom
    tte = new WWTTE(workout);

    // add a line between the dots
    line = new WWLine(workout);

    // block cursos
    bcursor = new WWBlockCursor(workout);

    // block selection
    brect = new WWBlockSelection(workout);

    // paint the W'bal curve
    wbline = new WWWBLine(workout, context);

    // selection tool
    rect = new WWRect(workout);

    // guides always on top!
    guide = new WWSmartGuide(workout);

    // setup the toolbar
    toolbar = new QToolBar(this);
    toolbar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
    toolbar->setFloatable(true);
    toolbar->setIconSize(QSize(18,18));

    QIcon saveIcon(":images/toolbar/save.png");
    saveAct = new QAction(saveIcon, tr("Save"), this);
    connect(saveAct, SIGNAL(triggered()), this, SLOT(saveFile()));
    toolbar->addAction(saveAct);

    toolbar->addSeparator();

    //XXX TODO
    //XXXHelpWhatsThis *helpToolbar = new HelpWhatsThis(toolbar);
    //XXXtoolbar->setWhatsThis(helpToolbar->getWhatsThisText(HelpWhatsThis::ChartRides_Editor));

    // undo and redo deliberately at a distance from the
    // save icon, since accidentally hitting the wrong
    // icon in that instance would be horrible
    QIcon undoIcon(":images/toolbar/undo.png");
    undoAct = new QAction(undoIcon, tr("Undo"), this);
    connect(undoAct, SIGNAL(triggered()), workout, SLOT(undo()));
    toolbar->addAction(undoAct);

    QIcon redoIcon(":images/toolbar/redo.png");
    redoAct = new QAction(redoIcon, tr("Redo"), this);
    connect(redoAct, SIGNAL(triggered()), workout, SLOT(redo()));
    toolbar->addAction(redoAct);
    
    toolbar->addSeparator();

    QIcon drawIcon(":images/toolbar/edit.png");
    drawAct = new QAction(drawIcon, tr("Draw"), this);
    connect(drawAct, SIGNAL(triggered()), this, SLOT(drawMode()));
    toolbar->addAction(drawAct);

    QIcon selectIcon(":images/toolbar/select.png");
    selectAct = new QAction(selectIcon, tr("Select"), this);
    connect(selectAct, SIGNAL(triggered()), this, SLOT(selectMode()));
    toolbar->addAction(selectAct);

    selectAct->setEnabled(true);
    drawAct->setEnabled(false);

    toolbar->addSeparator();

    QIcon cutIcon(":images/toolbar/cut.png");
    cutAct = new QAction(cutIcon, tr("Cut"), this);
    cutAct->setEnabled(true);
    toolbar->addAction(cutAct);
    connect(cutAct, SIGNAL(triggered()), workout, SLOT(cut()));

    QIcon copyIcon(":images/toolbar/copy.png");
    copyAct = new QAction(copyIcon, tr("Copy"), this);
    copyAct->setEnabled(true);
    toolbar->addAction(copyAct);
    connect(copyAct, SIGNAL(triggered()), workout, SLOT(copy()));

    QIcon pasteIcon(":images/toolbar/paste.png");
    pasteAct = new QAction(pasteIcon, tr("Paste"), this);
    pasteAct->setEnabled(false);
    toolbar->addAction(pasteAct);
    connect(pasteAct, SIGNAL(triggered()), workout, SLOT(paste()));

    // stretch the labels to the right hand side
    QWidget *empty = new QWidget(this);
    empty->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
    toolbar->addWidget(empty);


    xlabel = new QLabel("00:00");
    toolbar->addWidget(xlabel);

    ylabel = new QLabel("150w");
    toolbar->addWidget(ylabel);

    IFlabel = new QLabel("0 IF");
    toolbar->addWidget(IFlabel);

    TSSlabel = new QLabel("0 TSS");
    toolbar->addWidget(TSSlabel);

#if 0 // not yet!
    // get updates..
    connect(context, SIGNAL(telemetryUpdate(RealtimeData)), this, SLOT(telemetryUpdate(RealtimeData)));
    telemetryUpdate(RealtimeData());
#endif

    // WATTS and Duration for the cursor
    layout->addWidget(toolbar);
    layout->addWidget(workout);

    // make it look right
    saveAct->setEnabled(false);
    undoAct->setEnabled(false);
    redoAct->setEnabled(false);
    configChanged(CONFIG_APPEARANCE);
}