diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h index 7e0cc601ba2b82d1cdd405446a35306e4de45713..42d4fc2041d8fffc45e11a53cc4ab30066d57158 100644 --- a/Common/DefaultOptions.h +++ b/Common/DefaultOptions.h @@ -1291,7 +1291,7 @@ StringXNumber ViewOptions_Number[] = { { F|O, "AutoPosition" , opt_view_auto_position , 1. , "Position the scale or 2D plot automatically (0: manual, 1: automatic, 2: top left, " "3: top right, 4: bottom left, 5: bottom right, 6: top, 7: bottom, 8: left, 9: right, " - "10: full, 11: top third)" }, + "10: full, 11: top third, 12: in model coordinates)" }, { F|O, "Axes" , opt_view_axes , 0 , "Axes (0=none, 1=simple axes, 2=box, 3=full grid, 4=open grid, 5=ruler)" }, { F|O, "AxesMikado" , opt_view_axes_mikado , 0. , diff --git a/Common/Options.cpp b/Common/Options.cpp index 517f3037c61ca64706c30daafa05a0694b5642f2..47c16223b150c1f33e15dcb7efb3e192fb96c8d1 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -7166,7 +7166,7 @@ double opt_view_auto_position(OPT_ARGS_NUM) GET_VIEWo(0.); if(action & GMSH_SET) { opt->autoPosition = (int)val; - if(opt->autoPosition < 0 || opt->autoPosition > 11) + if(opt->autoPosition < 0 || opt->autoPosition > 12) opt->autoPosition = 0; } #if defined(HAVE_FLTK) @@ -7186,7 +7186,7 @@ double opt_view_position0(OPT_ARGS_NUM) #if defined(HAVE_POST) GET_VIEWo(0.); if(action & GMSH_SET) { - opt->position[0] = (int)val; + opt->position[0] = val; } #if defined(HAVE_FLTK) if(_gui_action_valid(action, num)) @@ -7203,7 +7203,7 @@ double opt_view_position1(OPT_ARGS_NUM) #if defined(HAVE_POST) GET_VIEWo(0.); if(action & GMSH_SET) { - opt->position[1] = (int)val; + opt->position[1] = val; } #if defined(HAVE_FLTK) if(_gui_action_valid(action, num)) @@ -7238,7 +7238,7 @@ double opt_view_size0(OPT_ARGS_NUM) #if defined(HAVE_POST) GET_VIEWo(0.); if(action & GMSH_SET) { - opt->size[0] = (int)val; + opt->size[0] = val; } #if defined(HAVE_FLTK) if(_gui_action_valid(action, num)) @@ -7255,7 +7255,7 @@ double opt_view_size1(OPT_ARGS_NUM) #if defined(HAVE_POST) GET_VIEWo(0.); if(action & GMSH_SET) { - opt->size[1] = (int)val; + opt->size[1] = val; } #if defined(HAVE_FLTK) if(_gui_action_valid(action, num)) diff --git a/Fltk/optionWindow.cpp b/Fltk/optionWindow.cpp index 3db05f54adeaeb75aab54dd8ecd88035c6932352..ec095ad4ecafee29e0ad5b663f9ed3223536efec 100644 --- a/Fltk/optionWindow.cpp +++ b/Fltk/optionWindow.cpp @@ -105,6 +105,7 @@ static Fl_Menu_Item menu_position[] = { {"Right", 0, 0, 0}, {"Full", 0, 0, 0}, {"Top third", 0, 0, 0}, + {"In model coordinates", 0, 0, 0}, {0} }; @@ -3039,28 +3040,28 @@ optionWindow::optionWindow(int deltaFontSize) (L + 2 * WB, 2 * WB + 9 * BH, IW / 2, BH); view.value[20]->minimum(-2000); view.value[20]->maximum(2000); - view.value[20]->step(1); + view.value[20]->step(0.5); view.value[20]->callback(view_options_ok_cb); view.value[21] = new Fl_Value_Input (L + 2 * WB + IW / 2, 2 * WB + 9 * BH, IW / 2, BH, "2D axes/value scale position"); view.value[21]->align(FL_ALIGN_RIGHT); view.value[21]->minimum(-2000); view.value[21]->maximum(2000); - view.value[21]->step(1); + view.value[21]->step(0.5); view.value[21]->callback(view_options_ok_cb); view.value[22] = new Fl_Value_Input (L + 2 * WB, 2 * WB + 10 * BH, IW / 2, BH); view.value[22]->minimum(0); view.value[22]->maximum(2000); - view.value[22]->step(1); + view.value[22]->step(0.5); view.value[22]->callback(view_options_ok_cb); view.value[23] = new Fl_Value_Input (L + 2 * WB + IW / 2, 2 * WB + 10 * BH, IW / 2, BH, "2D axes/value scale size"); view.value[23]->align(FL_ALIGN_RIGHT); view.value[23]->minimum(0); view.value[23]->maximum(2000); - view.value[23]->step(1); + view.value[23]->step(0.5); view.value[23]->callback(view_options_ok_cb); o->end(); @@ -4029,17 +4030,17 @@ void optionWindow::activate(const char *what) } } else if(!strcmp(what, "view_axes_auto_2d")){ - if(view.choice[16]->value()){ - view.value[20]->deactivate(); - view.value[21]->deactivate(); - view.value[22]->deactivate(); - view.value[23]->deactivate(); - } - else{ + if(view.choice[16]->value() == 0 || view.choice[16]->value() == 12){ view.value[20]->activate(); view.value[21]->activate(); view.value[22]->activate(); view.value[23]->activate(); } + else{ + view.value[20]->deactivate(); + view.value[21]->deactivate(); + view.value[22]->deactivate(); + view.value[23]->deactivate(); + } } } diff --git a/Graphics/drawContext.cpp b/Graphics/drawContext.cpp index 845431a3f508cc92a33bef61e0b3756fbd3a24a9..75bc9409699c1219c36a0bbee049a5c0d6ee6d1b 100644 --- a/Graphics/drawContext.cpp +++ b/Graphics/drawContext.cpp @@ -286,6 +286,7 @@ void drawContext::draw3d() drawBackgroundImage(true); drawMesh(); drawPost(); + drawGraph2d(true); } void drawContext::draw2d() @@ -306,11 +307,10 @@ void drawContext::draw2d() glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - drawGraph2d(); + drawGraph2d(false); drawText2d(); if(CTX::instance()->post.draw && !CTX::instance()->stereo) drawScales(); - if(CTX::instance()->smallAxes) drawSmallAxes(); } @@ -839,9 +839,9 @@ bool drawContext::select(int type, bool multiple, bool mesh, // maximum number of possible hits GModel *m = GModel::current(); int eles = (mesh && CTX::instance()->pickElements) ? 4 * m->getNumMeshElements() : 0; + int views = PView::list.size() * 100; int size = 7 * (m->getNumVertices() + m->getNumEdges() + m->getNumFaces() + - m->getNumRegions() + eles); - + m->getNumRegions() + eles) + views; if(!size) return false; // the model is empty, don't bother! // allocate selection buffer @@ -854,11 +854,28 @@ bool drawContext::select(int type, bool multiple, bool mesh, glRenderMode(GL_SELECT); glInitNames(); glPushMatrix(); + + // 3d stuff initProjection(x, y, w, h); initPosition(); drawGeom(); if(mesh) drawMesh(); + drawGraph2d(true); + + // 2d stuff + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPickMatrix((GLdouble)x, (GLdouble)(viewport[3] - y), + (GLdouble)w, (GLdouble)h, (GLint *)viewport); + glOrtho((double)viewport[0], (double)viewport[2], + (double)viewport[1], (double)viewport[3], + -100., 100.); // in pixels, so we can draw some 3D glyphs + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + drawGraph2d(false); + glPopMatrix(); + GLint numhits = glRenderMode(GL_RENDER); render_mode = drawContext::GMSH_RENDER; @@ -984,6 +1001,11 @@ bool drawContext::select(int type, bool multiple, bool mesh, if(!multiple) return true; } break; + case 4: + { + printf("got hit with %d\n", hits[i].ient); + } + break; } } } diff --git a/Graphics/drawContext.h b/Graphics/drawContext.h index 2f1285f283c7f2260dae09af034a7a4edb443b8c..7d0c97402a3f5c5da49a04c4e8c8194c38bdaa18 100644 --- a/Graphics/drawContext.h +++ b/Graphics/drawContext.h @@ -203,7 +203,7 @@ class drawContext { void drawBackgroundGradient(); void drawBackgroundImage(bool moving); void drawText2d(); - void drawGraph2d(); + void drawGraph2d(bool inModelCoordinates); void drawAxis(double xmin, double ymin, double zmin, double xmax, double ymax, double zmax, int nticks, int mikado); diff --git a/Graphics/drawGeom.cpp b/Graphics/drawGeom.cpp index 4da3101abf0246ff6915c4ed106f3b97b6bddb81..c8c7903d618207de5bbe0e94d94617c23366ec9d 100644 --- a/Graphics/drawGeom.cpp +++ b/Graphics/drawGeom.cpp @@ -466,7 +466,6 @@ class drawGRegion { void operator () (GRegion *r) { if(!r->getVisibility()) return; - // if(r->geomType() == GEntity::DiscreteVolume) return; bool select = (_ctx->render_mode == drawContext::GMSH_SELECT && r->model() == GModel::current()); diff --git a/Graphics/drawGlyph.cpp b/Graphics/drawGlyph.cpp index 641c8ff7e354b060e10b8f3617b9d0652c15899e..8c04472d9bf45f4896ee8768efb6e200a3ead114 100644 --- a/Graphics/drawGlyph.cpp +++ b/Graphics/drawGlyph.cpp @@ -23,7 +23,7 @@ void drawContext::drawString(const std::string &s, const std::string &font_name, if(valid == GL_FALSE) return; // the primitive is culled // change the raster position only if not creating TeX files - if(align > 0 && (!CTX::instance()->printing || + if(align > 0 && (!CTX::instance()->printing || CTX::instance()->print.fileFormat != FORMAT_TEX)){ GLdouble pos[4]; glGetDoublev(GL_CURRENT_RASTER_POSITION, pos); @@ -45,7 +45,7 @@ void drawContext::drawString(const std::string &s, const std::string &font_name, viewport2World(w, x); glRasterPos3d(x[0], x[1], x[2]); } - + if(!CTX::instance()->printing){ drawContext::global()->setFont(font_enum, font_size); drawContext::global()->drawString(s.c_str()); @@ -68,7 +68,7 @@ void drawContext::drawString(const std::string &s, const std::string &font_name, } gl2psTextOpt(tmp.c_str(), font_name.c_str(), font_size, opt, 0.); } - else if(CTX::instance()->print.epsQuality && + else if(CTX::instance()->print.epsQuality && (CTX::instance()->print.fileFormat == FORMAT_PS || CTX::instance()->print.fileFormat == FORMAT_EPS || CTX::instance()->print.fileFormat == FORMAT_PDF || @@ -84,7 +84,7 @@ void drawContext::drawString(const std::string &s, const std::string &font_name, void drawContext::drawString(const std::string &s) { - drawString(s, CTX::instance()->glFont, CTX::instance()->glFontEnum, + drawString(s, CTX::instance()->glFont, CTX::instance()->glFontEnum, CTX::instance()->glFontSize, 0); } @@ -166,7 +166,6 @@ void drawContext::drawEllipsoid(double x, double y, double z, float v0[3], float void drawContext::drawSphere(double size, double x, double y, double z, int light) { double ss = size * pixel_equiv_x / s[0]; // size is in pixels - if(light) glEnable(GL_LIGHTING); glPushMatrix(); glTranslated(x, y, z); @@ -176,8 +175,8 @@ void drawContext::drawSphere(double size, double x, double y, double z, int ligh glDisable(GL_LIGHTING); } -void drawContext::drawTaperedCylinder(double width, double val1, double val2, - double ValMin, double ValMax, +void drawContext::drawTaperedCylinder(double width, double val1, double val2, + double ValMin, double ValMax, double *x, double *y, double *z, int light) { if(light) glEnable(GL_LIGHTING); @@ -242,7 +241,7 @@ void drawContext::drawCylinder(double width, double *x, double *y, double *z, in static void drawSimpleVector(int arrow, int fill, double x, double y, double z, - double dx, double dy, double dz, + double dx, double dy, double dz, double d, int light) { double n[3], t[3], u[3]; @@ -288,7 +287,7 @@ static void drawSimpleVector(int arrow, int fill, glVertex3d(x, y, z); glVertex3d(x + f1 * dx, y + f1 * dy, z + f1 * dz); glEnd(); - + if(light && fill) glEnable(GL_LIGHTING); glBegin(GL_TRIANGLES); if(light) glNormal3dv(u); @@ -296,19 +295,19 @@ static void drawSimpleVector(int arrow, int fill, glVertex3d(x + f2 * dx + b * (t[0]), y + f2 * dy + b * (t[1]), z + f2 * dz + b * (t[2])); glVertex3d(x + f1 * dx, y + f1 * dy, z + f1 * dz); - + glVertex3d(x + f1 * dx, y + f1 * dy, z + f1 * dz); glVertex3d(x + f2 * dx + b * (-t[0]), y + f2 * dy + b * (-t[1]), z + f2 * dz + b * (-t[2])); glVertex3d(x + dx, y + dy, z + dz); - + if(light) glNormal3dv(t); glVertex3d(x + dx, y + dy, z + dz); glVertex3d(x + f2 * dx + b * (-u[0]), y + f2 * dy + b * (-u[1]), z + f2 * dz + b * (-u[2])); glVertex3d(x + f1 * dx, y + f1 * dy, z + f1 * dz); - glVertex3d(x + f1 * dx, y + f1 * dy, z + f1 * dz); + glVertex3d(x + f1 * dx, y + f1 * dy, z + f1 * dz); glVertex3d(x + f2 * dx + b * (u[0]), y + f2 * dy + b * (u[1]), z + f2 * dz + b * (u[2])); glVertex3d(x + dx, y + dy, z + dz); @@ -390,17 +389,17 @@ static void drawSimpleVector(int arrow, int fill, glVertex3d(x+b*(-t[0]), y+b*(-t[1]), z+b*(-t[2])); glVertex3d(x+b*(u[0]), y+b*(u[1]), z+b*(u[2])); glEnd(); - + glBegin(GL_LINES); glVertex3d(x+b*(t[0]), y+b*(t[1]), z+b*(t[2])); glVertex3d(x+dx, y+dy, z+dz); - + glVertex3d(x+b*(-u[0]), y+b*(-u[1]), z+b*(-u[2])); glVertex3d(x+dx, y+dy, z+dz); - + glVertex3d(x+b*(-t[0]), y+b*(-t[1]), z+b*(-t[2])); glVertex3d(x+dx, y+dy, z+dz); - + glVertex3d (x+b*(u[0]), y+b*(u[1]), z+b*(u[2])); glVertex3d(x+dx, y+dy, z+dz); glEnd(); @@ -409,8 +408,8 @@ static void drawSimpleVector(int arrow, int fill, } -void drawContext::drawArrow3d(double x, double y, double z, - double dx, double dy, double dz, +void drawContext::drawArrow3d(double x, double y, double z, + double dx, double dy, double dz, double length, int light) { double zdir[3] = {0., 0., 1.}; @@ -423,7 +422,7 @@ void drawContext::drawArrow3d(double x, double y, double z, axis[1] = 1.; axis[2] = 0.; } - double phi = 180. * myacos(cosphi) / M_PI; + double phi = 180. * myacos(cosphi) / M_PI; if(light) glEnable(GL_LIGHTING); glPushMatrix(); @@ -544,13 +543,13 @@ void drawContext::drawBox(double xmin, double ymin, double zmin, if(labels){ char label[256]; double offset = 0.3 * CTX::instance()->glFontSize * pixel_equiv_x; - glRasterPos3d(xmin + offset / s[0], - ymin + offset / s[1], + glRasterPos3d(xmin + offset / s[0], + ymin + offset / s[1], zmin + offset / s[2]); sprintf(label, "(%g,%g,%g)", xmin, ymin, zmin); drawString(label); - glRasterPos3d(xmax + offset / s[0], - ymax + offset / s[1], + glRasterPos3d(xmax + offset / s[0], + ymax + offset / s[1], zmax + offset / s[2]); sprintf(label, "(%g,%g,%g)", xmax, ymax, zmax); drawString(label); @@ -590,7 +589,7 @@ void drawContext::drawPlaneInBoundingBox(double xmin, double ymin, double zmin, {5, 6, 7, 11}, {8, 9, 10, 11} }; - + double n[3] = {a,b,c}, ll = 50; norme(n); if(CTX::instance()->arrowRelStemRadius) @@ -639,7 +638,7 @@ void drawContext::drawPlaneInBoundingBox(double xmin, double ymin, double zmin, glNormal3d(n[0], n[1], n[2]); for(int j = 0; j < n_shade; j++){ glVertex3d(p_shade[j].x, p_shade[j].y, p_shade[j].z); - } + } glEnd(); glDisable(GL_LIGHTING); glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, twoside); diff --git a/Graphics/drawGraph2d.cpp b/Graphics/drawGraph2d.cpp index 92debefae2e9b4d42abe0c43dc4f40d344ffd756..ab90b8994c8e7ee445dbd75f369548a0ffffeb91 100644 --- a/Graphics/drawGraph2d.cpp +++ b/Graphics/drawGraph2d.cpp @@ -201,7 +201,7 @@ static bool getGraphData(PView *p, std::vector<double> &x, double &xmin, static void drawGraphAxes(drawContext *ctx, PView *p, double xleft, double ytop, double width, double height, double xmin, double xmax, - int tic, int overlay) + double tic, int overlay, bool inModelCoordinates) { PViewData *data = p->getData(); PViewOptions *opt = p->getOptions(); @@ -212,7 +212,7 @@ static void drawGraphAxes(drawContext *ctx, PView *p, double xleft, double ytop, if(width <= 0 || height <= 0) return; - if(!overlay){ + if(!overlay && !inModelCoordinates){ int alpha = CTX::instance()->unpackAlpha(opt->color.background2d); if(alpha != 0){ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -234,6 +234,12 @@ static void drawGraphAxes(drawContext *ctx, PView *p, double xleft, double ytop, // height above ref. point double font_a = font_h - drawContext::global()->getStringDescent(); + if(inModelCoordinates){ + double ss = ctx->pixel_equiv_x / ctx->s[0]; + font_h *= ss; + font_a *= ss; + } + glPointSize((float)CTX::instance()->pointSize); gl2psPointSize((float)(CTX::instance()->pointSize * CTX::instance()->print.epsPointSizeFactor)); @@ -339,8 +345,9 @@ static void drawGraphAxes(drawContext *ctx, PView *p, double xleft, double ytop, int nb = opt->axesTics[0]; char tmp[256]; sprintf(tmp, opt->axesFormat[0].c_str(), -M_PI * 1.e4); - if((nb - 1) * drawContext::global()->getStringWidth(tmp) > width) - nb = (int)(width / drawContext::global()->getStringWidth(tmp)) + 1; + double ww = drawContext::global()->getStringWidth(tmp); + if(inModelCoordinates) ww *= ctx->pixel_equiv_x / ctx->s[0]; + if((nb - 1) * ww > width) nb = (int)(width / ww) + 1; if(nb == 1) nb++; double dx = width / (double)(nb - 1); @@ -388,7 +395,7 @@ static void drawGraphAxes(drawContext *ctx, PView *p, double xleft, double ytop, static void addGraphPoint(drawContext *ctx, PView *p, double xleft, double ytop, double width, double height, double x, double y, double xmin, double xmax, double ymin, double ymax, - bool numeric, bool sphere) + bool numeric, bool sphere, bool inModelCoordinates) { PViewOptions *opt = p->getOptions(); @@ -415,8 +422,21 @@ static void addGraphPoint(drawContext *ctx, PView *p, double xleft, double ytop, sprintf(label, opt->format.c_str(), y); ctx->drawString(label); } - else if(sphere) - ctx->drawSphere(opt->pointSize, px, py, 0, 10, 10, opt->light); + else if(sphere){ + if(ctx->render_mode == drawContext::GMSH_SELECT){ + glPushName(4); + static int ii = 0; + glPushName(ii++); + } + if(inModelCoordinates) + ctx->drawSphere(opt->pointSize, px, py, 0, opt->light); + else + ctx->drawSphere(opt->pointSize, px, py, 0, 10, 10, opt->light); + if(ctx->render_mode == drawContext::GMSH_SELECT){ + glPopName(); + glPopName(); + } + } else glVertex2d(px, py); } @@ -425,7 +445,8 @@ static void addGraphPoint(drawContext *ctx, PView *p, double xleft, double ytop, static void drawGraphCurves(drawContext *ctx, PView *p, double xleft, double ytop, double width, double height, std::vector<double> &x, double xmin, double xmax, - std::vector<std::vector<double> > &y) + std::vector<std::vector<double> > &y, + bool inModelCoordinates) { if(width <= 0 || height <= 0) return; @@ -448,7 +469,8 @@ static void drawGraphCurves(drawContext *ctx, PView *p, double xleft, double yto glBegin(GL_LINE_STRIP); for(unsigned int j = 0; j < x.size(); j++) addGraphPoint(ctx, p, xleft, ytop, width, height, x[j], y[i][j], - xmin, xmax, opt->tmpMin, opt->tmpMax, false, false); + xmin, xmax, opt->tmpMin, opt->tmpMax, false, false, + inModelCoordinates); glEnd(); if(opt->useStipple){ glDisable(GL_LINE_STIPPLE); @@ -461,11 +483,13 @@ static void drawGraphCurves(drawContext *ctx, PView *p, double xleft, double yto opt->intervalsType == PViewOptions::Discrete || opt->intervalsType == PViewOptions::Numeric){ bool sphere = (opt->pointType == 1 || opt->pointType == 3); + if(!sphere) glBegin(GL_POINTS); for(unsigned int i = 0; i < y.size(); i++) for(unsigned int j = 0; j < x.size(); j++) addGraphPoint(ctx, p, xleft, ytop, width, height, x[j], y[i][j], - xmin, xmax, opt->tmpMin, opt->tmpMax, false, sphere); + xmin, xmax, opt->tmpMin, opt->tmpMax, false, sphere, + inModelCoordinates); if(!sphere) glEnd(); } @@ -473,12 +497,14 @@ static void drawGraphCurves(drawContext *ctx, PView *p, double xleft, double yto for(unsigned int i = 0; i < y.size(); i++) for(unsigned int j = 0; j < x.size(); j++) addGraphPoint(ctx, p, xleft, ytop, width, height, x[j], y[i][j], - xmin, xmax, opt->tmpMin, opt->tmpMax, true, false); + xmin, xmax, opt->tmpMin, opt->tmpMax, true, false, + inModelCoordinates); } } static void drawGraph(drawContext *ctx, PView *p, double xleft, double ytop, - double width, double height, int tic, int overlay=0) + double width, double height, double tic, int overlay=0, + bool inModelCoordinates=false) { std::vector<double> x; std::vector<std::vector<double> > y; @@ -511,11 +537,13 @@ static void drawGraph(drawContext *ctx, PView *p, double xleft, double ytop, opt->tmpMax = log10(opt->tmpMax); } - drawGraphAxes(ctx, p, xleft, ytop, width, height, xmin, xmax, tic, overlay); - drawGraphCurves(ctx, p, xleft, ytop, width, height, x, xmin, xmax, y); + drawGraphAxes(ctx, p, xleft, ytop, width, height, xmin, xmax, tic, overlay, + inModelCoordinates); + drawGraphCurves(ctx, p, xleft, ytop, width, height, x, xmin, xmax, y, + inModelCoordinates); } -void drawContext::drawGraph2d() +void drawContext::drawGraph2d(bool inModelCoordinates) { std::vector<PView*> graphs; for(unsigned int i = 0; i < PView::list.size(); i++){ @@ -529,8 +557,8 @@ void drawContext::drawGraph2d() drawContext::global()->setFont(CTX::instance()->glFontEnum, CTX::instance()->glFontSize); - const int tic = 5; // size of tic marks and interline - const int mx = 25, my = 5; // x- and y-margin + double tic = 5; // size of tic marks and interline + double mx = 25, my = 5; // x- and y-margin double xsep = 0., ysep = drawContext::global()->getStringHeight() + tic; char label[1024]; for(unsigned int i = 0; i < graphs.size(); i++){ @@ -540,6 +568,15 @@ void drawContext::drawGraph2d() } xsep += tic; + if(inModelCoordinates){ + double ss = pixel_equiv_x / s[0]; + tic *= ss; + mx *= ss; + my *= ss; + xsep *= ss; + ysep *= ss; + } + // +------------------winw-------------------+ // | my+3*ysep | // |mx+xsep+---w---+mx+2*xsep+---w---+mx+xsep| @@ -564,7 +601,15 @@ void drawContext::drawGraph2d() double y = viewport[1] + my + 3 * ysep; PView *p = graphs[i]; PViewOptions *opt = graphs[i]->getOptions(); - if(opt->autoPosition == 1){ // automatic + if(opt->autoPosition == 0 && !inModelCoordinates){ // manual + double x = opt->position[0], y = opt->position[1]; + int center = fix2dCoordinates(&x, &y); + drawGraph(this, p, + x - (center & 1 ? opt->size[0] / 2. : 0), + y + (center & 2 ? opt->size[1] / 2. : 0), + opt->size[0], opt->size[1], tic); + } + else if(opt->autoPosition == 1 && !inModelCoordinates){ // automatic if(graphs.size() == 1){ double w = winw - 2 * mx - 2 * xsep; double h = winh - 2 * my - 7 * ysep; @@ -584,7 +629,7 @@ void drawContext::drawGraph2d() drawGraph(this, p, x, viewport[3] - y, w, h, tic); } } - else if(opt->autoPosition >= 2 && opt->autoPosition <= 11){ + else if(opt->autoPosition >= 2 && opt->autoPosition <= 11 && !inModelCoordinates){ // top left (2), top right (3), bottom left (4), bottom right (5), top // half (6), bottom half (7), left half (8), right half (9), full (10), // top third (11) @@ -607,13 +652,9 @@ void drawContext::drawGraph2d() if(opt->axes) overlay[opt->autoPosition] += (opt->axesLabel[0].size() ? 2 : 1); } - else{ // manual - double x = opt->position[0], y = opt->position[1]; - int center = fix2dCoordinates(&x, &y); - drawGraph(this, p, - x - (center & 1 ? opt->size[0] / 2. : 0), - y + (center & 2 ? opt->size[1] / 2. : 0), - opt->size[0], opt->size[1], tic); + else if(opt->autoPosition == 12 && inModelCoordinates){ // in model coordinates + drawGraph(this, p, opt->position[0], opt->position[1] + opt->size[1], + opt->size[0], opt->size[1], tic, 0, true); } } } diff --git a/Post/PViewOptions.h b/Post/PViewOptions.h index 622c8411125bd10c900ca8fbb55919f6e54712fa..2b126c908e85aff6bb1da8b87b9d842778773f05 100644 --- a/Post/PViewOptions.h +++ b/Post/PViewOptions.h @@ -57,8 +57,8 @@ class PViewOptions { DoubleLogarithmic = 3 }; - int type; - int position[2], size[2], autoPosition; + int type, autoPosition; + double position[2], size[2]; std::string format; int axes, axesAutoPosition, axesMikado; double axesTics[3];