本文整理汇总了C++中Selection::getSelectionWindow方法的典型用法代码示例。如果您正苦于以下问题:C++ Selection::getSelectionWindow方法的具体用法?C++ Selection::getSelectionWindow怎么用?C++ Selection::getSelectionWindow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Selection
的用法示例。
在下文中一共展示了Selection::getSelectionWindow方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: black
void
CurveData::process()
{
typedef data::Single<Selection *> SingleSelectionPtr;
typedef data::Single<Graph *> SingleGraphPtr;
#ifdef DEBUG_CURVEDATA
cout << "CurveData::process()" << endl;
// cout << " " << expression << endl;
#endif
if (this->expression.compare("") == 0)
{
#ifdef DEBUG_CURVEDATA
cout << " curve has no expression" << endl;
#endif
this->getOutputPort("curve")->setData(NULL);
return;
}
#ifdef DEBUG_CURVEDATA
cout << " curve expression is " << this->expression << endl;
#endif
bvdata::File* speciesFile;
if (!data::Single<bvdata::File*>::getInputValue(this,"file",speciesFile))
{
#ifdef DEBUG_TAGCLOUDDATA
cout << " could not retrieve species file" << endl;
#endif
getOutputPort("curve")->setData(NULL,true);
return;
}
bool integrate_all = false;
Selection *selection = NULL;
if (!SingleSelectionPtr::getInputValue(this,"selection",selection))
integrate_all = true;
#ifdef DEBUG_CURVEDATA
cout << " integrate_all: " << integrate_all << endl;
#endif
// cout << " screen window.....OK" << endl;
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;
//.........这里部分代码省略.........
示例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();
}