← Back to team overview

yade-dev team mailing list archive

[svn] r1501 - in trunk: core gui gui/qt3

 

Author: cosurgi
Date: 2008-09-02 17:52:37 +0200 (Tue, 02 Sep 2008)
New Revision: 1501

Modified:
   trunk/core/NullGUI.cpp
   trunk/gui/SConscript
   trunk/gui/qt3/GLViewer.cpp
   trunk/gui/qt3/GLViewer.hpp
   trunk/gui/qt3/QtGeneratedSimulationController.ui
   trunk/gui/qt3/SimulationController.cpp
   trunk/gui/qt3/SimulationController.hpp
   trunk/gui/qt3/YadeQtMainWindow.cpp
   trunk/gui/qt3/YadeQtMainWindow.hpp
Log:
add to SimulationController buttons for looking in different directions. The default view direction is now down along the direction of gravity.



Modified: trunk/core/NullGUI.cpp
===================================================================
--- trunk/core/NullGUI.cpp	2008-09-02 03:51:24 UTC (rev 1500)
+++ trunk/core/NullGUI.cpp	2008-09-02 15:52:37 UTC (rev 1501)
@@ -50,7 +50,8 @@
 \n\
     input:\n\
 	-f name		- specify filename to load, or filegenerator configuration file\n\
-			  (if a filegenerator then it must be the)\n\
+			  (if a filegenerator then it must be a last parameter\n\
+			  and multiple filegenerators are allowed)\n\
 \n\
     output:\n\
 	-s number	- if specified, a snapshot is saved every 'number'\n\

Modified: trunk/gui/SConscript
===================================================================
--- trunk/gui/SConscript	2008-09-02 03:51:24 UTC (rev 1500)
+++ trunk/gui/SConscript	2008-09-02 15:52:37 UTC (rev 1501)
@@ -29,6 +29,7 @@
 				'yade-serialization',
 				'XMLFormatManager',
 				'yade-serialization-qt',
+				'GravityEngines',
 				'OpenGLRenderingEngine',
 				'PositionOrientationRecorder',
 				'sqlite3x',

Modified: trunk/gui/qt3/GLViewer.cpp
===================================================================
--- trunk/gui/qt3/GLViewer.cpp	2008-09-02 03:51:24 UTC (rev 1500)
+++ trunk/gui/qt3/GLViewer.cpp	2008-09-02 15:52:37 UTC (rev 1501)
@@ -169,6 +169,8 @@
 
 void GLViewer::keyPressEvent(QKeyEvent *e)
 {
+	last_user_event = boost::posix_time::second_clock::local_time();
+
 	if(false){}
 	/* special keys: Escape and Space */
 	else if(e->key()==Qt::Key_Escape){ resetManipulation(); displayMessage("Manipulating scene."); }
@@ -496,12 +498,24 @@
 	YadeQtMainWindow::self->closeView(this);
 }
 
+void GLViewer::mouseMoveEvent(QMouseEvent *e){
+	last_user_event = boost::posix_time::second_clock::local_time();
+	QGLViewer::mouseMoveEvent(e);
+}
+
+void GLViewer::mousePressEvent(QMouseEvent *e){
+	last_user_event = boost::posix_time::second_clock::local_time();
+	QGLViewer::mousePressEvent(e);
+}
+
 /* Handle double-click event; if clipping plane is manipulated, align it with the global coordinate system.
  * Otherwise pass the event to QGLViewer to handle it normally.
  *
  * mostly copied over from ManipulatedFrame::mouseDoubleClickEvent
  */
 void GLViewer::mouseDoubleClickEvent(QMouseEvent *event){
+	last_user_event = boost::posix_time::second_clock::local_time();
+
 	if(manipulatedClipPlane<0) { /* LOG_DEBUG("Double click not on clipping plane"); */ QGLViewer::mouseDoubleClickEvent(event); return; }
 #if QT_VERSION >= 0x040000
 	if (event->modifiers() == Qt::NoModifier)
@@ -516,6 +530,8 @@
 }
 
 void GLViewer::wheelEvent(QWheelEvent* event){
+	last_user_event = boost::posix_time::second_clock::local_time();
+
 	if(manipulatedClipPlane<0){ QGLViewer::wheelEvent(event); return; }
 	assert(manipulatedClipPlane<renderer->clipPlaneNum);
 	float distStep=1e-3*sceneRadius();
@@ -554,3 +570,5 @@
 	}
 }
 
