refactor

Sat, 28 Jan 2017 13:32:55 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Sat, 28 Jan 2017 13:32:55 +0200
changeset 1061
273333700685
parent 1060
940b3e565ac3
child 1062
4119185b56ca

refactor

src/glRenderer.cpp file | annotate | diff | comparison | revisions
src/glRenderer.h file | annotate | diff | comparison | revisions
--- a/src/glRenderer.cpp	Sat Nov 19 22:57:18 2016 +0200
+++ b/src/glRenderer.cpp	Sat Jan 28 13:32:55 2017 +0200
@@ -75,25 +75,15 @@
 //
 GLRenderer::GLRenderer (QWidget* parent) :
 	QGLWidget (parent),
-	HierarchyElement (parent),
-	m_document (nullptr),
-	m_initialized (false)
+	HierarchyElement (parent)
 {
-	m_isPicking = false;
 	m_camera = (Camera) m_config->camera();
-	m_drawToolTip = false;
 	m_currentEditMode = AbstractEditMode::createByType (this, EditModeType::Select);
-	m_panning = false;
 	m_compiler = new GLCompiler (this);
-	m_objectAtCursor = nullptr;
-	setDrawOnly (false);
 	m_messageLog = new MessageManager (this);
 	m_messageLog->setRenderer (this);
-	m_width = m_height = -1;
-	m_position3D = Origin;
 	m_toolTipTimer = new QTimer (this);
 	m_toolTipTimer->setSingleShot (true);
-	m_isCameraMoving = false;
 	m_thinBorderPen = QPen (QColor (0, 0, 0, 208), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
 	m_thinBorderPen.setWidth (1);
 	setAcceptDrops (true);
@@ -199,11 +189,6 @@
 	return m_messageLog;
 }
 
-bool GLRenderer::isPicking() const
-{
-	return m_isPicking;
-}
-
 LDDocument* GLRenderer::document() const
 {
 	return m_document;
@@ -317,7 +302,7 @@
 //
 void GLRenderer::setBackground()
 {
-	if (not isPicking())
+	if (not m_isDrawingSelectionScene)
 	{
 		// Otherwise use the background that the user wants.
 		QColor color = m_config->backgroundColor();
@@ -385,7 +370,7 @@
 		zoomAllToFit();
 	}
 
-	if (m_config->drawWireframe() and not isPicking())
+	if (m_config->drawWireframe() and not m_isDrawingSelectionScene)
 		glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
 
 	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@@ -429,7 +414,7 @@
 	glEnableClientState (GL_VERTEX_ARRAY);
 	glEnableClientState (GL_COLOR_ARRAY);
 
-	if (isPicking())
+	if (m_isDrawingSelectionScene)
 	{
 		drawVbos (TrianglesVbo, PickColorsVboComplement, GL_TRIANGLES);
 		drawVbos (QuadsVbo, PickColorsVboComplement, GL_QUADS);
@@ -623,11 +608,10 @@
 	painter.setRenderHint(QPainter::Antialiasing);
 
 	// If we wish to only draw the brick, stop here
-	if (isDrawOnly())
+	if (isDrawOnly() or m_isDrawingSelectionScene)
 		return;
 
 #ifndef RELEASE
-	if (not isPicking())
 	{
 		QString text = format("Rotation: (%1°, %2°, %3°)\nPanning: (%4, %5), Zoom: %6",
 			rotation(X), rotation(Y), rotation(Z), panning(X), panning(Y), zoom());
@@ -638,7 +622,7 @@
 	}
 #endif
 
-	if (camera() != FreeCamera and not isPicking())
+	if (camera() != FreeCamera)
 	{
 		// Paint the overlay image if we have one
 		const LDGLOverlay& overlay = currentDocumentData().overlays[camera()];
@@ -661,7 +645,6 @@
 		                 textSize.width(), textSize.height(), Qt::AlignCenter, text);
 	}
 
-	if (not isPicking())
 	{
 		// Draw edit mode HUD
 		m_currentEditMode->render(painter);
@@ -1075,10 +1058,10 @@
 //
 void GLRenderer::setPicking(bool value)
 {
-	m_isPicking = value;
+	m_isDrawingSelectionScene = value;
 	setBackground();
 
-	if (isPicking())
+	if (m_isDrawingSelectionScene)
 	{
 		glDisable(GL_DITHER);
 
--- a/src/glRenderer.h	Sat Nov 19 22:57:18 2016 +0200
+++ b/src/glRenderer.h	Sat Jan 28 13:32:55 2017 +0200
@@ -208,11 +208,10 @@
 	void wheelEvent(QWheelEvent* ev);
 
 private:
-	MessageManager* m_messageLog;
-	LDDocument* m_document;
+	MessageManager* m_messageLog = nullptr;
+	LDDocument* m_document = nullptr;
 	GLCompiler* m_compiler;
-	LDObject* m_objectAtCursor;
-
+	LDObject* m_objectAtCursor = nullptr;
 	CameraIcon m_cameraIcons[7];
 	QTimer* m_toolTipTimer;
 	Qt::MouseButtons m_lastButtons;
@@ -220,14 +219,14 @@
 	Vertex m_position3D;
 	double m_virtualWidth;
 	double m_virtualHeight;
-	bool m_useDarkBackground;
-	bool m_drawToolTip;
-	bool m_takingScreenCapture;
-	bool m_panning;
-	bool m_initialized;
-	bool m_isDrawOnly;
-	bool m_isPicking;
-	bool m_isCameraMoving;
+	bool m_useDarkBackground = false;
+	bool m_drawToolTip = false;
+	bool m_takingScreenCapture = false;
+	bool m_panning = false;
+	bool m_initialized = false;
+	bool m_isDrawOnly = false;
+	bool m_isDrawingSelectionScene = false;
+	bool m_isCameraMoving = false;
 	QPoint m_mousePosition;
 	QPoint m_globalpos;
 	QPointF m_mousePositionF;
@@ -235,11 +234,11 @@
 	Camera m_camera;
 	Camera m_toolTipCamera;
 	GLuint m_axeslist;
-	int m_width;
-	int m_height;
+	int m_width = 0;
+	int m_height = 0;
 	int m_totalMouseMove;
 	QColor m_backgroundColor;
-	AbstractEditMode* m_currentEditMode;
+	AbstractEditMode* m_currentEditMode = nullptr;
 	GLuint m_axesVbo;
 	GLuint m_axesColorVbo;
 

mercurial