예제 #1
0
void
KnobGuiBool::onLabelChanged()
{
    const std::string& label = _knob.lock()->getLabel();

    if ( (label == "R") || (label == "r") || (label == "red") ) {
        QColor color;
        color.setRgbF(0.851643, 0.196936, 0.196936);
        _checkBox->setCustomColor(color, true);
    } else if ( (label == "G") || (label == "g") || (label == "green") ) {
        QColor color;
        color.setRgbF(0, 0.654707, 0);
        _checkBox->setCustomColor(color, true);
    } else if ( (label == "B") || (label == "b") || (label == "blue") ) {
        QColor color;
        color.setRgbF(0.345293, 0.345293, 1);
        _checkBox->setCustomColor(color, true);
    } else if ( (label == "A") || (label == "a") || (label == "alpha") ) {
        QColor color;
        color.setRgbF(0.398979, 0.398979, 0.398979);
        _checkBox->setCustomColor(color, true);
    } else {
        _checkBox->setCustomColor(Qt::black, false);
    }
}
예제 #2
0
파일: Viewer.cpp 프로젝트: Huanglihan/cgal
void
Viewer::draw()
{
    if(!are_buffers_initialized)
        initialize_buffers();
    QColor color;
    //points
    vao[1].bind();
    attrib_buffers(this);
    rendering_program_points.bind();
    color.setRgbF(1.0f, 0.0f, 0.0f);
    glPointSize(5);
    ::glEnable(GL_POINT_SMOOTH);
    rendering_program_points.setUniformValue(colorLocation_points, color);
    glDrawArrays(GL_POINTS, 0, static_cast<GLsizei>(pos_points.size()/3));
    rendering_program_points.release();
    vao[1].release();
    //facets
    vao[0].bind();
    attrib_buffers(this);
    rendering_program.bind();
    color.setRgbF(0.5f, 1.0f, 0.5f);
    rendering_program.setUniformValue(colorLocation, color);
    glDrawArrays(GL_TRIANGLES, 0, static_cast<GLsizei>(pos_poly.size()/3));
    rendering_program.release();
    vao[0].release();

}
예제 #3
0
  QWidget* OrbitalEngine::settingsWidget()
  {
    if(!m_settingsWidget)
    {
      m_settingsWidget = new OrbitalSettingsWidget();
      connect(m_settingsWidget->orbital1Combo, SIGNAL(currentIndexChanged(int)),
              this, SLOT(setOrbital1(int)));
      connect(m_settingsWidget->opacitySlider, SIGNAL(valueChanged(int)),
              this, SLOT(setOpacity(int)));
      connect(m_settingsWidget->renderCombo, SIGNAL(currentIndexChanged(int)),
              this, SLOT(setRenderMode(int)));
      connect(m_settingsWidget->drawBoxCheck, SIGNAL(stateChanged(int)),
              this, SLOT(setDrawBox(int)));
      connect(m_settingsWidget->posColor, SIGNAL(colorChanged(QColor)),
              this, SLOT(setPosColor(QColor)));
      connect(m_settingsWidget->negColor, SIGNAL(colorChanged(QColor)),
              this, SLOT(setNegColor(QColor)));
      connect(m_settingsWidget, SIGNAL(destroyed()),
              this, SLOT(settingsWidgetDestroyed()));

      // Initialise the widget from saved settings
      m_settingsWidget->opacitySlider->setValue(static_cast<int>(m_alpha * 20));
      m_settingsWidget->renderCombo->setCurrentIndex(m_renderMode);
      m_settingsWidget->drawBoxCheck->setChecked(m_drawBox);

      // Initialise the colour buttons
      QColor initial;
      initial.setRgbF(m_posColor.red(), m_posColor.green(), m_posColor.blue());
      m_settingsWidget->posColor->setColor(initial);
      initial.setRgbF(m_negColor.red(), m_negColor.green(), m_negColor.blue());
      m_settingsWidget->negColor->setColor(initial);
      updateOrbitalCombo();
    }
예제 #4
0
파일: info.cpp 프로젝트: Abbath/lbsim
QColor Info::color(double value) {
    double colorAverage = 0;
    double colorDelta = 0.023;
    double lowerLimit = colorAverage - colorDelta;
    double firstLimit = colorAverage - colorDelta / 2;
    double secondLimit = colorAverage;
    double thirdLimit = colorAverage + colorDelta / 2;
    double upperLimit = colorAverage + colorDelta;
    double firstInterval = colorDelta / 2;
    double secondInterval = colorDelta / 2;
    double thirdInterval = colorDelta / 2;
    double fourthInterval = colorDelta / 2;
    QColor result;
    if (value <= lowerLimit || value >= upperLimit) {
        result.setRgbF(1, 1, 1);
    } else if (value < firstLimit) {
        result.setRgbF(0, (value - lowerLimit) / firstInterval, 1 - (value - lowerLimit) / firstInterval);
    } else if (value < secondLimit) {
        result.setRgbF((value - firstLimit) / secondInterval, 1, 0);
    } else if (value < thirdLimit) {
        result.setRgbF(1, 1 - 0.5 * (value - secondLimit) / thirdInterval, 0);
    } else {
        result.setRgbF(1, 0.5 - 0.5 * (value - thirdLimit) / fourthInterval, 0);
    }
    return result;
}
예제 #5
0
파일: Viewer.cpp 프로젝트: CGAL/releases
void
Viewer::draw()
{
    glEnable(GL_DEPTH_TEST);
  if(!are_buffers_initialized)
      initialize_buffers();
  QColor color;
 //the points
  glEnable(GL_BLEND);
  glEnable(GL_POINT_SMOOTH);
  glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
  glEnable(GL_LINE_SMOOTH);
  glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  glEnable(GL_POLYGON_OFFSET_FILL);
  glPolygonOffset(3.0f,-3.0f);


  attrib_buffers(this);
  vao[0].bind();
  color.setRgbF(1.0f, 0.72f, 0.06f);
  rendering_program.bind();
  rendering_program.setUniformValue(colorLocation[0], color);
  glDrawArrays(GL_POINTS, 0, static_cast<GLsizei>(pos_points.size()/3));
  rendering_program.release();
  vao[0].release();

  //The Lines
  glDisable(GL_POLYGON_OFFSET_FILL);

  vao[1].bind();
  color.setRgbF(0.27f, 0.51f, 0.7f);
  rendering_program.bind();
  rendering_program.setUniformValue(colorLocation[0], color);
  glDrawArrays(GL_LINES, 0, static_cast<GLsizei>(pos_lines.size()/3));
  rendering_program.release();
  vao[1].release();

  if (scene->eight_copies) {
      vao[2].bind();
      color.setRgbF(0.69f, 0.77f, 0.87f);
      rendering_program.bind();
      rendering_program.setUniformValue(colorLocation[0], color);
      glDrawArrays(GL_LINES, 0, static_cast<GLsizei>(pos_8lines2D.size()/3));
      rendering_program.release();
      vao[2].release();


      if (!scene->two_dimensional) {
          vao[3].bind();
          color.setRgbF(0.69f, 0.77f, 0.87f);
          rendering_program.bind();
          rendering_program.setUniformValue(colorLocation[0], color);
          glDrawArrays(GL_LINES, 0, static_cast<GLsizei>(pos_8lines.size()/3));
          rendering_program.release();
          vao[3].release();
      }
  }
}
예제 #6
0
void SoFrameLabel::drawImage()
{
    const SbString* s = string.getValues(0);
    int num = string.getNum();
    if (num == 0) {
        this->image = SoSFImage();
        return;
    }

    QFont font(QString::fromAscii(name.getValue()), size.getValue());
    QFontMetrics fm(font);
    int w = 0;
    int h = fm.height() * num;
    const SbColor& b = backgroundColor.getValue();
    QColor brush;
    brush.setRgbF(b[0],b[1],b[2]);
    const SbColor& t = textColor.getValue();
    QColor front;
    front.setRgbF(t[0],t[1],t[2]);

    QStringList lines;
    for (int i=0; i<num; i++) {
        QString line = QString::fromUtf8(s[i].getString());
        w = std::max<int>(w, fm.width(line));
        lines << line;
    }

    QImage image(w+10,h+10,QImage::Format_ARGB32_Premultiplied);
    image.fill(0x00000000);
    QPainter painter(&image);
    painter.setRenderHint(QPainter::Antialiasing);

    SbBool drawFrame = frame.getValue();
    if (drawFrame) {
        painter.setPen(QPen(QColor(0,0,127), 2, Qt::SolidLine, Qt::RoundCap,
                            Qt::RoundJoin));
        painter.setBrush(QBrush(brush, Qt::SolidPattern));
        QRectF rectangle(0.0, 0.0, w+10, h+10);
        painter.drawRoundedRect(rectangle, 5, 5);
    }

    painter.setPen(front);

    Qt::Alignment align = Qt::AlignVCenter;
    if (justification.getValue() == 0)
        align = Qt::AlignVCenter | Qt::AlignLeft;
    else if (justification.getValue() == 1)
        align = Qt::AlignVCenter | Qt::AlignRight;
    else
        align = Qt::AlignVCenter | Qt::AlignHCenter;
    QString text = lines.join(QLatin1String("\n"));
    painter.setFont(font);
    painter.drawText(5,5,w,h,align,text);
    painter.end();

    SoSFImage sfimage;
    Gui::BitmapFactory().convert(image, sfimage);
    this->image = sfimage;
}
예제 #7
0
파일: Viewer.cpp 프로젝트: lrineau/cgal
void Viewer::draw()
{
  if(scene)
  {
    glEnable(GL_DEPTH_TEST);
    if(!are_buffers_initialized)
      initialize_buffers();

    QColor color;
    if ( !wireframe )
    {
      if(flatShading)
      {
        vao[0].bind();
        attrib_buffers(this);
        rendering_program.bind();
        glDrawArrays(GL_TRIANGLES, 0, static_cast<GLsizei>(pos_facets.size()/3));
        rendering_program.release();
        vao[0].release();
      }
      else
      {
        vao[1].bind();
        attrib_buffers(this);
        rendering_program.bind();
        glDrawArrays(GL_TRIANGLES, 0, static_cast<GLsizei>(pos_facets.size()/3));
        rendering_program.release();
        vao[1].release();
      }
    }
    if(edges)
    {
      vao[2].bind();
      attrib_buffers(this);
      color.setRgbF(0.2f, 0.2f, 0.7f);
      rendering_program_p_l.bind();
      rendering_program_p_l.setAttributeValue(colorLocation,color);
      glLineWidth(size_edges);
      glDrawArrays(GL_LINES, 0, static_cast<GLsizei>(pos_lines.size()/3));
      rendering_program_p_l.release();
      vao[2].release();
    }
    if(vertices)
    {
      vao[3].bind();
      attrib_buffers(this);
      color.setRgbF(.2f,.2f,.6f);
      rendering_program_p_l.bind();
      rendering_program_p_l.setAttributeValue(colorLocation,color);
      rendering_program_p_l.setUniformValue("point_size", GLfloat(size_points));
      glDrawArrays(GL_POINTS, 0, static_cast<GLsizei>(pos_points.size()/3));
      rendering_program_p_l.release();
      vao[3].release();
    }
  }
}
예제 #8
0
QRgb RGBColor::getQRgb() const
{
    QColor color;
    double maxValue = 1.0/max(r, max(g, b));
    
    if (maxValue < 1.0)
        color.setRgbF ( r*maxValue, g*maxValue, b*maxValue, 1.0 );
    else
        color.setRgbF ( r, g, b, 1.0 );

    return color.rgba();
}
예제 #9
0
void Viewer::draw()
{
if(!are_buffers_initialized)
    initialize_buffers();


QColor color;
    if ( !wireframe )
    {
      if(flatShading)
      {

          vao[0].bind();
          attrib_buffers(this);
          rendering_program.bind();
          glDrawArrays(GL_TRIANGLES, 0, static_cast<GLsizei>(pos_facets.size()/3));
          rendering_program.release();
          vao[0].release();
      }
      else
      {
          vao[1].bind();
          attrib_buffers(this);
          rendering_program.bind();
          glDrawArrays(GL_TRIANGLES, 0, static_cast<GLsizei>(pos_facets.size()/3));
          rendering_program.release();
          vao[1].release();
      }
    }
    if(edges)
    {
        vao[2].bind();
        attrib_buffers(this);
        color.setRgbF(0.2f, 0.2f, 0.7f);
        rendering_program_p_l.bind();
        rendering_program_p_l.setAttributeValue(colorLocation,color);
        glDrawArrays(GL_LINES, 0, static_cast<GLsizei>(pos_lines.size()/3));
        rendering_program_p_l.release();
        vao[2].release();
    }
    if(vertices)
    {
        ::glPointSize(7.f);
        vao[3].bind();
        attrib_buffers(this);
        color.setRgbF(.2f,.2f,.6f);
        rendering_program_p_l.bind();
        rendering_program_p_l.setAttributeValue(colorLocation,color);
        glDrawArrays(GL_POINTS, 0, static_cast<GLsizei>(pos_points.size()/3));
        rendering_program_p_l.release();
        vao[3].release();
    }
}
예제 #10
0
QColor Surface::color(Sign sign) const
{ 
   QColor color;
   switch (sign) {
      case Positive:
         color.setRgbF(m_colorPositive[0], m_colorPositive[1], m_colorPositive[2]); 
         break;
      case Negative:
         color.setRgbF(m_colorNegative[0], m_colorNegative[1], m_colorNegative[2]); 
         break;
   }
   return color;
}
예제 #11
0
void EC_HoveringText::AttributesChanged()
{
    if (font.ValueChanged() || fontSize.ValueChanged())
    {
        SetFont(QFont(font.Get(), fontSize.Get()));
    }
    if (fontColor.ValueChanged())
    {
        Color col = fontColor.Get();
        textColor_.setRgbF(col.r, col.g, col.b, col.a);
    }
    if (position.ValueChanged())
    {
        SetPosition(position.Get());
    }
    if (gradStart.ValueChanged() || gradEnd.ValueChanged())
    {
        QColor colStart;
        QColor colEnd;
        Color col = gradStart.Get();
        colStart.setRgbF(col.r, col.g, col.b);
        col = gradEnd.Get();
        colEnd.setRgbF(col.r, col.g, col.b);
        SetBackgroundGradient(colStart, colEnd);
    }
    if (overlayAlpha.ValueChanged())
        SetOverlayAlpha(overlayAlpha.Get());
    if (width.ValueChanged() || height.ValueChanged())
        SetBillboardSize(width.Get(), height.Get());

    if (material.ValueChanged())
    {
        // Don't render the HoveringText if it's not using a material.
        if (billboardSet_)
        {
            bool isVisible = !material.Get().ref.isEmpty();
            billboardSet_->setVisible(isVisible);
        }

        // If the material was cleared, erase the material from Ogre billboard as well. (we might be deleting the material in Tundra Asset API)
        if (material.Get().ref.isEmpty() && billboardSet_)
#if OGRE_VERSION_MAJOR <= 1 && OGRE_VERSION_MINOR <= 7 && OGRE_VERSION_PATCH <= 2
            billboardSet_->setMaterialName("BaseWhite"); // BaseWhite is an Ogre-internal default material which always exists.
#else // Ogre::BillboardSet::setMaterial() only available at Ogre 1.7.3 and newer.
            billboardSet_->setMaterial(Ogre::MaterialPtr());
#endif
        else
            materialAsset.HandleAssetRefChange(&material);
    }
예제 #12
0
QGradient* Gradient::platformGradient()
{
    if (m_gradient)
        return m_gradient;

    if (m_radial)
        m_gradient = new QRadialGradient(m_p1.x(), m_p1.y(), m_r1, m_p0.x(), m_p0.y());
    else
        m_gradient = new QLinearGradient(m_p0.x(), m_p0.y(), m_p1.x(), m_p1.y());

    QColor stopColor;
    Vector<ColorStop>::iterator stopIterator = m_stops.begin();;
    qreal lastStop;
    const qreal lastStopDiff = 0.0000001;
    while (stopIterator != m_stops.end()) {
        stopColor.setRgbF(stopIterator->red, stopIterator->green, stopIterator->blue, stopIterator->alpha);
        if (qFuzzyCompare(lastStop, qreal(stopIterator->stop)))
            lastStop = stopIterator->stop + lastStopDiff;
        else
            lastStop = stopIterator->stop;
        if (m_radial && m_r0)
            lastStop = m_r0 / m_r1 + lastStop * (1.0f - m_r0 / m_r1);
        m_gradient->setColorAt(lastStop, stopColor);
        ++stopIterator;
    }

    return m_gradient;
}
예제 #13
0
QColor Viewport::determineColor(const QColor &basecolor,
                                float weight, float totalweight,
                                bool highlighted, bool single)
{
	QColor color = basecolor;
	qreal alpha;
	/* TODO: this is far from optimal yet. challenge is to give a good
	   view where important information is not lost, yet not clutter
	   the view with too much low-weight information */
	/* logarithm is used to prevent single data points to get lost.
	   this should be configurable. */
	alpha = useralpha;
	if (drawLog->isChecked())
		alpha *= (0.01 + 0.99*(std::log(weight+1) / std::log(totalweight)));
	else
		alpha *= (0.01 + 0.99*(weight / totalweight));
	color.setAlphaF(std::min(alpha, 1.)); // cap at 1

	if (highlighted) {
		if (basecolor == Qt::white) {
			color = Qt::yellow;
		} else {
			color.setGreen(std::min(color.green() + 195, 255));
			color.setRed(std::min(color.red() + 195, 255));
			color.setBlue(color.blue()/2);
		}
		color.setAlphaF(1.);
	}

	// recolor singleLabel (and make 100% opaque)
	if (single) {
		color.setRgbF(1., 1., 0., 1.);
	}
	return color;
}
예제 #14
0
void QtFontRenderer::renderText(const double x, const double y, const double angle, const QString &string, OGLWidget *widget) {
    // rotated text not supported directly;
    if (angle != 0) {
        bool afb = widget->autoFillBackground();
        bool abs = widget->autoBufferSwap();
        widget->setAutoBufferSwap(false);
        widget->setAutoFillBackground(false);

        GLfloat colors[4];
        glGetFloatv(GL_CURRENT_COLOR, colors);

        mPainter.begin(widget);
        if (mPainter.isActive()) {
            QColor color;
            color.setRgbF(colors[0], colors[1], colors[2], colors[3]);
            mPainter.setPen(color);
            mPainter.setFont(mFont);
            mPainter.translate(x,y);
            mPainter.rotate(angle);
            mPainter.drawText(0, 0, string);
            mPainter.end();
        }

        widget->setAutoBufferSwap(abs);
        widget->setAutoFillBackground(afb);
    } else {
        widget->renderText(x, y, 0.0, string, mFont);
    }
}
예제 #15
0
파일: ShaderLibrary.C 프로젝트: Tyf0n/IQmol
/* This only parses uniform variables between the following lines:

// BEGIN UNIFORM
uniform float x;    // default
uniform vec4 color; // red green blue alpha
// END UNIFORM

uniform can be replaced by 'in' and if no default is given the floats default
to 0.0 and the color to white.  Comments between the BEGIN and END lines are
ignored.
*/
QVariantMap ShaderLibrary::parseUniformVariables(QString const& vertexShaderPath)
{
   QVariantMap map;

   QFile file(vertexShaderPath);
   if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
      Parser2::TextStream textStream(&file);

      int n;
      bool tf;
      double value;
      QString line;
      QString name;
      QColor  color;
      QStringList tokens;
      textStream.seek("BEGIN UNIFORM");

      while (!textStream.atEnd()) {
         line = textStream.nextLine();      
         if (line.contains("END UNIFORM")) break;

         if (!line.startsWith("//")) {
            line = line.replace(";"," ");
            line = line.replace(","," ");
            line = line.replace("//"," ");

            tokens = Parser2::TextStream::tokenize(line);
            n = tokens.size();

            if (n >= 3 && (tokens[0] == "uniform" || tokens[0] == "in"))  {
               name = tokens[2];

               if (tokens[1] == "float") {
                  value = (n >= 4) ? tokens[3].toDouble() : 0.0;
                  map.insert(name, value);
               }else if (tokens[1] == "bool") {
                  tf = (n >= 4) ? tokens[3].toInt() : false;
                  map.insert(name, tf);
               }else if (tokens[1] == "vec4") {
                  color = Qt::white;
                  if (n >= 7) {
                     color.setRgbF(tokens[3].toDouble(), tokens[4].toDouble(), 
                        tokens[5].toDouble(), tokens[6].toDouble());
                  }
                  map.insert(name, color);
               }else {
                  qDebug() << "Unknown uniform variable in shader" << tokens[1];
               }
            }
         }
      }

      file.close();
   }   
   qDebug() << "Parsed the following uniform variables:";
   for (QVariantMap::iterator iter = map.begin(); iter != map.end(); ++iter) {
        qDebug() << iter.key() << iter.value();
   }
   return map;
}
예제 #16
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RimSimWellInViewCollection::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute)
{
    if (&m_applyIndividualColorsToWells == field)
    {
        caf::PdmUiPushButtonEditorAttribute* editorAttr = dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>(attribute);
        if (editorAttr)
        {
            editorAttr->m_buttonText = "Apply";
        }
    }

    if (&m_applySingleColorToWells == field)
    {
        caf::PdmUiPushButtonEditorAttribute* editorAttr = dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>(attribute);
        if (editorAttr)
        {
            QColor col;
            col.setRgbF(m_wellColorForApply().r(), m_wellColorForApply().g(), m_wellColorForApply().b());

            QPixmap pixmap(20, 20);
            pixmap.fill(col);

            QIcon colorIcon(pixmap);

            editorAttr->m_buttonIcon = colorIcon;
            editorAttr->m_buttonText = "Apply";
        }
    }
}
예제 #17
0
ModelViewGadgetWidget::ModelViewGadgetWidget(QWidget *parent)
    : QGLWidget(new GLC_Context(QGLFormat(QGL::SampleBuffers)), parent)
    , m_Light()
    , m_World()
    , m_GlView(this)
    , m_MoverController()
    , m_ModelBoundingBox()
    , m_MotionTimer()
    , acFilename()
    , bgFilename()
    , vboEnable(false)
{
    setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
    CreateScene();

    QColor repColor;
    repColor.setRgbF(1.0, 0.11372, 0.11372, 0.0);
    m_MoverController = GLC_Factory::instance()->createDefaultMoverController(repColor, &m_GlView);

    // Get required UAVObjects
    ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
    UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
    attActual = AttitudeActual::GetInstance(objManager);

    connect(&m_MotionTimer, SIGNAL(timeout()), this, SLOT(updateAttitude()));
}
예제 #18
0
QColor ColorRangeBase::toColor(const QVariant &v, ColorRangeBase::ColorModel colormodel)
{
    if ( v.type() == QVariant::Color)
        return QColor(v.value<QColor>());
    else if ( v.type() == QVariant::String){
        QRegExp separ("[(]|,|[)]");
        QStringList parts = (v.toString()).split(separ);
        if(parts.last().isEmpty())
            parts.removeLast();
        QColor clr;
        bool ok1,ok2,ok3,ok4,ok5 =true;
        if ( parts.size() >= 5){
            double component1 = parts[1].toDouble(&ok1);
            double component2 = parts[2].toDouble(&ok2);
            double component3 = parts[3].toDouble(&ok3);
            double component4 = parts[4].toDouble(&ok4);
            double component5 =  parts.size()== 6 ? parts[5].toDouble(&ok5) : rUNDEF;
            if(! (ok1 && ok2 && ok3 && ok4 && ok5))
                return QColor();

            bool isFractional =  component1 <= 1 && component2 <= 1 && component3 <= 1 && component4 <= 1;
            if ( parts[0].toLower() == "rgba"){
                if ( isFractional){
                   clr.setRgbF(component1,component2, component3);
                   clr.setAlphaF(component4);
                }
                else{
                    clr.setRgb(component1,component2, component3);
                    clr.setAlpha(component4);
                }
            }else if ( parts[0].toLower() == "hsla"){
                if ( isFractional){
                   clr.setHslF(component1,component2, component3);
                   clr.setAlphaF(component4);
                }
                else{
                    clr.setHsl(component1,component2, component3);
                    clr.setAlpha(component4);
                }

            } else if ( parts[0].toLower() == "cmyka" && parts.size() == 6){
                if ( isFractional){
                   clr.setCmykF(component1,component2, component3, component4);
                   clr.setAlphaF(component5);
                }
                else{
                    clr.setCmyk(component1,component2, component3, component4);
                    clr.setAlpha(component5);
                }
            }
            return clr;
        }
    } else if( v.type() == QVariant::ULongLong){
        return ColorRangeBase::toColor(v.toULongLong(),colormodel);
    } else if( v.type() == QVariant::Double){
        return ColorRangeBase::toColor(v.toULongLong(),colormodel);
    }

    return QColor();
}
예제 #19
0
ModelViewGadgetWidget::ModelViewGadgetWidget(QWidget *parent)
    : QGLWidget(new GLC_Context(QGLFormat(QGL::SampleBuffers)), parent)
    , m_Light()
    , m_World()
    , m_GlView()
    , m_MoverController()
    , m_ModelBoundingBox()
    , m_MotionTimer()
    , acFilename()
    , bgFilename()
    , vboEnable(false)
{
    connect(&m_GlView, SIGNAL(updateOpenGL()), this, SLOT(updateGL()));
    setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);

    m_Light.setPosition(4000.0, 40000.0, 80000.0);
    // m_GlView.setBackgroundColor(Qt::white);
    m_Light.setAmbientColor(Qt::lightGray);

    m_GlView.cameraHandle()->setDefaultUpVector(glc::Z_AXIS);
    m_GlView.cameraHandle()->setRearView();

    QColor repColor;
    repColor.setRgbF(1.0, 0.11372, 0.11372, 0.0);
    m_MoverController = GLC_Factory::instance()->createDefaultMoverController(repColor, &m_GlView);

    CreateScene();
    // Get required UAVObjects
    ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
    UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
    attState = AttitudeActual::GetInstance(objManager);

    connect(&m_MotionTimer, SIGNAL(timeout()), this, SLOT(updateAttitude()));
}
void
Scene_implicit_function_item::draw(Viewer* viewer) const
{
  if(!texture_initialized)
  {
    viewer->glGenTextures(1, &textureId);
    texture_initialized = true;
  }
  if(!are_buffers_initialized)
    initialize_buffers(viewer);
  QColor color;
  vao[0].bind();
  attrib_buffers(viewer);
  rendering_program.bind();
  color.setRgbF(0.0,0.0,0.0);
  rendering_program.setUniformValue(colorLocation[0], color);
  glDrawArrays(GL_LINES, 0, static_cast<GLsizei>(v_cube.size()/3));
  rendering_program.release();
  vao[0].release();

  viewer->glActiveTexture(GL_TEXTURE0);
  viewer->glBindTexture(GL_TEXTURE_2D, textureId);

  vao[1].bind();
  tex_rendering_program.bind();
  glDrawArrays(GL_TRIANGLES, 0, static_cast<GLsizei>(v_plan.size()/3));
  tex_rendering_program.release();
  vao[1].release();

}
예제 #21
0
bool ColourControl::buttonClicked(unsigned int index)
{
	float red = m_pairedValue->r;
	float green = m_pairedValue->g;
	float blue = m_pairedValue->b;

	QColor colour;
	colour.setRgbF(red, green, blue);

	colour = QColorDialog::getColor(colour);

	// if colour is invalid, the user cancelled the colour dialog
	if (!colour.isValid())
		return false;

	m_pickButton->setColour(colour);
	m_pickButton->update();

	red = colour.redF();
	green = colour.greenF();
	blue = colour.blueF();

	*m_pairedValue = Colour3f(red, green, blue);

	return true;
}
예제 #22
0
// Return QIcon for the given element
QIcon ElementMap::icon(int z)
{
	if ((z < 0) || (z > nElements_))
	{
		Messenger::error("ElementMap::colourHasChanged() : Atomic number %i is out of range.\n", z);
		return QIcon();
	}

	QPixmap pixmap(32,32);

	QPainter painter(&pixmap);

	// Grab colour and set brush
	QColor colour;
	colour.setRgbF(elements_[z].colour[0], elements_[z].colour[1], elements_[z].colour[2]);
	painter.setBrush(colour);

	// Set up pen
	QPen pen;
	pen.setWidth(2);
	pen.setColor(Qt::black);

	// Set up font
	QFont font;
	font.setPointSize(10);
	
	// Draw rectangle and text
	painter.drawRect(0, 0, 30, 30);
	painter.setFont(font);
	painter.drawText(0, 0, 31, 31, Qt::AlignCenter, elements_[z].symbol);

	painter.end();

	return QIcon(pixmap);
}
예제 #23
0
void GLEDrawingObject::setColorProperty() {
	QColor col;
	GLEDrawObject* obj = getGLEObject();
	GLEColor* color = obj->getProperties()->getColorProperty(GLEDOPropertyColor);
	col.setRgbF(color->getRed(), color->getGreen(), color->getBlue());
	setPropertyNoUpdate(LineColour, col);
}
예제 #24
0
GLWidget::GLWidget(QWidget *p_parent)
    : QGLWidget(new GLC_Context(QGLFormat(QGL::SampleBuffers)), p_parent)
    , m_Light()
    , m_World()
    , m_GlView()
    , m_MoverController()
    , m_ShuttleBoundingBox()
    , m_MotionTimer()
{
    connect(&m_GlView, SIGNAL(updateOpenGL()), this, SLOT(updateGL()));

    m_Light.setPosition(4000.0, 40000.0, 80000.0);
    //m_GlView.setBackgroundColor(Qt::white);
    m_Light.setAmbientColor(Qt::lightGray);

    m_GlView.cameraHandle()->setDefaultUpVector(glc::Z_AXIS);
    m_GlView.cameraHandle()->setIsoView();

    QColor repColor;
    repColor.setRgbF(1.0, 0.11372, 0.11372, 1.0);
    m_MoverController= GLC_Factory::instance()->createDefaultMoverController(repColor, &m_GlView);

    createScene();
    // Signal and slot connection
    connect(&m_MotionTimer, SIGNAL(timeout()), this, SLOT(rotateView()));

    qDebug() << glc::X_AXIS.signedAngleWithVect(-glc::Y_AXIS, glc::Z_AXIS);
    qDebug() << fmod(glc::X_AXIS.signedAngleWithVect(-glc::Y_AXIS, glc::Z_AXIS), 2.0 * glc::PI);
}
예제 #25
0
void GLEDrawingObject::setSimplePenProperties(QPen& pen) {
	QColor col;
	GLEDrawObject* obj = getGLEObject();
	GLEColor* color = obj->getProperties()->getColorProperty(GLEDOPropertyColor);
	col.setRgbF(color->getRed(), color->getGreen(), color->getBlue());
	pen.setColor(col);
	double lwidth = obj->getProperties()->getRealProperty(GLEDOPropertyLineWidth);
	pen.setWidthF(QGLE::relGLEToQt(lwidth, dpi));
	GLEString* lstyle = obj->getProperties()->getStringProperty(GLEDOPropertyLineStyle);
	if (lstyle->length() == 1 && lstyle->get(0) > (unsigned int)'1') {
		QVector<qreal> dashes;
		const char *defline[] = {"","","12","41","14","92","1282","9229","4114","54","73","7337","6261","2514"};
		const char *myline = defline[lstyle->get(0)-'0'];
		int len = strlen(myline);
		for (int i = 0; i < len; i++) {
			double value = (myline[i]-'0');
			dashes.append((qreal)QGLE::relGLEToQt(value*0.04, dpi));
		}
		pen.setDashPattern(dashes);
	} else if (lstyle->length() > 1) {
		QVector<qreal> dashes;
		for (unsigned int i = 0; i < lstyle->length(); i++) {
			double value = (lstyle->get(i)-'0');
			dashes.append((qreal)QGLE::relGLEToQt(value*0.04, dpi));
		}
		pen.setDashPattern(dashes);
	}
}
예제 #26
0
//----------------------------------------------------------------------------
QColor ctkVTKSliceView::highlightedBoxColor()const
{
  Q_D(const ctkVTKSliceView);
  double* color = d->LightBoxRendererManager->GetHighlightedBoxColor();
  QColor c;
  c.setRgbF(color[0], color[1], color[2]);
  return c;
}
예제 #27
0
//----------------------------------------------------------------------------
QColor ctkVTKSliceView::backgroundColor()const
{
  Q_D(const ctkVTKSliceView);
  double* color = d->LightBoxRendererManager->GetBackgroundColor();
  QColor c;
  c.setRgbF(color[0], color[1], color[2]);
  return c;
}
예제 #28
0
// Get colour as QColor
QColor ColourScale::colourAsQColor(double value)
{
	static GLfloat col[4];
	colour(value, col);
	QColor qcol;
	qcol.setRgbF(col[0], col[1], col[2], col[3]);
	return qcol;
}
예제 #29
0
void
KnobGuiButton::reflectMultipleSelection(bool dirty)
{
    QColor c;
    c.setRgbF(0.2, 0.2, 0.2);
    c.setAlphaF(0.2);
    loadPixmaps(dirty, c);
}
예제 #30
0
파일: AtomLayer.C 프로젝트: nutjunkie/IQmol
void Atom::povray(PovRayGen& povray)
{
   QColor color;
   color.setRgbF(m_color[0], m_color[1], m_color[2], m_color[3]);
   double radius(getRadius());
   if (m_drawMode == Primitive::WireFrame) radius = 0.02;
   povray.writeAtom(getPosition(), color, radius);
}