Unabbreviated overlay member names

Sun, 08 May 2016 13:25:12 +0300

author
Teemu Piippo <teemu@compsta2.com>
date
Sun, 08 May 2016 13:25:12 +0300
changeset 1032
376db8dd6a42
parent 1031
55c0d3beea0d
child 1033
32153a1dbb15

Unabbreviated overlay member names

src/dialogs.cpp file | annotate | diff | comparison | revisions
src/glRenderer.cpp file | annotate | diff | comparison | revisions
src/glRenderer.h file | annotate | diff | comparison | revisions
ui/overlay.ui file | annotate | diff | comparison | revisions
--- a/src/dialogs.cpp	Wed Feb 17 19:54:21 2016 +0200
+++ b/src/dialogs.cpp	Sun May 08 13:25:12 2016 +0300
@@ -88,13 +88,13 @@
 	LDGLOverlay& info = g_win->renderer()->getOverlay (newcam);
 	RadioDefault<int> (newcam, m_cameraArgs);
 
-	if (info.img)
+	if (info.image)
 	{
-		ui->filename->setText (info.fname);
-		ui->originX->setValue (info.ox);
-		ui->originY->setValue (info.oy);
-		ui->width->setValue (info.lw);
-		ui->height->setValue (info.lh);
+		ui->filename->setText (info.fileName);
+		ui->originX->setValue (info.offsetX);
+		ui->originY->setValue (info.offsetY);
+		ui->width->setValue (info.width);
+		ui->height->setValue (info.height);
 	}
 	else
 	{
--- a/src/glRenderer.cpp	Wed Feb 17 19:54:21 2016 +0200
+++ b/src/glRenderer.cpp	Sun May 08 13:25:12 2016 +0300
@@ -643,13 +643,13 @@
 		// Paint the overlay image if we have one
 		const LDGLOverlay& overlay = currentDocumentData().overlays[camera()];
 
-		if (overlay.img)
+		if (overlay.image)
 		{
 			QPoint v0 = convert3dTo2d (currentDocumentData().overlays[camera()].v0);
 			QPoint v1 = convert3dTo2d (currentDocumentData().overlays[camera()].v1);
 			QRect targetRect (v0.x(), v0.y(), qAbs (v1.x() - v0.x()), qAbs (v1.y() - v0.y()));
-			QRect sourceRect (0, 0, overlay.img->width(), overlay.img->height());
-			painter.drawImage (targetRect, *overlay.img, sourceRect);
+			QRect sourceRect (0, 0, overlay.image->width(), overlay.image->height());
+			painter.drawImage (targetRect, *overlay.image, sourceRect);
 		}
 
 		// Paint the coordinates onto the screen.
@@ -1180,51 +1180,51 @@
 
 // =============================================================================
 //
-bool GLRenderer::setupOverlay (ECamera cam, QString file, int x, int y, int w, int h)
+bool GLRenderer::setupOverlay (ECamera camera, QString fileName, int x, int y, int w, int h)
 {
-	QImage* img = new QImage (QImage (file).convertToFormat (QImage::Format_ARGB32));
-	LDGLOverlay& info = getOverlay (cam);
+	QImage* image = new QImage (QImage (fileName).convertToFormat (QImage::Format_ARGB32));
+	LDGLOverlay& info = getOverlay (camera);
 
-	if (img->isNull())
+	if (image->isNull())
 	{
 		Critical (tr ("Failed to load overlay image!"));
-		currentDocumentData().overlays[cam].invalid = true;
-		delete img;
+		currentDocumentData().overlays[camera].invalid = true;
+		delete image;
 		return false;
 	}
 
-	delete info.img; // delete the old image
+	delete info.image; // delete the old image
 
-	info.fname = file;
-	info.lw = w;
-	info.lh = h;
-	info.ox = x;
-	info.oy = y;
-	info.img = img;
+	info.fileName = fileName;
+	info.width = w;
+	info.height = h;
+	info.offsetX = x;
+	info.offsetY = y;
+	info.image = image;
 	info.invalid = false;
 
-	if (info.lw == 0)
-		info.lw = (info.lh * img->width()) / img->height();
-	else if (info.lh == 0)
-		info.lh = (info.lw * img->height()) / img->width();
+	if (info.width == 0)
+		info.width = (info.height * image->width()) / image->height();
+	else if (info.height == 0)
+		info.height = (info.width * image->height()) / image->width();
 
-	const Axis x2d = getCameraAxis (false, cam),
-		y2d = getCameraAxis (true, cam);
-	const double negXFac = g_FixedCameras[cam].negatedX ? -1 : 1,
-		negYFac = g_FixedCameras[cam].negatedY ? -1 : 1;
+	Axis localX = getCameraAxis (false, camera);
+	Axis localY = getCameraAxis (true, camera);
+	int signX = g_FixedCameras[camera].negatedX ? -1 : 1;
+	int signY = g_FixedCameras[camera].negatedY ? -1 : 1;
 
 	info.v0 = info.v1 = Origin;
-	info.v0.setCoordinate (x2d, -(info.ox * info.lw * negXFac) / img->width());
-	info.v0.setCoordinate (y2d, (info.oy * info.lh * negYFac) / img->height());
-	info.v1.setCoordinate (x2d, info.v0[x2d] + info.lw);
-	info.v1.setCoordinate (y2d, info.v0[y2d] + info.lh);
+	info.v0.setCoordinate (localX, -(info.offsetX * info.width * signX) / image->width());
+	info.v0.setCoordinate (localY, (info.offsetY * info.height * signY) / image->height());
+	info.v1.setCoordinate (localX, info.v0[localX] + info.width);
+	info.v1.setCoordinate (localY, info.v0[localY] + info.height);
 
 	// Set alpha of all pixels to 0.5
-	for (long i = 0; i < img->width(); ++i)
-	for (long j = 0; j < img->height(); ++j)
+	for (int i = 0; i < image->width(); ++i)
+	for (int j = 0; j < image->height(); ++j)
 	{
-		uint32 pixel = img->pixel (i, j);
-		img->setPixel (i, j, 0x80000000 | (pixel & 0x00FFFFFF));
+		uint32 pixel = image->pixel (i, j);
+		image->setPixel (i, j, 0x80000000 | (pixel & 0x00FFFFFF));
 	}
 
 	updateOverlayObjects();
@@ -1239,8 +1239,8 @@
 		return;
 
 	LDGLOverlay& info = currentDocumentData().overlays[camera()];
-	delete info.img;
-	info.img = nullptr;
+	delete info.image;
+	info.image = nullptr;
 
 	updateOverlayObjects();
 }
@@ -1427,25 +1427,27 @@
 //
 void GLRenderer::initOverlaysFromObjects()
 {
-	for (ECamera cam = EFirstCamera; cam < ENumCameras; ++cam)
+	for (ECamera camera = EFirstCamera; camera < ENumCameras; ++camera)
 	{
-		if (cam == EFreeCamera)
+		if (camera == EFreeCamera)
 			continue;
 
-		LDGLOverlay& meta = currentDocumentData().overlays[cam];
-		LDOverlay* ovlobj = findOverlayObject (cam);
+		LDGLOverlay& meta = currentDocumentData().overlays[camera];
+		LDOverlay* overlay = findOverlayObject (camera);
 
-		if (ovlobj == nullptr and meta.img)
+		if (overlay == nullptr and meta.image)
 		{
-			delete meta.img;
-			meta.img = nullptr;
+			// The document doesn't have an overlay for this camera but we have an image for it, delete the image.
+			delete meta.image;
+			meta.image = nullptr;
 		}
-		else if (ovlobj and
-			(meta.img == nullptr or meta.fname != ovlobj->fileName()) and
-			not meta.invalid)
+		else if (overlay
+			and (meta.image == nullptr or meta.fileName != overlay->fileName())
+			and not meta.invalid)
 		{
-			setupOverlay (cam, ovlobj->fileName(), ovlobj->x(),
-				ovlobj->y(), ovlobj->width(), ovlobj->height());
+			// Found a valid overlay definition for this camera, set it up for use.
+			setupOverlay (camera, overlay->fileName(), overlay->x(),
+				overlay->y(), overlay->width(), overlay->height());
 		}
 	}
 }
@@ -1462,7 +1464,7 @@
 		LDGLOverlay& meta = currentDocumentData().overlays[cam];
 		LDOverlay* ovlobj = findOverlayObject (cam);
 
-		if (meta.img == nullptr and ovlobj)
+		if (meta.image == nullptr and ovlobj)
 		{
 			// If this is the last overlay image, we need to remove the empty space after it as well.
 			LDObject* nextobj = ovlobj->next();
@@ -1474,7 +1476,7 @@
 			// not, remove the object.
 			ovlobj->destroy();
 		}
-		else if (meta.img and ovlobj == nullptr)
+		else if (meta.image and ovlobj == nullptr)
 		{
 			// Inverse case: image is there but the overlay object is
 			// not, thus create the object.
@@ -1514,14 +1516,14 @@
 			}
 		}
 
