void dialogAnalog::plot(bool forceRedraw,QSize size) { QPainter p; screenPixmap = QPixmap( size); if (forceRedraw) { initPixmap(size); QColor greenColor(Qt::green); QPen dataPen1( greenColor); fillPixmap(&dataplot,&dataPen1); #if 0 QPen dataPen2(QColor(Qt::red)); dataPen2.setStyle(Qt::DashDotDotLine); fillPixmap(&dataplot2,&dataPen2); #endif } p.begin(&screenPixmap); p.drawPixmap(0, 0, lastPixmap); drawMarkers(&p); p.end(); // draw markers }
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 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 dialogAnalog::initPixmap(QSize size) { // resize the pixmap // complete it // Draw plot QPainter painter; int heightPerField = size.height() / NbBits; lastPixmap=QPixmap( size.width(), size.height() ); lastPixmap.fill(Qt::black); painter.begin(&lastPixmap); // set font ------------------------------------------------------------------------------------ QFont textFont; textFont.setPixelSize(heightPerField / 2); painter.setFont(textFont); // set the needed pens ------------------------------------------------------------------------- QPen linePen(QColor(100,100,100)); QPen textPen(QColor(255, 255, 255)); QPen gridPen(QColor(100, 100, 100)); QColor greenColor(Qt::green); QPen dataPen(greenColor); // draw the fields and the text ---------------------------------------------------------------- { int current = heightPerField; for (int i = 0; i < (NbBits - 1); i++) { painter.setPen(linePen); painter.drawLine(0, current, size.width(), current); painter.setPen(textPen); QString lbl = QString::number(i+1); if (currentlabels.contains(i+1)) lbl += "-"+currentlabels[i+1]; painter.drawText(10, current - heightPerField / 3, lbl); current += heightPerField; } painter.setPen(textPen); painter.drawText(10, current - 15, QString::number(NbBits)); } painter.end(); }
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 ); }
// NOTE: this only renders the "meta" portion of the Model, namely it renders debugging items, and it handles // the per frame simulation/update that might be required if the models properties changed. void RenderableModelEntityItem::render(RenderArgs* args) { PerformanceTimer perfTimer("RMEIrender"); assert(getType() == EntityTypes::Model); if (hasModel()) { if (_model) { if (getModelURL() != _model->getURL().toString()) { qDebug() << "Updating model URL: " << getModelURL(); _model->setURL(getModelURL()); } render::ScenePointer scene = AbstractViewStateInterface::instance()->getMain3DScene(); // check to see if when we added our models to the scene they were ready, if they were not ready, then // fix them up in the scene if (_model->needsFixupInScene()) { render::PendingChanges pendingChanges; _model->removeFromScene(scene, pendingChanges); render::Item::Status::Getters statusGetters; makeEntityItemStatusGetters(this, statusGetters); _model->addToScene(scene, pendingChanges, statusGetters); scene->enqueuePendingChanges(pendingChanges); } // FIXME: this seems like it could be optimized if we tracked our last known visible state in // the renderable item. As it stands now the model checks it's visible/invisible state // so most of the time we don't do anything in this function. _model->setVisibleInScene(getVisible(), scene); } remapTextures(); { // float alpha = getLocalRenderAlpha(); if (!_model || _needsModelReload) { // TODO: this getModel() appears to be about 3% of model render time. We should optimize PerformanceTimer perfTimer("getModel"); EntityTreeRenderer* renderer = static_cast<EntityTreeRenderer*>(args->_renderer); getModel(renderer); } if (_model) { // handle animations.. if (hasAnimation()) { if (!jointsMapped()) { QStringList modelJointNames = _model->getJointNames(); mapJoints(modelJointNames); } if (jointsMapped()) { bool newFrame; QVector<glm::quat> frameDataRotations; QVector<glm::vec3> frameDataTranslations; getAnimationFrame(newFrame, frameDataRotations, frameDataTranslations); assert(frameDataRotations.size() == frameDataTranslations.size()); if (newFrame) { for (int i = 0; i < frameDataRotations.size(); i++) { _model->setJointState(i, true, frameDataRotations[i], frameDataTranslations[i], 1.0f); } } } } bool movingOrAnimating = isMoving() || isAnimatingSomething(); if ((movingOrAnimating || _needsInitialSimulation) && _model->isActive() && _dimensionsInitialized) { _model->setScaleToFit(true, getDimensions()); _model->setSnapModelToRegistrationPoint(true, getRegistrationPoint()); _model->setRotation(getRotation()); _model->setTranslation(getPosition()); // make sure to simulate so everything gets set up correctly for rendering { PerformanceTimer perfTimer("_model->simulate"); _model->simulate(0.0f); } _needsInitialSimulation = false; } } } } else { glm::vec4 greenColor(0.0f, 1.0f, 0.0f, 1.0f); RenderableDebugableEntityItem::renderBoundingBox(this, args, 0.0f, greenColor); } RenderableDebugableEntityItem::render(this, args); }
void CameraProjections::Publish(Mat &guiRawImg, bool showHorizonBox) { if (!lastProjectionIsValid || guiRawImg.empty()) return; ros::Time now = ros::Time::now(); if (params.debug.showTopView->get()) { Mat UnDistRawImg; //Mat tmpp; //_distorionModel.CreateUndistortFull(guiRawImg, tmpp); _distorionModel.CreateUndistort(guiRawImg, UnDistRawImg); unDistortedImg_pub.publish(UnDistRawImg, MatPublisher::bgr); int sizeOfTopViewW = params.topView.width->get() / params.topView.scale->get(); int sizeOfTopViewH = params.topView.width->get() / params.topView.scale->get(); if (topImg_pub.thereAreListeners()) { Mat topHomoFor, topHomoBack; double picYawDegree; if (ipm.GetHomographyNoYaw(diagnalAngleView, cameraLocation, cameraOrintation, topHomoFor, topHomoBack, picYawDegree)) { warpPerspective(UnDistRawImg, topViewBGR, topHomoFor, Size(sizeOfTopViewW, sizeOfTopViewH), CV_INTER_LINEAR | CV_WARP_FILL_OUTLIERS); topImg_pub.publish(topViewBGR, MatPublisher::bgr); } } if (mmap_pub.getNumSubscribers() > 0) { warpPerspective(UnDistRawImg, calibViewBGR, realHomoFor, Size(sizeOfTopViewW, sizeOfTopViewH), CV_INTER_LINEAR | CV_WARP_FILL_OUTLIERS); calibImg_pub.publish(calibViewBGR, MatPublisher::bgr); Mat mapMonoImg(calibViewBGR.size(), CV_8UC1); cvtColor(calibViewBGR, mapMonoImg, CV_BGR2GRAY); std_msgs::Header head; nav_msgs::MapMetaData mapMeta; head.frame_id = "/ego_floor"; head.stamp = now; mapMeta.height = mapMonoImg.size().height; mapMeta.width = mapMonoImg.size().width; mapMeta.map_load_time = now; mapMeta.resolution = 0.01 * params.topView.scale->get(); mapMeta.origin.orientation.w = 1; mapMeta.origin.position.x = -(int) (params.topView.width->get() / 2.) / 100.; mapMeta.origin.position.y = -(int) (params.topView.width->get() / 2.) / 100.; mapMeta.origin.position.z = 0.1; for (uint16_t y = 0; y < mapMonoImg.size().height; y++) { for (uint16_t x = 0; x < mapMonoImg.size().width; x++) { mmap.data.push_back( (mapMonoImg.at<uchar>(y, x) / 255.) * 100.); } } mmap.header = head; mmap.info = mapMeta; mmap_pub.publish(mmap); mmap.data.clear(); } } if (params.debug.showCameraPoints->get()) { for (int i = 0; i <= 4; i++) { int k = i; if (i == 4) { k = 0; } geometry_msgs::Point p; p.x = transformedPointsRes[k].x / 100.; p.y = transformedPointsRes[k].y / 100.; p.z = transformedPointsRes[k].z / 100.; topViewCPoints.marker.points.push_back(p); } geometry_msgs::Point p; p.x = cameraLocation.x; p.y = cameraLocation.y; p.z = cameraLocation.z; topViewCPoints.marker.points.push_back(p); for (int i = 0; i <= 4; i++) { int k = i; if (i == 4) { k = 0; } geometry_msgs::Point p; p.x = gPointRes[k].x / 100.; p.y = gPointRes[k].y / 100.; p.z = -0.0; topViewGPoints.marker.points.push_back(p); } topViewCPoints.update(); topViewGPoints.update(); topViewMarker.publish(); topViewCPoints.marker.points.clear(); topViewGPoints.marker.points.clear(); } if (showHorizonBox && params.debug.showHorizonBox->get()) { for (int i = 0; i <= 3; i++) { int p1 = i; int p2 = i + 1; if (i == 3) { p2 = 0; } char msg[255]; sprintf(msg, "(%d)", i); putText(guiRawImg, msg, outerCornetrsRawImg[i], 1, 1, greenColor()); line(guiRawImg, outerCornetrsRawImg[p1], outerCornetrsRawImg[p2], redColor(), 3); } circle(guiRawImg, Point2d(320, 240), 5, redColor(), 5); } }