Esempio n. 1
0
WColor WStandardColorMap::interpolate(const WColor& color1,
				      const WColor& color2,
				      double factor) const
{
  return WColor((int)((1-factor)*color1.red() + factor*color2.red()),
		(int)((1-factor)*color1.green() + factor*color2.green()),
		(int)((1-factor)*color1.blue() + factor*color2.blue()));
}
Esempio n. 2
0
void WScatterData::dataFromModel(FloatBuffer& simplePtsArray,
				 FloatBuffer& simplePtsSize,
				 FloatBuffer& coloredPtsArray,
				 FloatBuffer& coloredPtsSize,
				 FloatBuffer& coloredPtsColor)
{
  int N = model_->rowCount();

  double xMin = chart_->axis(XAxis_3D).minimum();
  double xMax = chart_->axis(XAxis_3D).maximum();
  double yMin = chart_->axis(YAxis_3D).minimum();
  double yMax = chart_->axis(YAxis_3D).maximum();
  double zMin = chart_->axis(ZAxis_3D).minimum();
  double zMax = chart_->axis(ZAxis_3D).maximum();
  
  for (int i=0; i < N; i++) {
    if (colorColumn_ == -1 && model_->data(i,ZSeriesColumn_, MarkerBrushColorRole).empty()) {
      simplePtsArray.push_back((float)((Wt::asNumber(model_->data(i,XSeriesColumn_)) - xMin)/(xMax - xMin)));
      simplePtsArray.push_back((float)((Wt::asNumber(model_->data(i,YSeriesColumn_)) - yMin)/(yMax - yMin)));
      simplePtsArray.push_back((float)((Wt::asNumber(model_->data(i,ZSeriesColumn_)) - zMin)/(zMax - zMin)));
    } else if (colorColumn_ == -1) {
      coloredPtsArray.push_back((float)((Wt::asNumber(model_->data(i,XSeriesColumn_)) - xMin)/(xMax - xMin)));
      coloredPtsArray.push_back((float)((Wt::asNumber(model_->data(i,YSeriesColumn_)) - yMin)/(yMax - yMin)));
      coloredPtsArray.push_back((float)((Wt::asNumber(model_->data(i,ZSeriesColumn_)) - zMin)/(zMax - zMin)));
      WColor color = boost::any_cast<WColor>(model_->data(i,ZSeriesColumn_,MarkerBrushColorRole));
      coloredPtsColor.push_back((float)color.red());
      coloredPtsColor.push_back((float)color.green());
      coloredPtsColor.push_back((float)color.blue());
      coloredPtsColor.push_back((float)color.alpha());
    } else {
      coloredPtsArray.push_back((float)((Wt::asNumber(model_->data(i,XSeriesColumn_)) - xMin)/(xMax - xMin)));
      coloredPtsArray.push_back((float)((Wt::asNumber(model_->data(i,YSeriesColumn_)) - yMin)/(yMax - yMin)));
      coloredPtsArray.push_back((float)((Wt::asNumber(model_->data(i,ZSeriesColumn_)) - zMin)/(zMax - zMin)));
      WColor color = boost::any_cast<WColor>(model_->data(i,colorColumn_,asColorRole_));
      coloredPtsColor.push_back((float)color.red());
      coloredPtsColor.push_back((float)color.green());
      coloredPtsColor.push_back((float)color.blue());
      coloredPtsColor.push_back((float)color.alpha());
    }

    FloatBuffer& sizeArrayAlias = (colorColumn_ == -1 && model_->data(i,ZSeriesColumn_, MarkerBrushColorRole).empty()) ? simplePtsSize : coloredPtsSize;
    if (sizeColumn_ == -1 && model_->data(i,ZSeriesColumn_,MarkerScaleFactorRole).empty()) {
      sizeArrayAlias.push_back((float)pointSize_);
    } else if (sizeColumn_ == -1) {
      sizeArrayAlias.push_back((float)(Wt::asNumber(model_->data(i,ZSeriesColumn_,MarkerScaleFactorRole))));
    } else {
      sizeArrayAlias.push_back((float)(Wt::asNumber(model_->data(i,sizeColumn_, asSizeRole_))));
    }
  }
}
Esempio n. 3
0
void gdWColorDialog::setColor(const WColor& color)
{
    m_refData->m_color = color;
    char    selection[64];
    sprintf(selection, "RGB(%3d, %3d, %3d)", color.red(), color.green(), color.blue());
    m_pText->setText(selection);
}
Esempio n. 4
0
WColor WStandardPalette::fontColor(int index) const
{
  WColor c = color(index);
  if (c.red() + c.green() + c.blue() > 3*128) {
    return WColor(StandardColor::Black);
  } else
    return WColor(StandardColor::White);
}
Esempio n. 5
0
WColor WStandardPalette::fontColor(int index) const
{
  WColor c = color(index);
  if (c.red() + c.green() + c.blue() > 3*128) {
    return black;
  } else
    return white;
}
Esempio n. 6
0
void gdWColorDialog::addColor(WTableCell* cell, const WColor& color)
{
    cell->decorationStyle().setBackgroundColor(color);
    cell->resize(20, 20);
    char    toolTip[64];
    sprintf(toolTip, "RGB(%3d, %3d, %3d)", color.red(), color.green(), color.blue());
    cell->setToolTip(toolTip);
    const WColor* const javaColor = &color;
    cell->clicked().connect(boost::bind(&gdWColorDialog::setColor, boost::ref(*this), *javaColor));
}
Esempio n. 7
0
void WRasterImage::setPixel(int x, int y, const WColor& c)
{
  if (painter_)
    throw WException("WRasterImage::setPixel(): cannot be used while a "
		     "painter is active");
  uint8_t* addr = (uint8_t *)impl_->bitmap_->getAddr(x, y);
  addr[0] = c.blue();
  addr[1] = c.green();
  addr[2] = c.red();
  addr[3] = c.alpha();
}
Esempio n. 8
0
WColor::WColor(const WString& name)
  : default_(false),
    red_(-1),
    green_(-1),
    blue_(-1),
    alpha_(255),
    name_(name)
{ 
  WColor c = Wt::Color::parseCssColor(name.toUTF8());
  this->setRgb(c.red(), c.green(), c.blue(), c.alpha());
  // setRgb() erases name_
  name_ = name;
}
QColor transform(const WColor& color)
{
	return QColor(color.red(), color.green(), color.blue(), color.alpha());
}