-		if (meta.img and ovlobj)
+		if (meta.image and ovlobj)
 		{
 			ovlobj->setCamera (cam);
-			ovlobj->setFileName (meta.fname);
-			ovlobj->setX (meta.ox);
-			ovlobj->setY (meta.oy);
-			ovlobj->setWidth (meta.lw);
-			ovlobj->setHeight (meta.lh);
+			ovlobj->setFileName (meta.fileName);
+			ovlobj->setX (meta.offsetX);
+			ovlobj->setY (meta.offsetY);
+			ovlobj->setWidth (meta.width);
+			ovlobj->setHeight (meta.height);
 		}
 	}
 
@@ -1680,11 +1682,11 @@
 
 
 LDGLOverlay::LDGLOverlay() :
-	img(nullptr) {}
+	image(nullptr) {}
 
 LDGLOverlay::~LDGLOverlay()
 {
-	delete img;
+	delete image;
 }
 
 
--- a/src/glRenderer.h	Wed Feb 17 19:54:21 2016 +0200
+++ b/src/glRenderer.h	Sun May 08 13:25:12 2016 +0300
@@ -55,12 +55,12 @@
 
 	Vertex			v0,
 					v1;
-	int				ox,
-					oy;
-	double			lw,
-					lh;
-	QString			fname;
-	QImage*			img;
+	int				offsetX,
+					offsetY;
+	double			width,
+					height;
+	QString			fileName;
+	QImage*			image;
 	bool			invalid;
 };
 
