本文整理汇总了C++中Selection::getColor方法的典型用法代码示例。如果您正苦于以下问题:C++ Selection::getColor方法的具体用法?C++ Selection::getColor怎么用?C++ Selection::getColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Selection
的用法示例。
在下文中一共展示了Selection::getColor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: black
//.........这里部分代码省略.........
bvdata::Repository *repo = Global::instance()->getRepository();
//find out the sum ranges
ViewRect world_window = speciesFile->getProbSDQuad();//repo->getDefaultLonLatQuad();
int xMin, xMax, yMin, yMax;
double denominator = 1.0;
double cells_per_area_unit = (speciesFile->xcells * speciesFile->ycells) /
(speciesFile->quad.w * speciesFile->quad.h);
if (integrate_all)
{
xMin = 0; yMin = 0;
xMax = x_samples-1; yMax = y_samples-1;
#ifdef DEBUG_CURVEDATA
cout << " this->x_samples: " << x_samples << endl;
cout << " this->y_samples: " << y_samples << endl;
#endif
if (ColorConstants::NORMALIZE_CURVES)
{
denominator = cells_per_area_unit * (speciesFile->quad.w * speciesFile->quad.h) *
Global::instance()->estimateUSAreaCoefficientAtRectangle(
speciesFile->quad.x,
speciesFile->quad.y,
speciesFile->quad.w,
speciesFile->quad.h);
}
}
else {
ViewRect selection_window = selection->getSelectionWindow();
xMin = ((selection_window.x - world_window.x)/(world_window.w)) * x_samples;
if(xMin < 0) xMin = 0;
if(xMin >= x_samples) xMin = x_samples - 1;
xMax = ((selection_window.x +
selection_window.w - world_window.x)/(world_window.w)) * x_samples;
if(xMax < 0) xMax = 0;
if(xMax >= x_samples) xMax = x_samples - 1;
yMin = ((selection_window.y - world_window.y)/(world_window.h)) * y_samples;
if(yMin < 0) yMin = 0;
if(yMin >= y_samples) yMin = y_samples - 1;
yMax = ((selection_window.y +
selection_window.h - world_window.y)/(world_window.h)) * y_samples;
if(yMax < 0) yMax = 0;
if(yMax >= y_samples) yMax = y_samples - 1;
// TODO need to have this rectangle right
if (ColorConstants::NORMALIZE_CURVES)
{
denominator = cells_per_area_unit * (selection_window.w * selection_window.h) *
Global::instance()->estimateUSAreaCoefficientAtRectangle(selection_window.x,
selection_window.y,
selection_window.w,
selection_window.h);
}
}
#ifdef DEBUG_CURVEDATA
cout << " xMin, xMax, yMin, yMax: "
<< xMin << ", " << xMax << ", "
<< yMin << ", " << yMax << endl;
// cout << " " << expression << endl;
#endif
//R query
vector<float> curve = speciesFile->getVariableCurve("p", xMin+1, xMax+1, yMin+1, yMax+1);
vector<float>::iterator it;
Color black(0,0,0);
this->graph.curve.clear();
this->graph.color = (selection != NULL ? selection->getColor() : black);
float sum = 0;
for (int i=0;i<curve.size();i++)
{
if (denominator > 0.0)
this->graph.curve.push_back(curve[i]/denominator);
else
this->graph.curve.push_back(0.0);
sum += curve[i];
}
#ifdef DEBUG_CURVEDATA
cout << " Sum = " << sum << endl;
#endif
this->getOutputPort("curve")->setData(new SingleGraphPtr(&this->graph),true);
}
示例2: swt
void
MapSelectionsRenderer::process()
{
#ifdef DEBUG_MAPSELECTIONSRENDERER
cout << "MapSelectionsRenderer::process()" << endl;
#endif
// cout << "MapSelectionsRenderer::process()" << endl;
typedef data::Single<Selection *> SingleSelectionPtr;
ViewRect screen_window;
if (!data::SingleViewRect::getInputValue(this,"screen_window",screen_window))
return;
#ifdef DEBUG_MAPSELECTIONSRENDERER
cout << " screen window.....OK" << endl;
#endif
ViewRect world_window;
if (!data::SingleViewRect::getInputValue(this,"world_window",world_window))
return;
#ifdef DEBUG_MAPSELECTIONSRENDERER
cout << " world window.....OK" << endl;
#endif
vector<Selection *> selections;
vector<Data *> vec_data = this->getInputPort("selections")->getAllData();
for (int i=0;i<vec_data.size();i++)
{
SingleSelectionPtr* data = dynamic_cast<SingleSelectionPtr*>(vec_data.at(i));
if (data != NULL)
selections.push_back(data->value);
}
#ifdef DEBUG_MAPSELECTIONSRENDERER
cout << " number of selections " << selections.size() << endl;
#endif
Global *global = Global::instance();
if (global->usa_states == NULL)
{
cout << " usa states not loaded... returning without rendering" << endl;
}
ScreenWorldTransform swt(screen_window, world_window);
ViewRect adj_screen_window = swt.getAdjustedScreenWindow();
RenderSystem *renderSystem = global->getRenderSystem();
renderSystem->startViewport(adj_screen_window,
world_window,
screen_window);
for (int i=0;i<selections.size();i++)
{
Selection *sel = selections[i];
ViewRect sw = sel->getSelectionWindow();
Color c = sel->getColor();
renderSystem->setColor(c.r,c.g,c.b, ColorConstants::SEL_TRANSPARENCY);
renderSystem->drawQuad(sw.x,sw.y,sw.w,sw.h);
renderSystem->setColor(sel->getColor());
renderSystem->drawQuad(sw.x,sw.y,sw.w,sw.h,GL_LINE_LOOP);
}
renderSystem->endViewport();
}