+boost::posix_time::ptime GLViewer::getLastUserEvent(){return last_user_event;};
+

Modified: trunk/gui/qt3/GLViewer.hpp
===================================================================
--- trunk/gui/qt3/GLViewer.hpp	2008-09-02 03:51:24 UTC (rev 1500)
+++ trunk/gui/qt3/GLViewer.hpp	2008-09-02 15:52:37 UTC (rev 1501)
@@ -6,6 +6,7 @@
 #include<yade/pkg-common/OpenGLRenderingEngine.hpp>
 #include<yade/lib-QGLViewer/qglviewer.h>
 #include<yade/lib-QGLViewer/constraint.h>
+#include <boost/date_time/posix_time/posix_time.hpp>
 #include<set>
 
 /*! Class handling user interaction with the openGL rendering of simulation.
@@ -47,6 +48,7 @@
 		set<int> boundClipPlanes;
 		shared_ptr<qglviewer::LocalConstraint> xyPlaneConstraint;
 		string strBoundGroup(){string ret;FOREACH(int i, boundClipPlanes) ret+=" "+lexical_cast<string>(i+1);return ret;}
+		boost::posix_time::ptime last_user_event;
 
      public :
 
@@ -82,7 +84,9 @@
 		void initFromDOMElement(const QDomElement& element);
 		int viewId;
 
+		boost::posix_time::ptime getLastUserEvent();
 
+
 		DECLARE_LOGGER;
 	protected :
 		virtual void keyPressEvent(QKeyEvent *e);
@@ -92,4 +96,6 @@
 		virtual void endSelection(const QPoint &point);
 		virtual void mouseDoubleClickEvent(QMouseEvent *e);
 		virtual void wheelEvent(QWheelEvent* e);
+		virtual void mouseMoveEvent(QMouseEvent *e);
+		virtual void mousePressEvent(QMouseEvent *e);
 };

Modified: trunk/gui/qt3/QtGeneratedSimulationController.ui
===================================================================
--- trunk/gui/qt3/QtGeneratedSimulationController.ui	2008-09-02 03:51:24 UTC (rev 1500)
+++ trunk/gui/qt3/QtGeneratedSimulationController.ui	2008-09-02 15:52:37 UTC (rev 1501)
@@ -8,8 +8,8 @@
         <rect>
             <x>0</x>
             <y>0</y>
-            <width>261</width>
-            <height>470</height>
+            <width>269</width>
+            <height>519</height>
         </rect>
     </property>
     <property name="sizePolicy">
@@ -38,90 +38,98 @@
         </property>
         <widget class="QLayoutWidget" row="0" column="0">
             <property name="name">
-                <cstring>layout11</cstring>
+                <cstring>layout9</cstring>
             </property>
+            <vbox>
+                <property name="name">
+                    <cstring>unnamed</cstring>
+                </property>
+                <property name="spacing">
+                    <number>0</number>
+                </property>
+                <widget class="QLabel">
+                    <property name="name">
+                        <cstring>labelRealTime</cstring>
+                    </property>
+                    <property name="sizePolicy">
+                        <sizepolicy>
+                            <hsizetype>5</hsizetype>
+                            <vsizetype>0</vsizetype>
+                            <horstretch>0</horstretch>
+                            <verstretch>0</verstretch>
+                        </sizepolicy>
+                    </property>
+                    <property name="text">
+                        <string>real 0:00:00.000</string>
+                    </property>
+                </widget>
+                <widget class="QLabel">
+                    <property name="name">
+                        <cstring>labelSimulTime</cstring>
+                    </property>
+                    <property name="sizePolicy">
+                        <sizepolicy>
+                            <hsizetype>5</hsizetype>
+                            <vsizetype>0</vsizetype>
+                            <horstretch>0</horstretch>
+                            <verstretch>0</verstretch>
+                        </sizepolicy>
+                    </property>
+                    <property name="text">
+                        <string>virt 00:000.000m000u000n</string>
+                    </property>
+                </widget>
+                <widget class="QLabel">
+                    <property name="name">
+                        <cstring>labelIter</cstring>
+                    </property>
+                    <property name="sizePolicy">
+                        <sizepolicy>
+                            <hsizetype>5</hsizetype>
+                            <vsizetype>0</vsizetype>
+                            <horstretch>0</horstretch>
+                            <verstretch>0</verstretch>
+                        </sizepolicy>
+                    </property>
+                    <property name="text">
+                        <string>iter #0, 0/s</string>
+                    </property>
+                </widget>
+                <widget class="QLabel">
+                    <property name="name">
+                        <cstring>labelStep</cstring>
+                    </property>
+                    <property name="sizePolicy">
+                        <sizepolicy>
+                            <hsizetype>5</hsizetype>
+                            <vsizetype>0</vsizetype>
+                            <horstretch>0</horstretch>
+                            <verstretch>0</verstretch>
+                        </sizepolicy>
+                    </property>
+                    <property name="text">
+                        <string>step 4e-3</string>
+                    </property>
+                </widget>
+            </vbox>
+        </widget>
+        <widget class="QLayoutWidget" row="1" column="0">
+            <property name="name">
+                <cstring>layout12</cstring>
+            </property>
             <grid>
                 <property name="name">
                     <cstring>unnamed</cstring>
                 </property>
-                <widget class="QLayoutWidget" row="0" column="0">
+                <widget class="QPushButton" row="1" column="1">
                     <property name="name">
-                        <cstring>layout9</cstring>
+                        <cstring>pbReference</cstring>
                     </property>
-                    <vbox>
-                        <property name="name">
-                            <cstring>unnamed</cstring>
-                        </property>
-                        <property name="spacing">
-                            <number>0</number>
-                        </property>
-                        <widget class="QLabel">
-                            <property name="name">
-                                <cstring>labelRealTime</cstring>
-                            </property>
-                            <property name="sizePolicy">
-                                <sizepolicy>
-                                    <hsizetype>5</hsizetype>
-                                    <vsizetype>0</vsizetype>
-                                    <horstretch>0</horstretch>
-                                    <verstretch>0</verstretch>
-                                </sizepolicy>
-                            </property>
-                            <property name="text">
-                                <string>real 0:00:00.000</string>
-                            </property>
-                        </widget>
-                        <widget class="QLabel">
-                            <property name="name">
-                                <cstring>labelSimulTime</cstring>
-                            </property>
-                            <property name="sizePolicy">
-                                <sizepolicy>
-                                    <hsizetype>5</hsizetype>
-                                    <vsizetype>0</vsizetype>
-                                    <horstretch>0</horstretch>
-                                    <verstretch>0</verstretch>
-                                </sizepolicy>
-                            </property>
-                            <property name="text">
-                                <string>virt 00:000.000m000u000n</string>
-                            </property>
-                        </widget>
-                        <widget class="QLabel">
-                            <property name="name">
-                                <cstring>labelIter</cstring>
-                            </property>
-                            <property name="sizePolicy">
-                                <sizepolicy>
-                                    <hsizetype>5</hsizetype>
-                                    <vsizetype>0</vsizetype>
-                                    <horstretch>0</horstretch>
-                                    <verstretch>0</verstretch>
-                                </sizepolicy>
-                            </property>
-                            <property name="text">
-                                <string>iter #0, 0/s</string>
-                            </property>
-                        </widget>
-                        <widget class="QLabel">
-                            <property name="name">
-                                <cstring>labelStep</cstring>
-                            </property>
-                            <property name="sizePolicy">
-                                <sizepolicy>
-                                    <hsizetype>5</hsizetype>
-                                    <vsizetype>0</vsizetype>
-                                    <horstretch>0</horstretch>
-                                    <verstretch>0</verstretch>
-                                </sizepolicy>
-                            </property>
-                            <property name="text">
-                                <string>step 4e-3</string>
-                            </property>
-                        </widget>
-                    </vbox>
+                    <property name="text">
+                        <string>Reference</string>
+                    </property>
                 </widget>
-                <widget class="QTabWidget" row="1" column="0">
+                <widget class="QTabWidget" row="0" column="0" rowspan="1" colspan="3">
                     <property name="name">
                         <cstring>tabWidget</cstring>
                     </property>
@@ -626,59 +634,125 @@
                         </grid>
                     </widget>
                 </widget>
-                <widget class="QLayoutWidget" row="2" column="0">
+                <widget class="QPushButton" row="2" column="0">
                     <property name="name">
-                        <cstring>layout8</cstring>
+                        <cstring>pbXYZ</cstring>
                     </property>
-                    <grid>
-                        <property name="name">
-                            <cstring>unnamed</cstring>
-                        </property>
-                        <widget class="QPushButton" row="0" column="1">
-                            <property name="name">
-                                <cstring>pbReference</cstring>
-                            </property>
-                            <property name="text">
-                                <string>Reference</string>
-                            </property>
-                        </widget>
-                        <widget class="QPushButton" row="0" column="2">
-                            <property name="name">
-                                <cstring>pbCenterScene_2</cstring>
-                            </property>
-                            <property name="sizePolicy">
-                                <sizepolicy>
-                                    <hsizetype>7</hsizetype>
-                                    <vsizetype>0</vsizetype>
-                                    <horstretch>0</horstretch>
-                                    <verstretch>0</verstretch>
-                                </sizepolicy>
-                            </property>
-                            <property name="text">
-                                <string>Center</string>
-                            </property>
-                        </widget>
-                        <widget class="QPushButton" row="0" column="0">
-                            <property name="name">
-                                <cstring>pbNewView_2</cstring>
-                            </property>
-                            <property name="enabled">
-                                <bool>true</bool>
-                            </property>
-                            <property name="sizePolicy">
-                                <sizepolicy>
-                                    <hsizetype>7</hsizetype>
-                                    <vsizetype>0</vsizetype>
-                                    <horstretch>0</horstretch>
-                                    <verstretch>0</verstretch>
-                                </sizepolicy>
-                            </property>
-                            <property name="text">
-                                <string>New 3D</string>
-                            </property>
-                        </widget>
-                    </grid>
+                    <property name="enabled">
+                        <bool>true</bool>
+                    </property>
+                    <property name="sizePolicy">
+                        <sizepolicy>
+                            <hsizetype>3</hsizetype>
+                            <vsizetype>0</vsizetype>
+                            <horstretch>0</horstretch>
+                            <verstretch>0</verstretch>
+                        </sizepolicy>
+                    </property>
+                    <property name="minimumSize">
+                        <size>
+                            <width>0</width>
+                            <height>25</height>
+                        </size>
+                    </property>
+                    <property name="text">
+                        <string></string>
+                    </property>
+                    <property name="pixmap">
+                        <pixmap>image5</pixmap>
+                    </property>
                 </widget>
+                <widget class="QPushButton" row="2" column="2">
+                    <property name="name">
+                        <cstring>pbZXY</cstring>
+                    </property>
+                    <property name="enabled">
+                        <bool>true</bool>
+                    </property>
+                    <property name="sizePolicy">
+                        <sizepolicy>
+                            <hsizetype>3</hsizetype>
+                            <vsizetype>0</vsizetype>
+                            <horstretch>0</horstretch>
+                            <verstretch>0</verstretch>
+                        </sizepolicy>
+                    </property>
+                    <property name="minimumSize">
+                        <size>
+                            <width>0</width>
+                            <height>25</height>
+                        </size>
+                    </property>
+                    <property name="text">
+                        <string></string>
+                    </property>
+                    <property name="pixmap">
+                        <pixmap>image6</pixmap>
+                    </property>
+                </widget>
+                <widget class="QPushButton" row="2" column="1">
+                    <property name="name">
+                        <cstring>pbYZX</cstring>
+                    </property>
+                    <property name="enabled">
+                        <bool>true</bool>
+                    </property>
+                    <property name="sizePolicy">
+                        <sizepolicy>
+                            <hsizetype>3</hsizetype>
+                            <vsizetype>0</vsizetype>
+                            <horstretch>0</horstretch>
+                            <verstretch>0</verstretch>
+                        </sizepolicy>
+                    </property>
+                    <property name="minimumSize">
+                        <size>
+                            <width>0</width>
+                            <height>25</height>
+                        </size>
+                    </property>
+                    <property name="text">
+                        <string></string>
+                    </property>
+                    <property name="pixmap">
+                        <pixmap>image7</pixmap>
+                    </property>
+                </widget>
+                <widget class="QPushButton" row="1" column="2">
+                    <property name="name">
+                        <cstring>pbCenterScene_2</cstring>
+                    </property>
+                    <property name="sizePolicy">
+                        <sizepolicy>
+                            <hsizetype>7</hsizetype>
+                            <vsizetype>0</vsizetype>
+                            <horstretch>0</horstretch>
+                            <verstretch>0</verstretch>
+                        </sizepolicy>
+                    </property>
+                    <property name="text">
+                        <string>Center</string>
+                    </property>
+                </widget>
+                <widget class="QPushButton" row="1" column="0">
+                    <property name="name">
+                        <cstring>pbNewView_2</cstring>
+                    </property>
+                    <property name="enabled">
+                        <bool>true</bool>
+                    </property>
+                    <property name="sizePolicy">
+                        <sizepolicy>
+                            <hsizetype>7</hsizetype>
+                            <vsizetype>0</vsizetype>
+                            <horstretch>0</horstretch>
+                            <verstretch>0</verstretch>
+                        </sizepolicy>
+                    </property>
+                    <property name="text">
+                        <string>New 3D</string>
+                    </property>
+                </widget>
             </grid>
         </widget>
     </grid>
@@ -699,6 +773,15 @@
     <image name="image4">
         <data format="PNG" length="160">89504e470d0a1a0a0000000d4948445200000015000000150806000000a917a5960000006749444154388dadccd10d80300c03d1947118a1fbcb23b00e2c4013dbc9fd9ef4168098eecae6def73b8eba70893a3085aa308d2ab084b2b08c32b08556b08d66700b3dc16d1478d628fa07b6d01368a31968a11528a30c28a12c48a30a48a12a58a20e1811f101d3512a7c38fee1ac0000000049454e44ae426082</data>
     </image>
+    <image name="image5">
+        <data format="PNG" length="409">89504e470d0a1a0a0000000d49484452000000280000002808060000008cfeb86d00000160494441545885edd8cf2a05511cc0f1cf95c80bb0916c9462c1d2c20b7801b6ec59515e025bb628af203b6b65cfe6a2946c08c502d762ce2dae3b7f34cc8c9a6ffdea77a6697edf39bf9973eaf095135ca211e22a5cab0c4b686106b3215f2c53a8d1311ec03576d187790ce3b960af44364592b7d828d9a52b63a2d6b6425e49da82a5d353b6401a9517fcd7d4df60163a17ea36ad0cf71442e567b0f282dddad7ede728adcd959fc124ea65260bb5605e6ac1bcd48279a905f3d2de637fb26b94b22f67152c7cfbeb6c712b26fe924334d11fa219ae7d13eb644874c27096725f1a692f398157ac622de4136982bd38c63dc67f4930a923dbb80bb113f790cf6ce10d73198ae589368378c0a3a87389820b61bc9ee145b290650647f01262344970124f3848289647308e3ddc84d84f2a7c8e53d139e16f09a63185772c6325e4d37185d3be95bf103cc285e8c0b42fe44771826914be50f79659bca6083e00acfe78c833f5cc8f0000000049454e44ae426082</data>
+    </image>
+    <image name="image6">
+        <data format="PNG" length="435">89504e470d0a1a0a0000000d49484452000000280000002808060000008cfeb86d0000017a494441545885edd83f6a1b411480f19f8250e20b5827100494c22e5df8023e415aa74f2a1b7289fca98c5ddbe02b1877ae0de99d4689c1100c714292328952684416696777c55a9a35ec07034fc3e3e99b3768060df39c6184c7618cc25c6318e237f6b01fe26152a31c0ef12d8ca3c42eb9ace3077ea29f52a41b997f825e88d756e4b210c7f812c64962973936f0172ff12ac49b498d6638c727932dee85f83ca1cfc3659c5a001ea51628a313991f57c859098def60e305f3b62fefc7916c9b1bdfc122da63a60aad605d5ac1bab482756905eb32bd6317b93592dccb5505577efde56df1253e9b74aa83eb30b72cc691319734e545f8bc85ed10efe6e42d2a50853e6e705524b8863bbcc701befaffba504730da9d401717f88ea74582f0d66425b77853f26575469677f8839dd82ab30c324506057955a8d2c1e761fe75519158e1b2bc4504f378865f382d2b122b5c9657978ff820f28a963da8670fe0f14c4e2caf2eb14577aa24552db634b20f988df893d472dffc03abb374caa8555fb90000000049454e44ae426082</data>
+    </image>
+    <image name="image7">
+        <data format="PNG" length="434">89504e470d0a1a0a0000000d49484452000000280000002808060000008cfeb86d00000179494441545885edd8b14a1c4118c0f1df8928be8076218d2068114b0b5fc027486b7a5345c84b68ac24d60a798560672df800369a4040021ad11416ea59ec1c6c74766f8e3d7737b07ff860f8e6dbbbffceccceb0dbf3927e2407bd82fcab3219c9e545e67082bff5e88cc6248e708d85865da27cc103d69a1689f15eb6163f372d126349b6e6be352d52c4a9ecc198695a84f8d6d1aa6de6bfa668246b65a269816114adab7e424d2db47e045b2f98bacd3436cdad1fc132ba6d26854eb02a9d60553ac1aa748255199cb1a39c1a8d9ccba982b51f7fb129fe8e334c87380bb9d7e2183f6433d3c3cf90fb87fcc82ce21e9fb019da8b91ba54fa43aefb10fa57b01adaeb6582f0157f42ec95d48d22988f3c33b8c20e767129f24efefca259dce056f685abeccfaac4806dfcc26f6c15dd659e37b80bf1b6a42e85612308f3b9bef914c17d5c843818a3604a5d61e7807778c4063e86f67205c15492050f718ea910e721f7bc6edc240b0efb915ac97fa36ec54b52c7b879020c2e72e95070cdb80000000049454e44ae426082</data>
+    </image>
 </images>
 <connections>
     <connection>
@@ -797,6 +880,24 @@
         <receiver>QtGeneratedSimulationController</receiver>
         <slot>pbReferenceClicked()</slot>
     </connection>
+    <connection>
+        <sender>pbXYZ</sender>
+        <signal>clicked()</signal>
+        <receiver>QtGeneratedSimulationController</receiver>
+        <slot>pbXYZ_clicked()</slot>
+    </connection>
+    <connection>
+        <sender>pbYZX</sender>
+        <signal>clicked()</signal>
+        <receiver>QtGeneratedSimulationController</receiver>
+        <slot>pbYZX_clicked()</slot>
+    </connection>
+    <connection>
+        <sender>pbZXY</sender>
+        <signal>clicked()</signal>
+        <receiver>QtGeneratedSimulationController</receiver>
+        <slot>pbZXY_clicked()</slot>
+    </connection>
 </connections>
 <includes>
     <include location="local" impldecl="in implementation">QtGeneratedSimulationController.ui.h</include>
@@ -827,6 +928,9 @@
     <slot>closeGLViewEvent( int )</slot>
     <slot>pbReference_clicked()</slot>
     <slot>pbReferenceClicked()</slot>
+    <slot>pbXYZ_clicked()</slot>
+    <slot>pbYZX_clicked()</slot>
+    <slot>pbZXY_clicked()</slot>
 </slots>
 <layoutdefaults spacing="6" margin="11"/>
 </UI>

Modified: trunk/gui/qt3/SimulationController.cpp
===================================================================
--- trunk/gui/qt3/SimulationController.cpp	2008-09-02 03:51:24 UTC (rev 1500)
+++ trunk/gui/qt3/SimulationController.cpp	2008-09-02 15:52:37 UTC (rev 1501)
@@ -94,9 +94,25 @@
 void SimulationController::pbApplyClicked()
 {
 	guiGen.deserialize(YadeQtMainWindow::self->renderer);
+	YadeQtMainWindow::self->redrawAll(true);
 }
+		
+void SimulationController::pbXYZ_clicked()
+{
+	YadeQtMainWindow::self->adjustCameraInCurrentView(qglviewer::Vec(0,1,0),qglviewer::Vec(0,0,-1));
+};
 
+void SimulationController::pbYZX_clicked()
+{
+	YadeQtMainWindow::self->adjustCameraInCurrentView(qglviewer::Vec(0,0,1),qglviewer::Vec(-1,0,0));
+};
 
+void SimulationController::pbZXY_clicked()
+{
+	YadeQtMainWindow::self->adjustCameraInCurrentView(qglviewer::Vec(1,0,0),qglviewer::Vec(0,-1,0));
+};
+
+
 void SimulationController::pbLoadClicked()
 {
 	pbStopClicked();

Modified: trunk/gui/qt3/SimulationController.hpp
===================================================================
--- trunk/gui/qt3/SimulationController.hpp	2008-09-02 03:51:24 UTC (rev 1500)
+++ trunk/gui/qt3/SimulationController.hpp	2008-09-02 15:52:37 UTC (rev 1501)
@@ -72,6 +72,9 @@
 		virtual void sbRefreshValueChanged(int);
 		virtual void cbSyncToggled(bool);
 		virtual void pbStart2Clicked();
+		virtual void pbXYZ_clicked();
+		virtual void pbYZX_clicked();
+		virtual void pbZXY_clicked();
 
 
 

Modified: trunk/gui/qt3/YadeQtMainWindow.cpp
===================================================================
--- trunk/gui/qt3/YadeQtMainWindow.cpp	2008-09-02 03:51:24 UTC (rev 1500)
+++ trunk/gui/qt3/YadeQtMainWindow.cpp	2008-09-02 15:52:37 UTC (rev 1501)
@@ -23,7 +23,9 @@
 #include <qpixmap.h>
 #include <boost/filesystem/operations.hpp>
 #include <boost/filesystem/convenience.hpp>
+#include <boost/date_time/posix_time/posix_time.hpp>
 
+#include <yade/pkg-common/GravityEngines.hpp>
 
 
 using namespace std;
@@ -96,7 +98,7 @@
 	}
 }
 
-void YadeQtMainWindow::loadSimulation(string file){createController();	controller->loadSimulationFromFileName(file);}
+void YadeQtMainWindow::loadSimulation(string file){createController();	controller->loadSimulationFromFileName(file); lookDown(glViews[0]);}
 void YadeQtMainWindow::centerViews(){FOREACH(const shared_ptr<GLViewer>& glv,glViews){ if(glv) glv->centerScene(); }}
 
 
@@ -150,12 +152,44 @@
 	glv->setCamera(new YadeCamera);
 	glv->camera()->frame()->setWheelSensitivity(-1.0f);
 	glv->camera()->setUpVector(qglviewer::Vec(0,0,1));
-	glv->camera()->setViewDirection(qglviewer::Vec(-1,0,0));
-	glv->centerScene();
+	glv->camera()->setViewDirection(qglviewer::Vec(-1,-1,-1));
+	lookDown(glv);
 	glViews.push_back(glv);
 	//connect( glv, SIGNAL(closeSignal(int)), this, SLOT( closeGLViewEvent(int) ) );
 }
 
+void YadeQtMainWindow::lookDown(shared_ptr<GLViewer> glv)
+{
+	bool hasSimulation=(Omega::instance().getRootBody() ? Omega::instance().getRootBody()->bodies->size()>0 : false );
+	if(hasSimulation)
+	{	
+		Vector3r g(0,0,1);
+		FOREACH(const shared_ptr<Engine>& e,Omega::instance().getRootBody()->engines){
+			if(e && e->getClassName()=="GravityEngine")  
+				g = -1.0*(dynamic_cast<GravityEngine*>(e.get()))->gravity;
+		}
+		glv->camera()->setUpVector(qglviewer::Vec(g[0],g[1],g[2]));
+	} else {
+		glv->camera()->setUpVector(qglviewer::Vec(0,0,1));
+	}
+	glv->camera()->setViewDirection(qglviewer::Vec(-1,-1,-1));
+	glv->centerScene();
+};
+		
+void YadeQtMainWindow::adjustCameraInCurrentView(qglviewer::Vec up,qglviewer::Vec dir)
+{
+	boost::posix_time::ptime last(boost::posix_time::second_clock::local_time()-boost::posix_time::hours(1000));
+	FOREACH(const shared_ptr<GLViewer>& glv,glViews){ if(glv) last=std::max(last,glv->getLastUserEvent()); }
+	FOREACH(const shared_ptr<GLViewer>& glv,glViews){ 
+		if(glv && glv->getLastUserEvent()>=last)
+		{
+			glv->camera()->setUpVector(up);
+			glv->camera()->setViewDirection(dir);
+			glv->centerScene();
+		}
+	}
+};
+
 void YadeQtMainWindow::closeView(GLViewer* glv){
 	for(size_t i=0; i<glViews.size(); i++){
 		if(glViews[i].get()==glv){

Modified: trunk/gui/qt3/YadeQtMainWindow.hpp
===================================================================
--- trunk/gui/qt3/YadeQtMainWindow.hpp	2008-09-02 03:51:24 UTC (rev 1500)
+++ trunk/gui/qt3/YadeQtMainWindow.hpp	2008-09-02 15:52:37 UTC (rev 1501)
@@ -36,8 +36,10 @@
 		void closeView(GLViewer*);
 		void closeView(int);
 		void centerViews();
+		void adjustCameraInCurrentView(qglviewer::Vec up,qglviewer::Vec dir);
 		void loadSimulation(string file);
 		void redrawAll(bool force=false);
+		void lookDown(shared_ptr<GLViewer> glv);
 
 	protected :
 		shared_ptr<QtGUIPreferences> preferences;




Follow ups