本文整理汇总了C++中PView::getOptions方法的典型用法代码示例。如果您正苦于以下问题:C++ PView::getOptions方法的具体用法?C++ PView::getOptions怎么用?C++ PView::getOptions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PView
的用法示例。
在下文中一共展示了PView::getOptions方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: set_animation
void set_animation(int step)
{
for(unsigned int i = 0; i < PView::list.size(); i++){
PView * p = PView::list[i];
if(p->getOptions()->visible){
p->getOptions()->timeStep = step;
p->setChanged(true);
}
}
}
示例2: computeAndSendVertexArrays
// This version sends VArrays using MPI
static void computeAndSendVertexArrays()
{
// compute...
for(unsigned int i = 0; i < PView::list.size(); i++)
PView::list[i]->fillVertexArrays();
// ...and send
int nbArrays = PView::list.size()* 4;
MPI_Send(&nbArrays, 1, MPI_INT, 0, MPI_GMSH_DATA_READY, MPI_COMM_WORLD);
for(unsigned int i = 0; i < PView::list.size(); i++){
PView *p = PView::list[i];
PViewData *data = p->getData();
PViewOptions *opt = p->getOptions();
double min = data->getMin(), max = data->getMax();
if(opt->rangeType == PViewOptions::PerTimeStep){
min = data->getMin(opt->timeStep);
max = data->getMax(opt->timeStep);
}
VertexArray *va[4] =
{p->va_points, p->va_lines, p->va_triangles, p->va_vectors};
for(int type = 0; type < 4; type++){
if(va[type]){
int len;
char *str = va[type]->toChar
(p->getTag(), data->getName(), type + 1, min, max,
data->getNumTimeSteps(), data->getTime(opt->timeStep),
data->getBoundingBox(), len);
MPI_Send(&len, 1, MPI_INT, 0, MPI_GMSH_VARRAY_LEN, MPI_COMM_WORLD);
MPI_Send(str, len, MPI_CHAR, 0, MPI_GMSH_VARRAY, MPI_COMM_WORLD);
delete [] str;
}
}
}
}
示例3: animation_next
int animation_next()
{
int ret = 0;
for(unsigned int i = 0; i < PView::list.size(); i++){
PView * p = PView::list[i];
if(p->getOptions()->visible){
int step = (int)p->getOptions()->timeStep + 1;
int numSteps = (int)p->getData()->getNumTimeSteps();
if(step < 0) step = numSteps - 1;
if(step > numSteps - 1) step = 0;
p->getOptions()->timeStep = step;
p->setChanged(true);
ret = step;
}
}
return ret;
}
示例4: number_of_animation
int number_of_animation()
{
int ret = 0;
for(unsigned int i = 0; i < PView::list.size(); i++){
PView * p = PView::list[i];
if(p->getOptions()->visible){
int numSteps = (int)p->getData()->getNumTimeSteps();
if(numSteps > ret) ret = numSteps;
}
}
return ret;
}
示例5: drawScale
void drawContext::drawScale()
{
glPushMatrix();
glLoadIdentity();
double size = std::max(_right -_left, _top - _bottom);
double width = size / 3.5;
double height = size / 10.;
double dh = height / 5;
// Draw the scale bar
int nPview = 0;
for(int i=0; i<PView::list.size();i++){
PView *p = PView::list[i];
PViewOptions *opt = p->getOptions();
if(!opt->visible) continue;
PViewData *data = p->getData();
double box = width / (opt->nbIso ? opt->nbIso : 1);
double xmin = _left + (_right - _left - width)/2.;
double ymin = _bottom + 0.7 * height + height * nPview;
std::vector<GLfloat> vertex(opt->nbIso*3*4);
std::vector<GLubyte> color(opt->nbIso*4*4);
for(int i = 0; i < opt->nbIso; i++){
if(opt->intervalsType == PViewOptions::Discrete ||
opt->intervalsType == PViewOptions::Numeric){
unsigned int col = opt->getColor(i, opt->nbIso);
color[i*4*4+0] = color[i*4*4+4] = color[i*4*4+8] = color[i*4*4+12] =
(GLubyte)CTX::instance()->unpackRed(col);
color[i*4*4+1] = color[i*4*4+5] = color[i*4*4+9] = color[i*4*4+13] =
(GLubyte)CTX::instance()->unpackGreen(col);
color[i*4*4+2] = color[i*4*4+6] = color[i*4*4+10] = color[i*4*4+14] =
(GLubyte)CTX::instance()->unpackBlue(col);
color[i*4*4+3] = color[i*4*4+7] = color[i*4*4+11] = color[i*4*4+15] =
(GLubyte)CTX::instance()->unpackAlpha(col);
vertex[i*3*4+0] = xmin + i * box;
vertex[i*3*4+1] = ymin;
vertex[i*3*4+2] = 0.;
vertex[i*3*4+3] = xmin + i * box;
vertex[i*3*4+4] = ymin + dh;
vertex[i*3*4+5] = 0.;
vertex[i*3*4+6] = xmin + (i + 1) * box;
vertex[i*3*4+7] = ymin;
vertex[i*3*4+8] = 0.;
vertex[i*3*4+9] = xmin + (i + 1) * box;
vertex[i*3*4+10] = ymin + dh;
vertex[i*3*4+11] = 0.;
}
else if(opt->intervalsType == PViewOptions::Continuous){
double dv = (opt->tmpMax - opt->tmpMin) / (opt->nbIso ? opt->nbIso : 1);
double v1 = opt->tmpMin + i * dv;
unsigned int col1 = opt->getColor(v1, opt->tmpMin, opt->tmpMax, true);
color[i*4*4+0] = color[i*4*4+4] = (GLubyte)CTX::instance()->unpackRed(col1);
color[i*4*4+1] = color[i*4*4+5] = (GLubyte)CTX::instance()->unpackGreen(col1);
color[i*4*4+2] = color[i*4*4+6] = (GLubyte)CTX::instance()->unpackBlue(col1);
color[i*4*4+3] = color[i*4*4+7] = (GLubyte)CTX::instance()->unpackAlpha(col1);
vertex[i*3*4+0] = xmin + i * box;
vertex[i*3*4+1] = ymin;
vertex[i*3*4+2] = 0.;
vertex[i*3*4+3] = xmin + i * box;
vertex[i*3*4+4] = ymin + dh;
vertex[i*3*4+5] = 0.;
double v2 = opt->tmpMin + (i + 1) * dv;
unsigned int col2 = opt->getColor(v2, opt->tmpMin, opt->tmpMax, true);
color[i*4*4+8] = color[i*4*4+12] = (GLubyte)CTX::instance()->unpackRed(col2);
color[i*4*4+9] = color[i*4*4+13] = (GLubyte)CTX::instance()->unpackGreen(col2);
color[i*4*4+10] = color[i*4*4+14] = (GLubyte)CTX::instance()->unpackBlue(col2);
color[i*4*4+11] = color[i*4*4+15] = (GLubyte)CTX::instance()->unpackAlpha(col2);
vertex[i*3*4+6] = xmin + (i + 1) * box;
vertex[i*3*4+7] = ymin;
vertex[i*3*4+8] = 0.;
vertex[i*3*4+9] = xmin + (i + 1) * box;
vertex[i*3*4+10] = ymin + dh;
vertex[i*3*4+11] = 0.;
}
else{
unsigned int col = opt->getColor(i, opt->nbIso);
color[i*4*4+0] = color[i*4*4+4] = color[i*4*4+8] = color[i*4*4+12] =
(GLubyte)CTX::instance()->unpackRed(col);
color[i*4*4+1] = color[i*4*4+5] = color[i*4*4+9] = color[i*4*4+13] =
(GLubyte)CTX::instance()->unpackGreen(col);
color[i*4*4+2] = color[i*4*4+6] = color[i*4*4+10] = color[i*4*4+14] =
(GLubyte)CTX::instance()->unpackBlue(col);
color[i*4*4+3] = color[i*4*4+7] = color[i*4*4+11] = color[i*4*4+15] =
(GLubyte)CTX::instance()->unpackAlpha(col);
vertex[i*3*4+0] = xmin + i * box;
vertex[i*3*4+1] = ymin;
vertex[i*3*4+2] = 0.;
vertex[i*3*4+3] = xmin + i * box;
vertex[i*3*4+4] = ymin + dh;
vertex[i*3*4+5] = 0.;
vertex[i*3*4+6] = xmin + (i + 1) * box;
vertex[i*3*4+7] = ymin;
vertex[i*3*4+8] = 0.;
vertex[i*3*4+9] = xmin + (i + 1) * box;
vertex[i*3*4+10] = ymin + dh;
vertex[i*3*4+11] = 0.;
}
}
//.........这里部分代码省略.........
示例6: drawScales
void drawContext::drawScales()
{
std::vector<PView*> scales;
for(unsigned int i = 0; i < PView::list.size(); i++){
PViewData *data = PView::list[i]->getData();
PViewOptions *opt = PView::list[i]->getOptions();
if(!data->getDirty() && opt->visible && opt->showScale &&
opt->type == PViewOptions::Plot3D && data->getNumElements() &&
isVisible(PView::list[i]))
scales.push_back(PView::list[i]);
}
if(scales.empty()) return;
drawContext::global()->setFont(CTX::instance()->glFontEnum,
CTX::instance()->glFontSize);
char label[1024];
double maxw = 0.;
for(unsigned int i = 0; i < scales.size(); i++) {
PViewOptions *opt = scales[i]->getOptions();
sprintf(label, opt->format.c_str(), -M_PI * 1.e-4);
maxw = std::max(maxw, drawContext::global()->getStringWidth(label));
}
const double tic = 10., bar_size = 16.;
double width = 0., width_prev = 0., width_total = 0.;
for(unsigned int i = 0; i < scales.size(); i++) {
PView *p = scales[i];
PViewData *data = p->getData();
PViewOptions *opt = p->getOptions();
if(!opt->autoPosition) {
double w = opt->size[0], h = opt->size[1];
double x = opt->position[0], y = opt->position[1] - h;
int c = fix2dCoordinates(&x, &y);
if(c & 1) x -= w / 2.;
if(c & 2) y += h / 2.;
drawScale(this, p, x, y, w, h, tic, CTX::instance()->post.horizontalScales);
}
else if(CTX::instance()->post.horizontalScales){
double ysep = 20.;
double xc = (viewport[2] - viewport[0]) / 2.;
if(scales.size() == 1){
double w = (viewport[2] - viewport[0]) / 2., h = bar_size;
double x = xc - w / 2., y = viewport[1] + ysep;
drawScale(this, p, x, y, w, h, tic, 1);
}
else{
double xsep = maxw / 4. + (viewport[2] - viewport[0]) / 10.;
double w = (viewport[2] - viewport[0] - 4 * xsep) / 2.;
if(w < 20.) w = 20.;
double h = bar_size;
double x = xc - (i % 2 ? -xsep / 1.5 : w + xsep / 1.5);
double y = viewport[1] + ysep +
(i / 2) * (bar_size + tic +
2 * drawContext::global()->getStringHeight() + ysep);
drawScale(this, p, x, y, w, h, tic, 1);
}
}
else{
double xsep = 20.;
double dy = 2. * drawContext::global()->getStringHeight();
if(scales.size() == 1){
double ysep = (viewport[3] - viewport[1]) / 6.;
double w = bar_size, h = viewport[3] - viewport[1] - 2 * ysep - dy;
double x = viewport[0] + xsep, y = viewport[1] + ysep + dy;
drawScale(this, p, x, y, w, h, tic, 0);
}
else{
double ysep = (viewport[3] - viewport[1]) / 15.;
double w = bar_size;
double h = (viewport[3] - viewport[1] - 3 * ysep - 2.5 * dy) / 2.;
double x = viewport[0] + xsep + width_total + (i / 2) * xsep;
double y = viewport[1] + ysep + dy + (1 - i % 2) * (h + 1.5 * dy + ysep);
drawScale(this, p, x, y, w, h, tic, 0);
}
// compute width
width_prev = width;
sprintf(label, opt->format.c_str(), -M_PI * 1.e-4);
width = bar_size + tic + drawContext::global()->getStringWidth(label);
if(opt->showTime){
char tmp[256];
sprintf(tmp, opt->format.c_str(), data->getTime(opt->timeStep));
sprintf(label, "%s (%s)", data->getName().c_str(), tmp);
}
else
sprintf(label, "%s", data->getName().c_str());
width = std::max(width, drawContext::global()->getStringWidth(label));
if(i % 2) width_total += std::max(bar_size + width, bar_size + width_prev);
}
}
}
示例7: getView
PView *GMSH_MinMaxPlugin::execute(PView * v)
{
int iView = (int)MinMaxOptions_Number[0].def;
int overTime = (int)MinMaxOptions_Number[1].def;
int argument = (int)MinMaxOptions_Number[2].def;
PView *v1 = getView(iView, v);
if(!v1) return v;
PViewData *data1 = v1->getData(true);
PView *vMin = new PView();
PView *vMax = new PView();
PViewDataList *dataMin = getDataList(vMin);
PViewDataList *dataMax = getDataList(vMax);
if(!argument){
double x = data1->getBoundingBox().center().x();
double y = data1->getBoundingBox().center().y();
double z = data1->getBoundingBox().center().z();
dataMin->SP.push_back(x); dataMin->SP.push_back(y); dataMin->SP.push_back(z);
dataMax->SP.push_back(x); dataMax->SP.push_back(y); dataMax->SP.push_back(z);
dataMin->NbSP = 1;
dataMax->NbSP = 1;
}
double min=VAL_INF, max=-VAL_INF, timeMin=0, timeMax=0;
for(int step = 0; step < data1->getNumTimeSteps(); step++){
if(data1->hasTimeStep(step)){
double minView = VAL_INF, maxView = -VAL_INF;
double xmin = 0., ymin = 0., zmin = 0., xmax = 0., ymax = 0., zmax = 0.;
for(int ent = 0; ent < data1->getNumEntities(step); ent++){
for(int ele = 0; ele < data1->getNumElements(step, ent); ele++){
for(int nod = 0; nod < data1->getNumNodes(step, ent, ele); nod++){
double val;
data1->getScalarValue(step, ent, ele, nod, val);
if(val < minView){
data1->getNode(step, ent, ele, nod, xmin, ymin, zmin);
minView = val;
}
if(val > maxView){
data1->getNode(step, ent, ele, nod, xmax, ymax, zmax);
maxView = val;
}
}
}
}
if(!overTime){
if(argument){
dataMin->SP.push_back(xmin); dataMin->SP.push_back(ymin); dataMin->SP.push_back(zmin);
dataMax->SP.push_back(xmax); dataMax->SP.push_back(ymax); dataMax->SP.push_back(zmax);
(dataMin->NbSP)++;
(dataMax->NbSP)++;
}
else{
double time = data1->getTime(step);
dataMin->Time.push_back(time);
dataMax->Time.push_back(time);
}
dataMin->SP.push_back(minView);
dataMax->SP.push_back(maxView);
}
else{
if(minView < min){
min = minView;
timeMin = data1->getTime(step);
}
if(maxView > max){
max = maxView;
timeMax = data1->getTime(step);
}
}
}
}
if(overTime){
dataMin->SP.push_back(min);
dataMax->SP.push_back(max);
dataMin->Time.push_back(timeMin);
dataMax->Time.push_back(timeMax);
}
vMin->getOptions()->intervalsType = PViewOptions::Numeric;
vMax->getOptions()->intervalsType = PViewOptions::Numeric;
dataMin->setName(data1->getName() + "_Min");
dataMin->setFileName(data1->getName() + "_Min.pos");
dataMin->finalize();
dataMax->setName(data1->getName() + "_Max");
dataMax->setFileName(data1->getName() + "_Max.pos");
dataMax->finalize();
return 0;
}
示例8: combine
void PView::combine(bool time, int how, bool remove)
{
// time == true: combine the timesteps (oherwise combine the elements)
// how == 0: try to combine all visible views
// 1: try to combine all views
// 2: try to combine all views having identical names
std::vector<nameData> nds;
for(unsigned int i = 0; i < list.size(); i++) {
PView *p = list[i];
PViewData *data = p->getData();
if(how || p->getOptions()->visible) {
nameData nd;
// this will lead to weird results if there are views named
// "__all__" or "__vis__" :-)
if(how == 2)
nd.name = data->getName();
else if(how == 1)
nd.name = "__all__";
else
nd.name = "__vis__";
unsigned int j = 0;
while(j < nds.size()){
if(nds[j].name == nd.name){
nds[j].data.push_back(data);
nds[j].indices.push_back(i);
break;
}
j++;
}
if(j == nds.size()){
nd.data.push_back(data);
nd.indices.push_back(i);
nds.push_back(nd);
}
}
}
std::set<PView*> rm;
for(unsigned int i = 0; i < nds.size(); i++){
if(nds[i].data.size() > 1){ // there's potentially something to combine
// sanity checks:
bool allListBased = true, allModelBased = true;
for(unsigned int j = 0; j < nds[i].data.size(); j++){
PViewDataList *d1 = dynamic_cast<PViewDataList*>(nds[i].data[j]);
if(!d1) allListBased = false;
PViewDataGModel *d2 = dynamic_cast<PViewDataGModel*>(nds[i].data[j]);
if(!d2) allModelBased = false;
}
PViewData *data = 0;
if(allListBased){
data = new PViewDataList();
}
else if(allModelBased){
PViewDataGModel *d2 = dynamic_cast<PViewDataGModel*>(nds[i].data[0]);
data = new PViewDataGModel(d2->getType());
}
else{
Msg::Error("Cannot combine hybrid list/mesh-based datasets");
continue;
}
PView *p = new PView(data);
bool res = time ? data->combineTime(nds[i]) : data->combineSpace(nds[i]);
if(res){
for(unsigned int j = 0; j < nds[i].indices.size(); j++)
rm.insert(list[nds[i].indices[j]]);
PViewOptions *opt = p->getOptions();
if(opt->adaptVisualizationGrid){
// the (empty) adaptive data created in PView() must be
// recreated, since we added some data
data->destroyAdaptiveData();
data->initAdaptiveData
(opt->timeStep, opt->maxRecursionLevel, opt->targetError);
}
}
else
delete p;
}
}
if(remove)
for(std::set<PView*>::iterator it = rm.begin(); it != rm.end(); it++)
delete *it;
}