Skip to content

Commit

Permalink
Merge pull request OpenVSP#4 from ramcdona/master
Browse files Browse the repository at this point in the history
Fixes and version bump to 2.0.2.
  • Loading branch information
Rob McDonald committed Feb 22, 2012
2 parents 4408bd1 + d80a431 commit 7b37d54
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 34 deletions.
3 changes: 2 additions & 1 deletion examples/setup/VspPreferences.xml
Expand Up @@ -18,7 +18,8 @@
</OutputName> </OutputName>
</Vsp_OutputNames> </Vsp_OutputNames>
<WindowManagerStyle>1</WindowManagerStyle> <WindowManagerStyle>1</WindowManagerStyle>
<DefaultComponentFileID>0</DefaultComponentFileID> <AutoSaveInterval>180</AutoSaveInterval>
<DefaultComponentFileID>1</DefaultComponentFileID>
<DefaultComponentFileList> <DefaultComponentFileList>
<DefaultComponentFile> <DefaultComponentFile>
<Name>BWB</Name> <Name>BWB</Name>
Expand Down
1 change: 1 addition & 0 deletions src/vsp/VspPreferences.cpp
Expand Up @@ -102,6 +102,7 @@ VspPreferences::VspPreferences()
} }


windowMgrStyle = xmlFindInt(root, "WindowManagerStyle", 0); windowMgrStyle = xmlFindInt(root, "WindowManagerStyle", 0);
autoSaveInterval = xmlFindInt(root, "AutoSaveInterval", 180);


} }


Expand Down
1 change: 1 addition & 0 deletions src/vsp/VspPreferences.h
Expand Up @@ -51,6 +51,7 @@ class VspPreferences
int getNumOutputNames() { return outputNameVec.size(); } int getNumOutputNames() { return outputNameVec.size(); }
Stringc getOutputName(int i); Stringc getOutputName(int i);
int windowMgrStyle; int windowMgrStyle;
int autoSaveInterval;


int getDefaultCompFileID() { return m_DefaultCompFileID; } int getDefaultCompFileID() { return m_DefaultCompFileID; }
void setDefaultCompFileID( int id ); void setDefaultCompFileID( int id );
Expand Down
20 changes: 14 additions & 6 deletions src/vsp/aircraft.cpp
Expand Up @@ -474,17 +474,20 @@ void Aircraft::reorderGeom( int action )


} }


void Aircraft::writeFile( const char* file_name ) void Aircraft::writeFile( const char* file_name, bool restore_file_name )
{ {
vector< Geom* > gVec = geomVec; vector< Geom* > gVec = geomVec;
gVec.push_back( getUserGeom() ); gVec.push_back( getUserGeom() );
writeFile( file_name, gVec, labelVec ); writeFile( file_name, gVec, labelVec, restore_file_name );
} }


