Skip to content
Snippets Groups Projects
Commit b671bb6f authored by Gilles Marckmann's avatar Gilles Marckmann
Browse files

Add toggle for compatible mode. Does not export scale bars in case of...

Add toggle for compatible mode. Does not export scale bars in case of compatibility mode : usefull for MeshLab for instance.
Otherwise, scales bar are exported (compatible with view3Dscene). 
parent 3e837f72
No related branches found
No related tags found
No related merge requests found
......@@ -1584,6 +1584,7 @@ int x3dViewFileDialog(const char *name, const char *title, int format)
Fl_Choice *c[1];
Fl_Choice *d[1];
Fl_Value_Input *input[2];
Fl_Check_Button *e;
Fl_Button *ok, *cancel;
};
static _viewFileDialog *dialog = NULL;
......@@ -1604,7 +1605,7 @@ int x3dViewFileDialog(const char *name, const char *title, int format)
if(!dialog){
dialog = new _viewFileDialog;
int h = 6 * WB + 5 * BH, w = 2 * BBB + BBB / 3 + 12 * WB , y = WB;
int h = 7 * WB + 6 * BH, w = 2 * BBB + BBB / 3 + 12 * WB , y = WB;
dialog->window = new Fl_Double_Window(w, h);
dialog->window->box(GMSH_WINDOW_BOX);
dialog->window->set_modal();
......@@ -1622,6 +1623,7 @@ int x3dViewFileDialog(const char *name, const char *title, int format)
dialog->input[1]->minimum(0.);
dialog->input[1]->maximum(1.);
dialog->input[1]->step(0.05);
dialog->e = new Fl_Check_Button (WB, y, w - 2 * WB , BH, "High compatibility (no scale bar)"); y += BH;
dialog->ok = new Fl_Return_Button( WB , y , BBB, BH, "OK");
dialog->cancel = new Fl_Button ( 2 * WB + BBB, y , BBB, BH, "Cancel");
dialog->window->end();
......@@ -1634,7 +1636,8 @@ int x3dViewFileDialog(const char *name, const char *title, int format)
dialog->input[0]->align(FL_ALIGN_RIGHT);
dialog->input[1]->value( PView::getTransparencyValue() );
dialog->input[1]->align(FL_ALIGN_RIGHT);
dialog->e->type(FL_TOGGLE_BUTTON);
dialog->e->value(PView::getX3dCompatibility() );
while(dialog->window->shown()){
Fl::wait();
for (;;) {
......@@ -1642,6 +1645,7 @@ int x3dViewFileDialog(const char *name, const char *title, int format)
if (!o) break;
if (o == dialog->ok) {
dialog->d[0]->value()==1 ? PView::setInnerBorder(true) : PView::setInnerBorder(false) ;
dialog->e->value()==1 ? PView::setX3dCompatibility(true) : PView::setX3dCompatibility(false) ;
PView::setTransparencyValue( dialog->input[1]->value() );
PView::setPrecisionValue( dialog->input[0]->value() );
......
......@@ -16,6 +16,7 @@
int PView::_globalTag = 0;
bool PView::_removeInnerBorders = false;
bool PView::_x3dCompatibility = false;
double PView::_transparency=0.;
double PView::_precision=pow(10.,-9.);
std::vector<PView*> PView::list;
......
......@@ -69,7 +69,10 @@ class PView{
// precision for inner border deletion in x3d output
static double _precision;
static bool _x3dCompatibility;
// get/set global tag
static double getX3dCompatibility() { return _x3dCompatibility ; }
static void setX3dCompatibility ( bool br){ _x3dCompatibility = br; }
static double getTransparencyValue() { return _transparency ; }
static void setTransparencyValue( double tr){ _transparency = tr; }
static double getPrecisionValue() { return log10( _precision ) ; }
......
......@@ -176,6 +176,24 @@ bool PView::writeX3D(const std::string &fileName )
fprintf(fp," <Background skyColor='.7 .7 1'/> \n");
//****************
// HUD : Head Up Display
// here contour/scalebar legends in frame (-.45,-.28, 0.) and (.45, .28,0.) : viewport .9 x .56
double viewportWidth =.9 ;
double viewportHeight =.56 ;
double font_size = 0.02;
if ( !getX3dCompatibility() ) {
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()
)
scales.push_back(PView::list[i]);
}
if ( !scales.empty() ){
fprintf(fp," <ProtoDeclare appinfo='Heads-up display (HUD)' name='HeadsUpDisplay'> \n");
fprintf(fp," <ProtoInterface> \n");
fprintf(fp," <field accessType='inputOutput' appinfo='offset position for HUD' name='screenOffset' type='SFVec3f' value='%g %g %g'/> \n", _center.x(), _center.y() , 5*_center.z()+_diagonal*1.2 );
......@@ -209,7 +227,7 @@ bool PView::writeX3D(const std::string &fileName )
fprintf(fp," </Group> \n");
fprintf(fp," </ProtoBody> \n");
fprintf(fp," </ProtoDeclare> \n");
fprintf(fp," <Background skyColor='.7 .7 1'/> \n");
// fprintf(fp," <Background skyColor='.7 .7 1'/> \n");
fprintf(fp," <Viewpoint description='Book View' orientation='0 0. 1. 0.' position='%g %g %g'/> \n", _center.x(), _center.y() , _center.z()+_diagonal*1.2 );
fprintf(fp," <!-- ProtoDeclare is the \"cookie cutter\" template, ProtoInstance creates an actual occurrence --> \n");
fprintf(fp," <ProtoInstance DEF='HeadsUpDisplay' name='HeadsUpDisplay'> \n");
......@@ -218,21 +236,6 @@ bool PView::writeX3D(const std::string &fileName )
fprintf(fp," <fieldValue name='children'> \n");
// here contour/scalebar legends in frame (-.45,-.28, 0.) and (.45, .28,0.) : viewport .9 x .56
double viewportWidth =.9 ;
double viewportHeight =.56 ;
double font_size = 0.02;
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()
)
scales.push_back(PView::list[i]);
}
if(!scales.empty()) {
char label[1024];
double maxw = 10.*font_size*3./4.;
const double tic = viewportWidth/100 ;
......@@ -302,11 +305,10 @@ bool PView::writeX3D(const std::string &fileName )
if(i % 2) width_total += std::max(bar_size + width, bar_size + width_prev);
}
}
}
fprintf(fp," </fieldValue> \n");
fprintf(fp," </ProtoInstance> \n");
} // if ( !scales.empty() )
} // if ( !getX3dCompatibility()
// geometrical objects
VertexArray *va;
......@@ -725,7 +727,7 @@ static void writeX3DStringCenter( FILE *fp,char *label,double x, double y, doubl
fprintf(fp," <Transform translation='%g %g %g'> \n",x,y,0.);
fprintf(fp," <Shape> \n");
fprintf(fp," <Text string='\"%s\"'>\n",label);
fprintf(fp," <FontStyle justify='\"MIDDLE\" \"MIDDLE\"' size=' %g '/> \n",font_size);
fprintf(fp," <FontStyle justify='\"MIDDLE\" \"MIDDLE\"' size=' %d '/> \n",font_size);
fprintf(fp," </Text>\n");
fprintf(fp," <Appearance>\n");
fprintf(fp," <Material diffuseColor='0. 0. 0. '/>\n");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment