// Returns a "discernible" background color. If the background mode // is Solid, the returned value is just the background color. If the // background mode is Gradient, the returned color is an average of // the two gradient colors const ColorAttribute AnnotationAttributes::GetDiscernibleBackgroundColor() const { ColorAttribute retval; double bg[4]; if (GetBackgroundMode() == Solid) { GetBackgroundColor().GetRgba(bg); } else { double gbg1[4], gbg2[4]; GetGradientColor1().GetRgba(gbg1); GetGradientColor2().GetRgba(gbg2); bg[0] = (gbg1[0] + gbg2[0]) * 0.5; bg[1] = (gbg1[1] + gbg2[1]) * 0.5; bg[2] = (gbg1[2] + gbg2[2]) * 0.5; bg[3] = (gbg1[3] + gbg2[3]) * 0.5; } retval.SetRgba2(bg); return retval; }
void ColorAttributeList::SetFromNode(DataNode *parentNode) { if(parentNode == 0) return; DataNode *searchNode = parentNode->GetNode("ColorAttributeList"); if(searchNode == 0) return; DataNode *node; DataNode **children; // Clear all the ColorAttributes. ClearColors(); // Go through all of the children and construct a new // ColorAttribute for each one of them. children = searchNode->GetChildren(); if(children != 0) { for(int i = 0; i < searchNode->GetNumChildren(); ++i) { if(children[i]->GetKey() == std::string("ColorAttribute")) { ColorAttribute temp; temp.SetFromNode(children[i]); AddColors(temp); } } } }
void QvisLine3DInterface::arrow2ResolutionChanged(int r) { ColorAttribute ca = annot->GetColor2(); ca.SetAlpha(r); annot->SetColor2(ca); Apply(); }
void QvisLine3DInterface::endArrowToggled(bool val) { ColorAttribute ca = annot->GetColor2(); ca.SetGreen(val?1:0); annot->SetColor2(ca); Apply(); }
void avtParallelCoordinatesPlot::SetColors() { int redID, red, green, blue; ColorAttribute colorAtt; ColorAttributeList colorAttList; if (true) // TODO: !atts.GetDoTime() { int numColorEntries = 4 * 2 * PCP_CTX_BRIGHTNESS_LEVELS; unsigned char *plotColors = new unsigned char[numColorEntries]; for (redID = 0; redID < numColorEntries; redID += 4) { float scale; if (redID < numColorEntries/2) scale = ((redID)/4.)/float(PCP_CTX_BRIGHTNESS_LEVELS); else scale = ((redID-numColorEntries/2)/4.)/float(PCP_CTX_BRIGHTNESS_LEVELS); int bgred = int(bgColor[0]*255); int bggreen = int(bgColor[1]*255); int bgblue = int(bgColor[2]*255); int hired, higreen, hiblue; if (redID < numColorEntries/2) { hired = atts.GetContextColor().Red(); higreen = atts.GetContextColor().Green(); hiblue = atts.GetContextColor().Blue(); } else { hired = atts.GetLinesColor().Red(); higreen = atts.GetLinesColor().Green(); hiblue = atts.GetLinesColor().Blue(); } red = int(scale*hired + (1.-scale)*bgred); green = int(scale*higreen + (1.-scale)*bggreen); blue = int(scale*hiblue + (1.-scale)*bgblue); colorAtt.SetRgba(red, green, blue, 255); colorAttList.AddColors(colorAtt); plotColors[redID ] = (unsigned char)red; plotColors[redID+1] = (unsigned char)green; plotColors[redID+2] = (unsigned char)blue; plotColors[redID+3] = 255; } avtLUT->SetLUTColorsWithOpacity(plotColors, 2*PCP_CTX_BRIGHTNESS_LEVELS); levelsMapper->SetColors(colorAttList, needsRecalculation); delete [] plotColors; } else { // Not implemented..... } }
void avtStreamlineRenderer::SetSpecularProperties(bool flag, double coeff, double power, const ColorAttribute &color) { spec_coeff = flag ? coeff : 0; spec_power = power; spec_r = float(color.Red())/255.; spec_g = float(color.Green())/255.; spec_b = float(color.Blue())/255.; }
void avtTransparencyActor::SetSpecularProperties(bool flag,double coeff,double power, const ColorAttribute &color) { vtkProperty *prop = myActor->GetProperty(); if(prop != NULL && prop->GetRepresentation() == VTK_SURFACE) { prop->SetSpecular(flag ? coeff : 0); prop->SetSpecularPower(power); int r = color.Red(); int g = color.Green(); int b = color.Blue(); prop->SetSpecularColor(double(r)/255., double(g)/255., double(b)/255.); } }
void MultiCurveViewer::finishPlot() { if (viewer->DelayedState()->GetAnnotationObjectList()->GetNumAnnotations() > 0) { // Set the first title. vector<string> text; text.push_back("Multi Curve Plot"); viewer->DelayedState()->GetAnnotationObjectList()->GetAnnotation(0).SetText(text); double position[2]; position[0] = 0.3; position[1] = 0.92; viewer->DelayedState()->GetAnnotationObjectList()->GetAnnotation(0).SetPosition(position); position[0] = 0.4; // The text width viewer->DelayedState()->GetAnnotationObjectList()->GetAnnotation(0).SetPosition2(position); ColorAttribute red; red.SetRgba(255, 0, 0, 255); viewer->DelayedState()->GetAnnotationObjectList()->GetAnnotation(0).SetTextColor(red); viewer->DelayedState()->GetAnnotationObjectList()->GetAnnotation(0).SetUseForegroundForTextColor(false); // Set the second title. viewer->DelayedState()->GetAnnotationObjectList()->GetAnnotation(1).SetText(text); position[0] = 0.3; position[1] = 0.02; viewer->DelayedState()->GetAnnotationObjectList()->GetAnnotation(1).SetPosition(position); position[0] = 0.4; // The text width viewer->DelayedState()->GetAnnotationObjectList()->GetAnnotation(1).SetPosition2(position); red.SetRgba(0, 255, 0, 255); viewer->DelayedState()->GetAnnotationObjectList()->GetAnnotation(1).SetTextColor(red); viewer->DelayedState()->GetAnnotationObjectList()->GetAnnotation(1).SetUseForegroundForTextColor(false); viewer->DelayedState()->GetAnnotationObjectList()->Notify(); viewer->DelayedMethods()->SetAnnotationObjectOptions(); } // Draw the plot. viewer->DelayedMethods()->DrawPlots(); }
void CurveViewerPluginInfo::SetColor(AttributeSubject *atts) { CurveAttributes *curveAtts = (CurveAttributes *)atts; if (curveAtts->GetCurveColorSource() == CurveAttributes::Cycle) { ColorAttribute c; unsigned char rgb[3] = {0,0,0}; // // Try and get the color for the colorIndex'th color in the default // discrete color table. // avtColorTables *ct = avtColorTables::Instance(); if(ct->GetControlPointColor(ct->GetDefaultDiscreteColorTable(), colorIndex, rgb)) { c.SetRed(int(rgb[0])); c.SetGreen(int(rgb[1])); c.SetBlue(int(rgb[2])); } curveAtts->SetCurveColor(c); curveAtts->SetFillColor1(c); // Make a whiter version of the color for fill color 2. int R = int(rgb[0]) + 100; int G = int(rgb[1]) + 100; int B = int(rgb[2]) + 100; R = (R > 255) ? 255 : R; G = (G > 255) ? 255 : G; B = (B > 255) ? 255 : B; c.SetRed(R); c.SetGreen(G); c.SetBlue(B); curveAtts->SetFillColor2(c); // Increment the color index. colorIndex = (colorIndex + 1) % ct->GetNumColors(); } }
void avtWellBorePlot::SetColors() { if (atts.GetColorType() == WellBoreAttributes::ColorBySingleColor) { const ColorAttribute ca = atts.GetSingleColor(); ColorAttributeList cal; cal.AddColors(atts.GetSingleColor()); avtLUT->SetLUTColorsWithOpacity(ca.GetColor(), 1); levelsMapper->SetColors(cal); } else if (atts.GetColorType() == WellBoreAttributes::ColorByMultipleColors) { const ColorAttributeList &cal = atts.GetMultiColor(); unsigned char *colors = new unsigned char[atts.GetNWellBores() * 4]; unsigned char *cptr = colors; for(int i = 0; i < atts.GetNWellBores(); i++) { *cptr++ = (char)cal[i].Red(); *cptr++ = (char)cal[i].Green(); *cptr++ = (char)cal[i].Blue(); *cptr++ = (char)cal[i].Alpha(); } avtLUT->SetLUTColorsWithOpacity(colors, atts.GetNWellBores()); levelsMapper->SetColors(cal); delete [] colors; } else // ColorByColorTable { ColorAttributeList cal(atts.GetMultiColor()); unsigned char *colors = new unsigned char[atts.GetNWellBores() * 4]; unsigned char *cptr = colors; avtColorTables *ct = avtColorTables::Instance(); const int opacity = 255; // // Detect if we're using the default color table or a color table // that does not exist anymore. // std::string ctName(atts.GetColorTableName()); if(ctName == "Default") ctName = std::string(ct->GetDefaultDiscreteColorTable()); else if(!ct->ColorTableExists(ctName.c_str())) { delete [] colors; EXCEPTION1(InvalidColortableException, ctName); } bool invert = atts.GetInvertColorTable(); // // Add a color for each subset name. // if(ct->IsDiscrete(ctName.c_str())) { // The CT is discrete, get its color color control points. for(int i = 0; i < atts.GetNWellBores(); ++i) { unsigned char rgb[3] = {0,0,0}; ct->GetControlPointColor(ctName.c_str(), i, rgb, invert); *cptr++ = rgb[0]; *cptr++ = rgb[1]; *cptr++ = rgb[2]; *cptr++ = opacity; cal[i].SetRgba(rgb[0], rgb[1], rgb[2], opacity); } } else { // The CT is continuous, sample the CT so we have a unique color // for each element. unsigned char *rgb = ct->GetSampledColors(ctName.c_str(), atts.GetNWellBores(), invert); if(rgb) { for(int i = 0; i < atts.GetNWellBores(); ++i) { int j = i * 3; *cptr++ = rgb[j]; *cptr++ = rgb[j+1]; *cptr++ = rgb[j+2]; *cptr++ = opacity; cal[i].SetRgba(rgb[j], rgb[j+1], rgb[j+2], opacity); } delete [] rgb; } } avtLUT->SetLUTColorsWithOpacity(colors, atts.GetNWellBores()); levelsMapper->SetColors(cal); delete [] colors; } }
void QvisLine3DInterface::UpdateControls() { // Set the start position. QString pos; pos.sprintf("%lg %lg %lg", annot->GetPosition()[0], annot->GetPosition()[1], annot->GetPosition()[2]); point1Edit->setText(pos); // Set the end position. pos.sprintf("%lg %lg %lg", annot->GetPosition2()[0], annot->GetPosition2()[1], annot->GetPosition2()[2]); point2Edit->setText(pos); lineType->blockSignals(true); lineType->setCurrentIndex(annot->GetIntAttribute3()); lineType->blockSignals(false); // Set the values for the width and style widthWidget->blockSignals(true); widthWidget->SetLineWidth(annot->GetIntAttribute1()); widthWidget->setEnabled(lineType->currentIndex() == 0); widthLabel->setEnabled(lineType->currentIndex() == 0); widthWidget->blockSignals(false); styleWidget->blockSignals(true); styleWidget->SetLineStyle(annot->GetIntAttribute2()); styleWidget->setEnabled(lineType->currentIndex() == 0); styleLabel->setEnabled(lineType->currentIndex() == 0); styleWidget->blockSignals(false); doubleVector dv = annot->GetDoubleVector1(); tubeQuality->blockSignals(true); tubeQuality->setCurrentIndex((int)dv[2]); tubeQuality->setEnabled(lineType->currentIndex() == 1); tubeQualLabel->setEnabled(lineType->currentIndex() == 1); tubeQuality->blockSignals(false); tubeRadius->blockSignals(true); pos.sprintf("%lg", dv[3]); tubeRadius->setText(pos); tubeRadius->setEnabled(lineType->currentIndex() == 1); tubeRadLabel->setEnabled(lineType->currentIndex() == 1); tubeRadius->blockSignals(false); // Set the use foreground color check box. useForegroundColorCheckBox->blockSignals(true); useForegroundColorCheckBox->setChecked(annot->GetUseForegroundForTextColor()); useForegroundColorCheckBox->blockSignals(false); // Change color and opacity. colorButton->blockSignals(true); opacitySlider->blockSignals(true); if (annot->GetUseForegroundForTextColor()) { QColor tmp(255,255,255); colorButton->setButtonColor(tmp); colorLabel->setEnabled(false); colorButton->setEnabled(false); opacitySlider->setGradientColor(tmp); } else { QColor tc(annot->GetColor1().Red(), annot->GetColor1().Green(), annot->GetColor1().Blue()); colorButton->setButtonColor(tc); colorLabel->setEnabled(true); colorButton->setEnabled(true); opacitySlider->setGradientColor(tc); opacitySlider->setValue(annot->GetColor1().Alpha()); } opacitySlider->blockSignals(false); colorButton->blockSignals(false); ColorAttribute ca = annot->GetColor2(); beginArrow->blockSignals(true); beginArrow->setChecked((bool)(ca.Red())); beginArrow->blockSignals(false); arrow1Resolution->blockSignals(true); arrow1Resolution->setValue((int)ca.Blue()); arrow1Resolution->setEnabled(beginArrow->isChecked()); res1Label->setEnabled(beginArrow->isChecked()); arrow1Resolution->blockSignals(false); arrow1Radius->blockSignals(true); pos.sprintf("%lg", dv[0]); arrow1Radius->setText(pos); arrow1Radius->setEnabled(beginArrow->isChecked()); rad1Label->setEnabled(beginArrow->isChecked()); arrow1Radius->blockSignals(false); endArrow->blockSignals(true); endArrow->setChecked((bool)(ca.Green())); endArrow->blockSignals(false); arrow2Resolution->blockSignals(true); arrow2Resolution->setValue((int)ca.Alpha()); arrow2Resolution->setEnabled(endArrow->isChecked()); res2Label->setEnabled(endArrow->isChecked()); arrow2Resolution->blockSignals(false); arrow2Radius->blockSignals(true); pos.sprintf("%lg", dv[1]); arrow2Radius->setText(pos); arrow2Radius->setEnabled(endArrow->isChecked()); rad2Label->setEnabled(endArrow->isChecked()); arrow2Radius->blockSignals(false); // Set the visible check box. visibleCheckBox->blockSignals(true); visibleCheckBox->setChecked(annot->GetVisible()); visibleCheckBox->blockSignals(false); }
ColorAttribute* ColorAttribute__New_1(::uStatic* __this) { ColorAttribute* inst = (ColorAttribute*)::uAllocObject(sizeof(ColorAttribute), ColorAttribute__typeof()); inst->_ObjInit_1(); return inst; }
MaterialAttribute& ColorAttribute::pooledCopy() { ColorAttribute* attr = pool.obtain(); attr->set ( *this ); return *attr; }