void Aircraft::writeFile( const char* file_name, vector< Geom * > &gVec, vector< LabelGeom * > &lVec ) void Aircraft::writeFile( const char* file_name, vector< Geom * > &gVec, vector< LabelGeom * > &lVec, bool restore_file_name )
{ {
fileName = file_name; if ( !restore_file_name )
setTempDir( fileName, false ); {
fileName = file_name;
setTempDir( fileName, false );
}


xmlDocPtr doc = xmlNewDoc((const xmlChar *)"1.0"); xmlDocPtr doc = xmlNewDoc((const xmlChar *)"1.0");


Expand Down Expand Up @@ -3354,9 +3357,14 @@ void Aircraft::updateExportFileNames()
void Aircraft::setTempDir( const char* fn, bool user_set ) void Aircraft::setTempDir( const char* fn, bool user_set )
{ {
Stringc dirString = fn; Stringc dirString = fn;

int dirLen = dirString.get_length();
for (int i=0; i<dirLen; i++) {
if ( dirString[i] == '\\' ) dirString[i] = '/';
}

if ( dirString.count_substrings( "/" ) >= 1 ) if ( dirString.count_substrings( "/" ) >= 1 )
{ {
int dirLen = dirString.get_length();
int slashLoc = dirLen-1; int slashLoc = dirLen-1;


while ( slashLoc > 0 ) while ( slashLoc > 0 )
Expand Down
4 changes: 2 additions & 2 deletions src/vsp/aircraft.h
Expand Up @@ -82,8 +82,8 @@ class Aircraft
VSPDLL int openFile( const char* file_name ); VSPDLL int openFile( const char* file_name );
int insertFile( const char* file_name ); int insertFile( const char* file_name );


void writeFile( const char* file_name ); void writeFile( const char* file_name , bool restore_file_name = false );
void writeFile( const char* file_name, vector< Geom * > &gVec, vector< LabelGeom * > &lVec ); void writeFile( const char* file_name, vector< Geom * > &gVec, vector< LabelGeom * > &lVec, bool restore_file_name = false );
int readFile( const char* file_name ); int readFile( const char* file_name );
int readOldRamFile ( const char* file_name ); int readOldRamFile ( const char* file_name );


Expand Down
23 changes: 11 additions & 12 deletions src/vsp/geom.cpp
Expand Up @@ -2852,17 +2852,7 @@ int XSecGeom::read_xsec( const char* file_name )
} }
fclose(fp); fclose(fp);


surfVec.clear(); generate();
for ( int i = 0 ; i < (int)xsecCompVec.size() ; i++ )
{
xsecCompVec[i].load_refl_pnts_xsecs();
xsecCompVec[i].load_hidden_surf();
xsecCompVec[i].load_normals();
xsecCompVec[i].load_uw();
surfVec.push_back( &xsecCompVec[i] );
}

update_bbox();


return 1; return 1;
} }
Expand Down Expand Up @@ -2943,7 +2933,16 @@ void XSecGeom::LoadLinkableParms( vector< Parm* > & parmVec )


void XSecGeom::generate() void XSecGeom::generate()
{ {
update_bbox(); surfVec.clear();
for ( int i = 0 ; i < (int)xsecCompVec.size() ; i++ )
{
xsecCompVec[i].load_refl_pnts_xsecs();
xsecCompVec[i].load_hidden_surf();
xsecCompVec[i].load_normals();
xsecCompVec[i].load_uw();
surfVec.push_back( &xsecCompVec[i] );
}
update_bbox();
} }


void XSecGeom::computeCenter() void XSecGeom::computeCenter()
Expand Down
9 changes: 5 additions & 4 deletions src/vsp/main.cpp
Expand Up @@ -33,6 +33,7 @@
#include "scriptMgr.h" #include "scriptMgr.h"
#include "FeaMeshMgr.h" #include "FeaMeshMgr.h"
#include "CfdMeshMgr.h" #include "CfdMeshMgr.h"
#include "VspPreferences.h"


// Include OpenNurbs for Rhino Dump // Include OpenNurbs for Rhino Dump
// ON Needs to be undefined for it to compile // ON Needs to be undefined for it to compile
Expand Down Expand Up @@ -558,17 +559,16 @@ void vsp_exit()
} }




#define AUTO_SAVE_TIME (180)
void autoSaveTimeoutHandler(void *data) void autoSaveTimeoutHandler(void *data)
{ {
if ( airPtr ) if ( airPtr )
{ {
Stringc backupfn = airPtr->getTempDir(); Stringc backupfn = airPtr->getTempDir();
backupfn.concatenate("vsp_autobackup.vsp"); backupfn.concatenate("vsp_autobackup.vsp");
airPtr->writeFile(backupfn.get_char_star()); airPtr->writeFile(backupfn.get_char_star(), true);
} }


Fl::repeat_timeout(AUTO_SAVE_TIME, autoSaveTimeoutHandler, data ); Fl::repeat_timeout(VspPreferences::Instance()->autoSaveInterval, autoSaveTimeoutHandler, data );
} }




Expand Down Expand Up @@ -615,7 +615,8 @@ int main( int argc, char** argv)
} }
else else
{ {
Fl::add_timeout( AUTO_SAVE_TIME, autoSaveTimeoutHandler, airPtr ); if (VspPreferences::Instance()->autoSaveInterval > 0)
Fl::add_timeout( VspPreferences::Instance()->autoSaveInterval, autoSaveTimeoutHandler, airPtr );
screenMgrPtr->showGui( argc-1, argv ); screenMgrPtr->showGui( argc-1, argv );
} }


Expand Down
6 changes: 3 additions & 3 deletions src/vsp/main.h
Expand Up @@ -10,9 +10,9 @@
#ifndef main_h #ifndef main_h
#define main_h #define main_h


