void RenderableDebugableEntityItem::render(EntityItem* entity, RenderArgs* args) { if (args->_debugFlags & RenderArgs::RENDER_DEBUG_SIMULATION_OWNERSHIP) { Q_ASSERT(args->_batch); gpu::Batch& batch = *args->_batch; batch.setModelTransform(entity->getTransformToCenter()); // we want to include the scale as well auto nodeList = DependencyManager::get<NodeList>(); const QUuid& myNodeID = nodeList->getSessionUUID(); bool highlightSimulationOwnership = (entity->getSimulatorID() == myNodeID); if (highlightSimulationOwnership) { glm::vec4 greenColor(0.0f, 1.0f, 0.2f, 1.0f); renderBoundingBox(entity, args, 0.08f, greenColor); } quint64 now = usecTimestampNow(); if (now - entity->getLastEditedFromRemote() < 0.1f * USECS_PER_SECOND) { glm::vec4 redColor(1.0f, 0.0f, 0.0f, 1.0f); renderBoundingBox(entity, args, 0.16f, redColor); } if (now - entity->getLastBroadcast() < 0.2f * USECS_PER_SECOND) { glm::vec4 yellowColor(1.0f, 1.0f, 0.2f, 1.0f); renderBoundingBox(entity, args, 0.24f, yellowColor); } ObjectMotionState* motionState = static_cast<ObjectMotionState*>(entity->getPhysicsInfo()); if (motionState && motionState->isActive()) { glm::vec4 blueColor(0.0f, 0.0f, 1.0f, 1.0f); renderBoundingBox(entity, args, 0.32f, blueColor); } } }
void Ball::drawBall(QPainter* painter) { // draw bg const QPoint center = rect().center(); int radius = width() > height() ? height() / 2 : width() / 2; QRadialGradient bgColor(center, radius, QPoint(center.x(), center.y() - 5)); if (_isInteractive && !_pressed) { QColor grayColor(176, 176, 176); bgColor.setColorAt(0.0, lighterColor(grayColor)); bgColor.setColorAt(1.0, grayColor); } else { if (_type == Red) { switch (numberZone(_number)) { case 1: bgColor.setColorAt(0.0, lighterColor(Zone1Color)); bgColor.setColorAt(1.0, Zone1Color); break; case 2: bgColor.setColorAt(0.0, lighterColor(Zone2Color)); bgColor.setColorAt(1.0, Zone2Color); break; case 3: bgColor.setColorAt(0.0, lighterColor(Zone3Color)); bgColor.setColorAt(1.0, Zone3Color); break; } } else { QColor blueColor(0, 162, 245); bgColor.setColorAt(0.0, lighterColor(blueColor)); bgColor.setColorAt(1.0, blueColor); } } painter->setBrush(bgColor); painter->setPen(Qt::NoPen); painter->drawEllipse(center, radius - 1, radius - 1); // draw text painter->setRenderHints(QPainter::TextAntialiasing); if ((_isInteractive && !_pressed) ||(_type == Red && (numberZone(_number) == 3 || numberZone(_number) == 2))) painter->setPen(AlternateNumberColor); else painter->setPen(NumberColor); QFont f = painter->font(); f.setBold(true); f.setPointSize(12); painter->setFont(f); painter->drawText(rect(), Qt::AlignVCenter | Qt::AlignHCenter, QString("%1").arg(_number)); }
void TupColorPalette::setBaseColorsPanel() { #ifndef Q_OS_ANDROID QSize cellSize(50, 30); #else QSize cellSize(70, 50); #endif k->currentBaseColor = 0; QColor redColor(255, 0, 0); QBrush redBrush(redColor, k->brush.style()); TupColorWidget *red = new TupColorWidget(0, redBrush, cellSize, false); red->selected(); connect(red, SIGNAL(clicked(int)), this, SLOT(updateMatrix(int))); k->baseColors << red; QColor greenColor(0, 255, 0); QBrush greenBrush(greenColor, k->brush.style()); TupColorWidget *green = new TupColorWidget(1, greenBrush, cellSize, false); connect(green, SIGNAL(clicked(int)), this, SLOT(updateMatrix(int))); k->baseColors << green; QColor blueColor(0, 0, 255); QBrush blueBrush(blueColor, k->brush.style()); TupColorWidget *blue = new TupColorWidget(2, blueBrush, cellSize, false); connect(blue, SIGNAL(clicked(int)), this, SLOT(updateMatrix(int))); k->baseColors << blue; QColor whiteColor(255, 255, 255); QBrush whiteBrush(whiteColor, k->brush.style()); TupColorWidget *white = new TupColorWidget(3, whiteBrush, cellSize, false); connect(white, SIGNAL(clicked(int)), this, SLOT(updateMatrix(int))); k->baseColors << white; QBoxLayout *bottomLayout = new QHBoxLayout; bottomLayout->setAlignment(Qt::AlignHCenter); bottomLayout->setContentsMargins(3, 3, 3, 3); #ifndef Q_OS_ANDROID bottomLayout->setSpacing(10); #else bottomLayout->setSpacing(25); #endif bottomLayout->addWidget(red); bottomLayout->addWidget(green); bottomLayout->addWidget(blue); bottomLayout->addWidget(white); k->paletteGlobalLayout->addWidget(new TupSeparator(Qt::Horizontal)); k->paletteGlobalLayout->addLayout(bottomLayout); }
void KeyboardDemo::Render( ) { if( d3dContext_ == 0 ) return; float clearColor[4] = { 0.0f, 0.0f, 0.25f, 1.0f }; d3dContext_->ClearRenderTargetView( backBufferTarget_, clearColor ); unsigned int stride = sizeof( VertexPos ); unsigned int offset = 0; d3dContext_->IASetInputLayout( inputLayout_ ); d3dContext_->IASetVertexBuffers( 0, 1, &vertexBuffer_, &stride, &offset ); d3dContext_->IASetPrimitiveTopology( D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST ); XMFLOAT4 redColor( 1.0f, 0.0f, 0.0f, 1.0f ); XMFLOAT4 greenColor( 0.0f, 1.0f, 0.0f, 1.0f ); XMFLOAT4 blueColor( 0.0f, 0.0f, 1.0f, 1.0f ); if( selectedColor_ == 0 ) { d3dContext_->UpdateSubresource( colorCB_, 0, 0, &redColor, 0, 0 ); } else if( selectedColor_ == 1 ) { d3dContext_->UpdateSubresource( colorCB_, 0, 0, &greenColor, 0, 0 ); } else { d3dContext_->UpdateSubresource( colorCB_, 0, 0, &blueColor, 0, 0 ); } d3dContext_->VSSetShader( customColorVS_, 0, 0 ); d3dContext_->PSSetShader( customColorPS_, 0, 0 ); d3dContext_->PSSetConstantBuffers( 0, 1, &colorCB_ ); d3dContext_->Draw( 3, 0 ); swapChain_->Present( 0, 0 ); }
void Histogram_gui::changeCurve(const QString & s) { std::map<float,int>::iterator itr; int total = histogram_->rawDataSize(); int i = 0; QwtText tfp("Probability"); tfp.setFont(plot_->axisFont(QwtPlot::yLeft)); QwtText tff("Frequency"); tff.setFont(plot_->axisFont(QwtPlot::yLeft)); QColor blueColor(Qt::blue); const QPen pen(blueColor); std::pair<double*,double*> curve = histogram_->plotting_data(); if (!curve.first) { appli_message("No data present"); return; } if (s == "cdf") { std::map<float, int> freqCount = histogram_->frequency(); _cdfCurve->setAxis(QwtPlot::xBottom, QwtPlot::yLeft); plot_->setAxisTitle(QwtPlot::yLeft, tfp); plot_->enableAxis(QwtPlot::yRight,false); curve_grid_->enableY(true); curve_grid_->setYAxis(QwtPlot::yLeft); plot_->enableAxis(QwtPlot::yLeft); curve_id_->setStyle(QwtPlotCurve::NoCurve); _cdfCurve->setStyle(QwtPlotCurve::Lines); double * x = new double[freqCount.size()+1]; double * y = new double[freqCount.size()+1]; y[0] = 0; for (itr = freqCount.begin(); itr != freqCount.end(); ++itr,++i) { x[i+1] = itr->first; y[i+1] = y[i]+(double)(itr->second)/(double)(total); } x[0] = x[1]; _cdfCurve->setPen(pen); _cdfCurve->setData( x, y, freqCount.size()+1 ); refresh_plot( _cdfCurve, std::make_pair( x,y ), freqCount.size()+1 ); refresh_stats(); delete []x; delete []y; } else if (s == "pdf") { //_cdfCurve->detach(); plot_->enableAxis(QwtPlot::yRight, false); plot_->setAxisTitle(QwtPlot::yLeft, tff); plot_->enableAxis(QwtPlot::xBottom); curve_id_->setAxis(QwtPlot::xBottom, QwtPlot::yLeft); curve_grid_->setYAxis(QwtPlot::yLeft); curve_grid_->enableY(true); curve_grid_->setXAxis(QwtPlot::xBottom); curve_grid_->enableX(true); _cdfCurve->setStyle(QwtPlotCurve::NoCurve); curve_id_->setStyle(QwtPlotCurve::Histogram); int size = histogram_->bins()+1; double* x = new double[size+1]; double* y = new double[size+1]; for( int i =0 ; i < size ; i++ ) { x[i+1] = curve.first[i]; y[i+1] = curve.second[i]; } x[0] = x[1]; y[0] = 0.0; refresh_plot( std::make_pair( x,y ), size+1 ); refresh_stats(); delete []x; delete []y; } else { std::map<float, int> freqCount = histogram_->frequency(); _cdfCurve->setAxis(QwtPlot::xBottom, QwtPlot::yRight); plot_->enableAxis(QwtPlot::yRight, true); plot_->enableAxis(QwtPlot::yLeft, true); curve_grid_->setYAxis(QwtPlot::yLeft); plot_->setAxisTitle(QwtPlot::yLeft, tff); plot_->setAxisTitle(QwtPlot::yRight, tfp); _cdfCurve->setStyle(QwtPlotCurve::Lines); curve_id_->setStyle(QwtPlotCurve::Histogram); double * x = new double[freqCount.size()+1]; double * y = new double[freqCount.size()+1]; y[0] = 0; for (itr = freqCount.begin(); itr != freqCount.end(); ++itr,++i) { x[i+1] = itr->first; y[i+1] = y[i]+(double)(itr->second)/(double)(total); } x[0] = x[1]; _cdfCurve->setPen(pen); _cdfCurve->setData( x, y, freqCount.size()+1 ); refresh_plot( _cdfCurve, std::make_pair( x,y ), freqCount.size()+1 ); //refresh_stats(); int size = histogram_->bins()+1; double* x1 = new double[size+1]; double* y1 = new double[size+1]; for( int i =0 ; i < size ; i++ ) { x1[i+1] = curve.first[i]; y1[i+1] = curve.second[i]; } x1[0] = x1[1]; y1[0] = 0.0; refresh_plot( std::make_pair( x1,y1 ), size+1 ); refresh_stats(); delete []x1; delete []y1; delete []x; delete []y; } //plot_->replot(); }