void SparseOccupancyGridArrayDisplay::processMessage( const jsk_recognition_msgs::SparseOccupancyGridArray::ConstPtr& msg) { allocateCloudsAndNodes(msg->grids.size()); // not enough for (size_t i = 0; i < msg->grids.size(); i++) { Ogre::SceneNode* node = nodes_[i]; rviz::PointCloud* cloud = clouds_[i]; const jsk_recognition_msgs::SparseOccupancyGrid grid = msg->grids[i]; Ogre::Vector3 position; Ogre::Quaternion quaternion; if(!context_->getFrameManager()->transform(grid.header, grid.origin_pose, position, quaternion)) { ROS_ERROR( "Error transforming pose '%s' from frame '%s' to frame '%s'", qPrintable( getName() ), grid.header.frame_id.c_str(), qPrintable( fixed_frame_ )); return; // return? } node->setPosition(position); node->setOrientation(quaternion); cloud->setDimensions(grid.resolution, grid.resolution, 0.0); std::vector<rviz::PointCloud::Point> points; for (size_t ci = 0; ci < grid.columns.size(); ci++) { const jsk_recognition_msgs::SparseOccupancyGridColumn column = grid.columns[ci]; const int column_index = column.column_index; for (size_t ri = 0; ri < column.cells.size(); ri++) { const jsk_recognition_msgs::SparseOccupancyGridCell cell = column.cells[ri]; const int row_index = cell.row_index; rviz::PointCloud::Point point; if (!axis_color_) { QColor color = gridColor(cell.value); Ogre::ColourValue ogre_color = rviz::qtToOgre(color); point.color = ogre_color; } else { QColor color = axisColor(quaternion, Ogre::Vector3(1, 0, 0)); Ogre::ColourValue ogre_color = rviz::qtToOgre(color); point.color = ogre_color; } point.position.x = grid.resolution * (column_index + 0.5); point.position.y = grid.resolution * (row_index + 0.5); point.position.z = 0.0; points.push_back(point); } } cloud->clear(); cloud->setAlpha(alpha_); if (!points.empty()) { cloud->addPoints(&points.front(), points.size()); } } context_->queueRender(); }
void Level::render() { GameState::render(); camera->commit(); glLightfv(GL_LIGHT0, GL_POSITION, light0Pos); // Applies camera changes to the scene Col axisColor(0.2f, 0.7f, 0.95f, 0.7f); //ColExp1 axisColor1(0.2f, 0.7f, 0.95f, 0.7f); //ColExp2 axisColor2(0.2f, 0.7f, 0.95f, 0.7f); GrcPrimitives::segment(Vec3(0, 0, 0), Vec3(10, 0, 0), axisColor); GrcPrimitives::segment(Vec3(0, 0, 0), Vec3(0, 10, 0), axisColor); GrcPrimitives::segment(Vec3(0, 0, 0), Vec3(0, 0, 10), axisColor); GrcPrimitives::ray(exampleEntity->getTransform().getPosition(), exampleEntity->getTransform().getForward(), Col(1.0f, 1.0f, 1.0f, 1.0f)); GrcPrimitives::ray(exampleEntity->getTransform().getPosition(), exampleEntity->getTransform().getRight(), Col(1.0f, 1.0f, 1.0f, 1.0f)); GrcPrimitives::ray(exampleEntity->getTransform().getPosition(), exampleEntity->getTransform().getUp(), Col(1.0f, 1.0f, 1.0f, 1.0f)); floorProg->enable(); floorProg->bindTexture("tex", floorTex->index, GL_TEXTURE_2D, 0); GLfloat light0Color[]={1.0f, 1.0f, 0.8f}; floorProg->setUniformfv("lightColor", light0Color, 3); glColor3f(1.0f, 1.0f, 1.0f); glNormal3f(0.0f, 1.0f, 0.0f); glBegin(GL_QUADS); { float s = 20.f; float rep = 20.f; glTexCoord2f(0.f, 0.f); glVertex3f(-s, -5, -s); glTexCoord2f(rep, 0.f); glVertex3f(s, -5.f, -s); glTexCoord2f(rep, rep); glVertex3f(s, -5.f, s); glTexCoord2f(0.f, rep); glVertex3f(-s, -5.f, s); } glEnd(); floorProg->disable(); objProg->enable(); objProg->setUniformfv("lightColor", light0Color, 3); exampleEntity->Render(); objProg->disable(); }
void RotationManipulator::RenderScaled(const Vect &cameraDir, float scale) { traceInFast(RotationManipulator::RenderScaled); DWORD i; Shader *rotManipShader = GetVertexShader(TEXT("Editor:RotationManipulator.vShader")); LoadVertexShader(rotManipShader); LoadPixelShader(GetPixelShader(TEXT("Base:SolidColor.pShader"))); rotManipShader->SetVector(rotManipShader->GetParameter(2), cameraDir); MatrixPush(); MatrixTranslate(GetWorldPos()); MatrixScale(scale, scale, scale); for(i=0; i<3; i++) { Vect axisColor(0.0f, 0.0f, 0.0f); axisColor.ptr[i] = 1.0f; if(i == activeAxis) axisColor.Set(1.0f, 1.0f, 0.0f); else axisColor.ptr[i] = 1.0f; rotManipShader->SetVector(rotManipShader->GetParameter(1), axisColor); LoadVertexBuffer(axisBuffers[i]); LoadIndexBuffer(NULL); Draw(GS_LINESTRIP); } LoadVertexBuffer(NULL); //---------------------------------------------------- Shader *solidShader = GetVertexShader(TEXT("Base:SolidColor.vShader")); LoadVertexShader(solidShader); MatrixPush(); MatrixRotate(Quat().SetLookDirection(cameraDir)); LoadVertexBuffer(axisBuffers[2]); LoadIndexBuffer(NULL); solidShader->SetColor(solidShader->GetParameter(1), 0.5, 0.5, 0.5, 0.5); Draw(GS_LINESTRIP); MatrixScale(1.25f, 1.25f, 1.25f); //--------------- if(activeAxis == 4) solidShader->SetColor(solidShader->GetParameter(1), 1.0f, 1.0f, 0.0, 1.0f); else solidShader->SetColor(solidShader->GetParameter(1), 0.8, 0.8, 0.8, 0.8); Draw(GS_LINESTRIP); MatrixPop(); MatrixPop(); LoadVertexShader(NULL); LoadPixelShader(NULL); traceOutFast; }
void FadeMetro::paintEvent(QPaintEvent* /*event*/) { QPainter painter(this); painter.setRenderHints(QPainter::Antialiasing|QPainter::TextAntialiasing); QPainterPath clip; clip.addRoundedRect(m_MetroRect, ROUNDED, ROUNDED); painter.setClipPath(clip); const QPixmap &pixmap = m_Images[m_ImageIndex].pixmap; if( !pixmap.isNull() ) { painter.drawPixmap( m_MetroRect.x() + qRound((m_MetroRect.width()-pixmap.width())*0.5), m_MetroRect.y() + qRound((m_MetroRect.height()-pixmap.height())*0.5), pixmap ); } painter.setClipping(false); float brightness = m_Click; if(m_Hover > 0) brightness += (m_Hover*0.2f); QColor color( palette().color(QPalette::Button) ); if(brightness > 0) { qreal t = (brightness * BUTTON_BRIGHTESS); color.setRedF( qMin(color.redF()+t,1.0) ); color.setGreenF( qMin(color.greenF()+t,1.0) ); color.setBlueF( qMin(color.blueF()+t,1.0) ); } float t = sinf(m_Pos); const float TRAVEL_45_DEGREES_IN_RADIANS = 0.785398163f; float radians = (t * TRAVEL_45_DEGREES_IN_RADIANS); float armPenWidth = (BORDER * 2); QPointF base(m_MetroRect.x()+m_MetroRect.width()*0.5, m_MetroRect.bottom()); QColor axisColor(color); axisColor.setAlpha(180); painter.setPen( QPen(axisColor,HALF_BORDER) ); painter.drawLine(base.x(), base.y(), base.x(), m_MetroRect.y()); painter.setPen( QPen(color,BORDER,Qt::SolidLine,Qt::SquareCap,Qt::RoundJoin) ); painter.setBrush(Qt::NoBrush); painter.drawRoundedRect(m_MetroRect, ROUNDED, ROUNDED); QPointF tip(base.x() + m_ArmLength*sinf(radians), m_MetroRect.height() - m_ArmLength*cosf(radians)); painter.setPen( QPen(color,armPenWidth,Qt::SolidLine,Qt::RoundCap) ); painter.drawLine(base, tip); if( !text().isEmpty() ) { int hoverRaise = qRound(m_Hover * BUTTON_RAISE); painter.setFont( font() ); painter.setPen( palette().color(QPalette::ButtonText) ); painter.drawText(QRect(0,0,width(),m_MetroRect.y()-hoverRaise), Qt::AlignCenter|Qt::TextWordWrap|Qt::TextDontClip, text()); if( !m_Label.isEmpty() ) painter.drawText(QRect(0,m_MetroRect.bottom(),width(),height()-m_MetroRect.bottom()+hoverRaise), Qt::AlignCenter|Qt::TextWordWrap|Qt::TextDontClip, m_Label); } else if( !m_Label.isEmpty() ) { int hoverRaise = qRound(m_Hover * BUTTON_RAISE); painter.setFont( font() ); painter.setPen( palette().color(QPalette::ButtonText) ); painter.drawText(QRect(0,m_MetroRect.bottom(),width(),height()-m_MetroRect.bottom()+hoverRaise), Qt::AlignCenter|Qt::TextWordWrap|Qt::TextDontClip, m_Label); } if( m_Paused ) { painter.setOpacity(0.8); color = color.lighter(250); painter.setPen(color); painter.setBrush(BG_COLOR); int pauseSize = qRound(0.6 * qMin(m_MetroRect.width(),m_MetroRect.height())); QRect pauseRect( m_MetroRect.x() + qRound((m_MetroRect.width()-pauseSize)*0.5), m_MetroRect.y() + qRound((m_MetroRect.height()-pauseSize)*0.5), pauseSize, pauseSize ); painter.drawRoundedRect(pauseRect, ROUNDED, ROUNDED); int w = qRound(pauseSize * 0.35); int h = qRound(pauseSize * 0.7); pauseRect.adjust(w, h, -w, -h); painter.setPen( QPen(color,pauseSize*0.1,Qt::SolidLine,Qt::RoundCap) ); painter.drawLine(pauseRect.left(), pauseRect.top(), pauseRect.left(), pauseRect.bottom()); painter.drawLine(pauseRect.right(), pauseRect.top(), pauseRect.right(), pauseRect.bottom()); } }
void ExoplanetsDialog::populateDiagramsList() { Q_ASSERT(ui->comboAxisX); Q_ASSERT(ui->comboAxisY); QColor axisColor(Qt::white); QPen axisPen(axisColor, 1); ui->customPlot->setBackground(QBrush(QColor(86, 87, 90))); ui->customPlot->xAxis->setLabelColor(axisColor); ui->customPlot->xAxis->setTickLabelColor(axisColor); ui->customPlot->xAxis->setBasePen(axisPen); ui->customPlot->xAxis->setTickPen(axisPen); ui->customPlot->xAxis->setSubTickPen(axisPen); ui->customPlot->yAxis->setLabelColor(axisColor); ui->customPlot->yAxis->setTickLabelColor(axisColor); ui->customPlot->yAxis->setBasePen(axisPen); ui->customPlot->yAxis->setTickPen(axisPen); ui->customPlot->yAxis->setSubTickPen(axisPen); QComboBox* axisX = ui->comboAxisX; QComboBox* axisY = ui->comboAxisY; //Save the current selection to be restored later axisX->blockSignals(true); axisY->blockSignals(true); int indexX = axisX->currentIndex(); int indexY = axisY->currentIndex(); QVariant selectedAxisX = axisX->itemData(indexX); QVariant selectedAxisY = axisY->itemData(indexY); axisX->clear(); axisY->clear(); QList<axisPair> axis; axis.append(qMakePair(q_("Orbital Eccentricity"), 0)); axis.append(qMakePair(q_("Orbit Semi-Major Axis, AU"), 1)); axis.append(qMakePair(q_("Planetary Mass, Mjup"), 2)); axis.append(qMakePair(q_("Planetary Radius, Rjup"), 3)); axis.append(qMakePair(q_("Orbital Period, days"), 4)); axis.append(qMakePair(q_("Angular Distance, arcsec"), 5)); axis.append(qMakePair(q_("Effective temperature of host star, K"), 6)); axis.append(qMakePair(q_("Year of Discovery"), 7)); axis.append(qMakePair(q_("Metallicity of host star"), 8)); axis.append(qMakePair(q_("V magnitude of host star, mag"), 9)); axis.append(qMakePair(q_("RA (J2000) of star, deg"), 10)); axis.append(qMakePair(q_("Dec (J2000) of star, deg"), 11)); axis.append(qMakePair(q_("Distance to star, pc"), 12)); axis.append(qMakePair(q_("Mass of host star, Msol"), 13)); axis.append(qMakePair(q_("Radius of host star, Rsol"), 14)); for(int i=0; i<axis.size(); ++i) { axisX->addItem(axis.at(i).first, axis.at(i).second); axisY->addItem(axis.at(i).first, axis.at(i).second); } //Restore the selection indexX = axisX->findData(selectedAxisX, Qt::UserRole, Qt::MatchCaseSensitive); if (indexX<0) indexX = 1; indexY = axisY->findData(selectedAxisY, Qt::UserRole, Qt::MatchCaseSensitive); if (indexY<0) indexY = 0; axisX->setCurrentIndex(indexX); axisY->setCurrentIndex(indexY); axisX->blockSignals(false); axisY->blockSignals(false); }