#define VSPVERSION1 "Vehicle Sketch Pad 2.0.1" #define VSPVERSION1 "Vehicle Sketch Pad 2.0.2"
#define VSPVERSION2 "OpenVSP 2.0.1 - 2/2/12" #define VSPVERSION2 "OpenVSP 2.0.2 - 2/21/12"
#define VSPVERSION3 "OpenVSP 2.0.1 : Vehicle Sketch Pad" #define VSPVERSION3 "OpenVSP 2.0.2 : Vehicle Sketch Pad"


void vsp_exit(); void vsp_exit();


Expand Down
23 changes: 17 additions & 6 deletions src/vsp/vspGlWindow.cpp
Expand Up @@ -322,12 +322,16 @@ void VirtGlWindow::mouseDrag( int mx, int my )
if ( !showFlag ) if ( !showFlag )
return; return;


if ( (Fl::event_state(FL_BUTTON1) && Fl::event_button3() ) || Fl::event_state(FL_BUTTON2) ) if ( (Fl::event_state(FL_BUTTON1) && Fl::event_button3() ) ||
(Fl::event_state(FL_BUTTON1) && Fl::event_ctrl() ) ||
(Fl::event_state(FL_BUTTON1) && Fl::event_state(FL_META) ) ||
Fl::event_state(FL_BUTTON2) )
currTrack.poll( SCALE, mx-wx, my-wy ); currTrack.poll( SCALE, mx-wx, my-wy );
else if ( Fl::event_state(FL_BUTTON3 ) ||
(Fl::event_state(FL_BUTTON1) && Fl::event_alt()))
currTrack.poll( TRANSLATE, mx-wx, my-wy );
else if ( Fl::event_state(FL_BUTTON1 ) ) else if ( Fl::event_state(FL_BUTTON1 ) )
currTrack.poll( ROTATE, mx-wx, my-wy ); currTrack.poll( ROTATE, mx-wx, my-wy );
else if ( Fl::event_state(FL_BUTTON3 ) )
currTrack.poll( TRANSLATE, mx-wx, my-wy );


} }


Expand Down Expand Up @@ -433,15 +437,22 @@ Fl_Gl_Window(x,y,w,h,"Vsp GL Window")
vWin[TWO_LOW] = new VirtGlWindow( 0, h/2, w, h/2 ); vWin[TWO_LOW] = new VirtGlWindow( 0, h/2, w, h/2 );


//==== Set Up Initial Viewing Angles ====// //==== Set Up Initial Viewing Angles ====//
vWin[FOUR_LOW_L]->currTrack.set_init_angle(PI/2.0, 0.0, 0.0); //vWin[FOUR_LOW_L]->currTrack.set_init_angle(PI/2.0, 0.0, 0.0);
vWin[FOUR_LOW_L]->currTrack.set_init_angle(PI/2.0, -PI/2.0, 0.0);
vWin[FOUR_LOW_L]->currTrack.init(); vWin[FOUR_LOW_L]->currTrack.init();


vWin[FOUR_UP_R]->currTrack.set_init_angle(PI/2.0, -PI/2.0, 0.0); //vWin[FOUR_UP_R]->currTrack.set_init_angle(PI/2.0, -PI/2.0, 0.0);
vWin[FOUR_UP_R]->currTrack.set_init_angle(PI/4.0, -PI/6.0, -PI/6.0);
vWin[FOUR_UP_R]->currTrack.init(); vWin[FOUR_UP_R]->currTrack.init();


vWin[FOUR_LOW_R]->currTrack.set_init_angle(PI/4.0, -PI/6.0, -PI/6.0); //vWin[FOUR_LOW_R]->currTrack.set_init_angle(PI/4.0, -PI/6.0, -PI/6.0);
vWin[FOUR_LOW_R]->currTrack.set_init_angle(PI/2.0, 0.0, 0.0);
vWin[FOUR_LOW_R]->currTrack.init(); vWin[FOUR_LOW_R]->currTrack.init();


//vWin[FOUR_UP_L]->currTrack.set_init_angle(0.0, 0.0, 0.0);
vWin[FOUR_UP_L]->currTrack.set_init_angle(0.0, 0.0, -PI/2.0);
vWin[FOUR_UP_L]->currTrack.init();

vWin[TWO_L]->currTrack.set_init_angle(0.0, 0.0, PI/2.0); vWin[TWO_L]->currTrack.set_init_angle(0.0, 0.0, PI/2.0);
vWin[TWO_L]->currTrack.init(); vWin[TWO_L]->currTrack.init();


Expand Down

0 comments on commit 7b37d54

Please sign in to comment.