Skip to content
Snippets Groups Projects
Commit c7272ef3 authored by Maxime Graulich's avatar Maxime Graulich
Browse files

mobile: center model

parent f3675995
No related branches found
No related tags found
No related merge requests found
...@@ -170,11 +170,20 @@ void drawContext::OrthofFromGModel() ...@@ -170,11 +170,20 @@ void drawContext::OrthofFromGModel()
{ {
SBoundingBox3d bb = GModel::current()->bounds(); SBoundingBox3d bb = GModel::current()->bounds();
double ratio = (double)(this->_width ? this->_width : 1.) / (double)(this->_height ? this->_height : 1.); double ratio = (double)(this->_width ? this->_width : 1.) / (double)(this->_height ? this->_height : 1.);
double bbRation = (bb.max().x() - bb.min().x()) / (bb.max().y() - bb.min().y());
double xmin = -ratio, xmax = ratio, ymin = -1., ymax = 1.; double xmin = -ratio, xmax = ratio, ymin = -1., ymax = 1.;
xmin = bb.min().x(); if(bbRation < 1) {
xmax = bb.max().x(); xmin = bb.min().y() * ratio + bb.max().x() + bb.min().x();
ymin = bb.min().x() / ratio; xmax = bb.max().y() * ratio + bb.max().x() + bb.min().x();
ymax = bb.max().x() / ratio; ymin = bb.min().y() + bb.max().y() + bb.min().y();
ymax = bb.max().y() + bb.max().y() + bb.min().y();
}
else {
xmin = bb.min().x() + bb.max().x() + bb.min().x();
xmax = bb.max().x() + bb.max().x() + bb.min().x();
ymin = bb.min().x() / ratio + bb.max().y() + bb.min().y();
ymax = bb.max().x() / ratio + bb.max().y() + bb.min().y();
}
xmax += (xmax - xmin) / 5.; xmax += (xmax - xmin) / 5.;
xmin -= (xmax - xmin) / 5.; xmin -= (xmax - xmin) / 5.;
ymax += (ymax - ymin) / 5.; ymax += (ymax - ymin) / 5.;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment