mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Started the code for the Profile Plotting
This small patch adds a new class - ProfileGraphicsView it's a QGraphicsView based class that will holds all graphics-items for the plotting. The setup is simple, just call ui->ListView->plot( dive ) ( that's already a ProfileGraphicsView and magic will happen. Since Im using a QGraphicsView , the size of the canvas doesn't matter and I'm fixing it at 0,0,100,100. when a resize is done, the resizeEvent will be called, fitting the scene's rectangle on the view. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
		
							parent
							
								
									fcd6903621
								
							
						
					
					
						commit
						8353d57164
					
				
					 5 changed files with 53 additions and 3 deletions
				
			
		
							
								
								
									
										2
									
								
								Makefile
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								Makefile
									
										
									
									
									
								
							|  | @ -39,6 +39,7 @@ HEADERS = \ | ||||||
| 	qt-ui/plotareascene.h \
 | 	qt-ui/plotareascene.h \
 | ||||||
| 	qt-ui/starwidget.h \
 | 	qt-ui/starwidget.h \
 | ||||||
| 	qt-ui/modeldelegates.h \
 | 	qt-ui/modeldelegates.h \
 | ||||||
|  | 	qt-ui/profilegraphics.h \
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| SOURCES = \
 | SOURCES = \
 | ||||||
|  | @ -67,6 +68,7 @@ SOURCES = \ | ||||||
| 	qt-ui/plotareascene.cpp \
 | 	qt-ui/plotareascene.cpp \
 | ||||||
| 	qt-ui/starwidget.cpp \
 | 	qt-ui/starwidget.cpp \
 | ||||||
| 	qt-ui/modeldelegates.cpp \
 | 	qt-ui/modeldelegates.cpp \
 | ||||||
|  | 	qt-ui/profilegraphics.cpp \
 | ||||||
| 	$(RESFILE) | 	$(RESFILE) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -67,7 +67,6 @@ void MainWindow::on_actionOpen_triggered() | ||||||
| 		g_error_free(error); | 		g_error_free(error); | ||||||
| 		error = NULL; | 		error = NULL; | ||||||
| 	} | 	} | ||||||
| 
 |  | ||||||
| 	process_dives(FALSE, FALSE); | 	process_dives(FALSE, FALSE); | ||||||
| 
 | 
 | ||||||
| 	ui->InfoWidget->reload(); | 	ui->InfoWidget->reload(); | ||||||
|  | @ -94,6 +93,7 @@ void MainWindow::dive_selection_changed(const QItemSelection& newSelection, cons | ||||||
| 			continue; | 			continue; | ||||||
| 		select_dive(get_divenr(d)); | 		select_dive(get_divenr(d)); | ||||||
| 	} | 	} | ||||||
|  | 	ui->ProfileWidget->plot(get_dive(selected_dive)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void MainWindow::on_actionSave_triggered() | void MainWindow::on_actionSave_triggered() | ||||||
|  |  | ||||||
|  | @ -25,7 +25,7 @@ | ||||||
|         <enum>Qt::Horizontal</enum> |         <enum>Qt::Horizontal</enum> | ||||||
|        </property> |        </property> | ||||||
|        <widget class="MainTab" name="InfoWidget" native="true"/> |        <widget class="MainTab" name="InfoWidget" native="true"/> | ||||||
|        <widget class="QGraphicsView" name="ProfileWidget"/> |        <widget class="ProfileGraphicsView" name="ProfileWidget"/> | ||||||
|       </widget> |       </widget> | ||||||
|       <widget class="DiveListView" name="ListWidget"> |       <widget class="DiveListView" name="ListWidget"> | ||||||
|        <property name="styleSheet"> |        <property name="styleSheet"> | ||||||
|  | @ -88,7 +88,7 @@ | ||||||
|      <x>0</x> |      <x>0</x> | ||||||
|      <y>0</y> |      <y>0</y> | ||||||
|      <width>763</width> |      <width>763</width> | ||||||
|      <height>19</height> |      <height>25</height> | ||||||
|     </rect> |     </rect> | ||||||
|    </property> |    </property> | ||||||
|    <widget class="QMenu" name="menuFile"> |    <widget class="QMenu" name="menuFile"> | ||||||
|  | @ -339,6 +339,11 @@ | ||||||
|    <extends>QTreeView</extends> |    <extends>QTreeView</extends> | ||||||
|    <header>divelistview.h</header> |    <header>divelistview.h</header> | ||||||
|   </customwidget> |   </customwidget> | ||||||
|  |   <customwidget> | ||||||
|  |    <class>ProfileGraphicsView</class> | ||||||
|  |    <extends>QGraphicsView</extends> | ||||||
|  |    <header>profilegraphics.h</header> | ||||||
|  |   </customwidget> | ||||||
|  </customwidgets> |  </customwidgets> | ||||||
|  <resources/> |  <resources/> | ||||||
|  <connections/> |  <connections/> | ||||||
|  |  | ||||||
							
								
								
									
										26
									
								
								qt-ui/profilegraphics.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								qt-ui/profilegraphics.cpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,26 @@ | ||||||
|  | #include "profilegraphics.h" | ||||||
|  | 
 | ||||||
|  | #include <QGraphicsScene> | ||||||
|  | #include <QResizeEvent> | ||||||
|  | 
 | ||||||
|  | #include <QDebug> | ||||||
|  | 
 | ||||||
|  | ProfileGraphicsView::ProfileGraphicsView(QWidget* parent) : QGraphicsView(parent) | ||||||
|  | { | ||||||
|  | 	setScene(new QGraphicsScene()); | ||||||
|  | 	scene()->setSceneRect(0,0,100,100); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void ProfileGraphicsView::plot(struct dive *d) | ||||||
|  | { | ||||||
|  | 	qDebug() << "Start the plotting of the dive here."; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void ProfileGraphicsView::resizeEvent(QResizeEvent *event) | ||||||
|  | { | ||||||
|  | 	// Fits the scene's rectangle on the view.
 | ||||||
|  | 	// I can pass some parameters to this -
 | ||||||
|  | 	// like Qt::IgnoreAspectRatio or Qt::KeepAspectRatio
 | ||||||
|  | 	QRectF r = scene()->sceneRect(); | ||||||
|  | 	fitInView ( r.x() - 2, r.y() -2, r.width() + 4, r.height() + 4); // do a little bit of spacing;
 | ||||||
|  | } | ||||||
							
								
								
									
										17
									
								
								qt-ui/profilegraphics.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								qt-ui/profilegraphics.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,17 @@ | ||||||
|  | #ifndef PROFILEGRAPHICS_H | ||||||
|  | #define PROFILEGRAPHICS_H | ||||||
|  | 
 | ||||||
|  | #include <QGraphicsView> | ||||||
|  | 
 | ||||||
|  | class ProfileGraphicsView : public QGraphicsView { | ||||||
|  | Q_OBJECT | ||||||
|  | public: | ||||||
|  | 	ProfileGraphicsView(QWidget* parent = 0); | ||||||
|  | 	void plot(struct dive *d); | ||||||
|  | 
 | ||||||
|  | protected: | ||||||
|  | 	void resizeEvent(QResizeEvent *event); | ||||||
|  | 
 | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | #endif | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue