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_)))); } } }
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(); }
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()); }