@@ -91,7 +91,7 @@
 		{
 			if (i < 6)
 			{
-				overlays[i].img = nullptr;
+				overlays[i].image = nullptr;
 				overlays[i].invalid = false;
 				depthValues[i] = 0.0f;
 			}
@@ -198,7 +198,7 @@
 	void setDrawOnly (bool value);
 	void setEditMode (EditModeType type);
 	void setPicking (bool a);
-	bool setupOverlay (ECamera cam, QString file, int x, int y, int w, int h);
+	bool setupOverlay (ECamera camera, QString fileName, int x, int y, int w, int h);
 	QPen textPen() const;
 	void updateOverlayObjects();
 	void zoomNotch (bool inward);
--- a/ui/overlay.ui	Wed Feb 17 19:54:21 2016 +0200
+++ b/ui/overlay.ui	Sun May 08 13:25:12 2016 +0300
@@ -6,15 +6,15 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>276</width>
-    <height>244</height>
+    <width>299</width>
+    <height>277</height>
    </rect>
   </property>
   <property name="windowTitle">
    <string>Set Overlay</string>
   </property>
   <property name="windowIcon">
-   <iconset resource="../../ldforge.qrc">
+   <iconset resource="../ldforge.qrc">
     <normaloff>:/icons/overlay.png</normaloff>:/icons/overlay.png</iconset>
   </property>
   <layout class="QVBoxLayout" name="verticalLayout">
@@ -30,7 +30,7 @@
          <string>Top</string>
         </property>
         <property name="icon">
-         <iconset resource="../../ldforge.qrc">
+         <iconset resource="../ldforge.qrc">
           <normaloff>:/icons/camera-top.png</normaloff>:/icons/camera-top.png</iconset>
         </property>
        </widget>
@@ -41,7 +41,7 @@
          <string>Front</string>
         </property>
         <property name="icon">
-         <iconset resource="../../ldforge.qrc">
+         <iconset resource="../ldforge.qrc">
           <normaloff>:/icons/camera-front.png</normaloff>:/icons/camera-front.png</iconset>
         </property>
        </widget>
@@ -52,7 +52,7 @@
          <string>Left</string>
         </property>
         <property name="icon">
-         <iconset resource="../../ldforge.qrc">
+         <iconset resource="../ldforge.qrc">
           <normaloff>:/icons/camera-left.png</normaloff>:/icons/camera-left.png</iconset>
         </property>
        </widget>
@@ -63,7 +63,7 @@
          <string>Bottom</string>
         </property>
         <property name="icon">
-         <iconset resource="../../ldforge.qrc">
+         <iconset resource="../ldforge.qrc">
           <normaloff>:/icons/camera-bottom.png</normaloff>:/icons/camera-bottom.png</iconset>
         </property>
        </widget>
@@ -74,7 +74,7 @@
          <string>Back</string>
         </property>
         <property name="icon">
-         <iconset resource="../../ldforge.qrc">
+         <iconset resource="../ldforge.qrc">
           <normaloff>:/icons/camera-back.png</normaloff>:/icons/camera-back.png</iconset>
         </property>
        </widget>
@@ -85,7 +85,7 @@
          <string>Right</string>
         </property>
         <property name="icon">
-         <iconset resource="../../ldforge.qrc">
+         <iconset resource="../ldforge.qrc">
           <normaloff>:/icons/camera-right.png</normaloff>:/icons/camera-right.png</iconset>
         </property>
        </widget>
@@ -122,7 +122,7 @@
              <string/>
             </property>
             <property name="icon">
-             <iconset resource="../../ldforge.qrc">
+             <iconset resource="../ldforge.qrc">
               <normaloff>:/icons/file-open.png</normaloff>:/icons/file-open.png</iconset>
             </property>
            </widget>
@@ -239,7 +239,7 @@
   </layout>
  </widget>
  <resources>
-  <include location="../../ldforge.qrc"/>
+  <include location="../ldforge.qrc"/>
  </resources>
  <connections>
   <connection>

mercurial