Commits

iorodeo committed f39f920

Worked on alignment settings dialog.

Comments (0)

Files changed (6)

src/gui/alignment_settings.cpp

 
 namespace bias
 {
+    const unsigned int AlignmentSettings::GRID_MIN_NUM_COL = 1;
+    const unsigned int AlignmentSettings::GRID_MAX_NUM_COL = 20; 
+    const unsigned int AlignmentSettings::GRID_MIN_NUM_ROW = 1;
+    const unsigned int AlignmentSettings::GRID_MAX_NUM_ROW = 20; 
 
-    const bool DEFAULT_GRID_VISIBLE = true;
-    const unsigned int DEFAULT_GRID_NUM_COL = 5;
-    const unsigned int DEFAULT_GRID_NUM_ROW = 5;
-    const unsigned int DEFAULT_GRID_PEN_WIDTH = 1;
-    const QColor DEFAULT_GRID_QCOLOR = QColor(0,0,255);
+    const bool AlignmentSettings::DEFAULT_GRID_VISIBLE = true;
+    const unsigned int AlignmentSettings::DEFAULT_GRID_NUM_COL = 5;
+    const unsigned int AlignmentSettings::DEFAULT_GRID_NUM_ROW = 5;
+    const unsigned int AlignmentSettings::DEFAULT_GRID_PEN_WIDTH = 1;
+    const QColor AlignmentSettings::DEFAULT_GRID_QCOLOR = QColor(0,0,255);
 
-    const bool DEFAULT_CIRCLE_VISIBLE = true;
-    const unsigned int DEFAULT_CIRCLE_RADIUS = 50;
-    const unsigned int DEFAULT_CIRCLE_POS_X = 100;
-    const unsigned int DEFAULT_CIRCLE_POS_Y = 100;
-    const unsigned int DEFAULT_CIRCLE_PEN_WIDTH = 1;
-    const QColor DEFAULT_CIRCLE_QCOLOR = QColor(255,255,0);
+    const bool AlignmentSettings::DEFAULT_ELLIPSE_VISIBLE = true;
+    const unsigned int AlignmentSettings::DEFAULT_ELLIPSE_POS_X = 100;
+    const unsigned int AlignmentSettings::DEFAULT_ELLIPSE_POS_Y = 100;
+    const unsigned int AlignmentSettings::DEFAULT_ELLIPSE_RADIUS_X = 50;
+    const unsigned int AlignmentSettings::DEFAULT_ELLIPSE_RADIUS_Y = 25;
+    const unsigned int AlignmentSettings::DEFAULT_ELLIPSE_PEN_WIDTH = 1;
+    const QColor AlignmentSettings::DEFAULT_ELLIPSE_QCOLOR = QColor(255,255,0);
 
     AlignmentSettings::AlignmentSettings()
     {
         gridPenWidth = DEFAULT_GRID_PEN_WIDTH;
         gridQColor = DEFAULT_GRID_QCOLOR;
 
-        circleVisible = DEFAULT_CIRCLE_VISIBLE;
-        circleRadius = DEFAULT_CIRCLE_RADIUS;
-        circlePosX = DEFAULT_CIRCLE_POS_X;
-        circlePosY = DEFAULT_CIRCLE_POS_Y;
-        circlePenWidth = DEFAULT_CIRCLE_PEN_WIDTH;
-        circleQColor = DEFAULT_CIRCLE_QCOLOR;
-
+        ellipseVisible = DEFAULT_ELLIPSE_VISIBLE;
+        ellipsePosX = DEFAULT_ELLIPSE_POS_X;
+        ellipsePosY = DEFAULT_ELLIPSE_POS_Y;
+        ellipseRadiusX = DEFAULT_ELLIPSE_RADIUS_X;
+        ellipseRadiusY = DEFAULT_ELLIPSE_RADIUS_Y;
+        ellipsePenWidth = DEFAULT_ELLIPSE_PEN_WIDTH;
+        ellipseQColor = DEFAULT_ELLIPSE_QCOLOR;
     };
 
 } // namespace bias

src/gui/alignment_settings.hpp

             unsigned int gridPenWidth;
             QColor gridQColor;
 
-            bool circleVisible;
-            unsigned int circleRadius;
-            unsigned int circlePosX;
-            unsigned int circlePosY;
-            unsigned int circlePenWidth;
-            QColor circleQColor;
+            bool ellipseVisible;
+            unsigned int ellipsePosX;
+            unsigned int ellipsePosY;
+            unsigned int ellipseRadiusX;
+            unsigned int ellipseRadiusY;
+            unsigned int ellipsePenWidth;
+            QColor ellipseQColor;
 
-    };
+            static const bool DEFAULT_GRID_VISIBLE;
+            static const unsigned int DEFAULT_GRID_NUM_COL;
+            static const unsigned int DEFAULT_GRID_NUM_ROW;
+            static const unsigned int DEFAULT_GRID_PEN_WIDTH;
+            static const QColor DEFAULT_GRID_QCOLOR;
+
+            static const unsigned int GRID_MIN_NUM_COL;
+            static const unsigned int GRID_MAX_NUM_COL; 
+            static const unsigned int GRID_MIN_NUM_ROW;
+            static const unsigned int GRID_MAX_NUM_ROW; 
+
+            static const bool DEFAULT_ELLIPSE_VISIBLE;
+            static const unsigned int DEFAULT_ELLIPSE_POS_X;
+            static const unsigned int DEFAULT_ELLIPSE_POS_Y;
+            static const unsigned int DEFAULT_ELLIPSE_RADIUS_X;
+            static const unsigned int DEFAULT_ELLIPSE_RADIUS_Y;
+            static const unsigned int DEFAULT_ELLIPSE_PEN_WIDTH;
+            static const QColor DEFAULT_ELLIPSE_QCOLOR;
+
+    }; // AlignmentSettings
 
 } // namespace bias
 

src/gui/alignment_settings_dialog.cpp

 #include "alignment_settings_dialog.hpp"
+#include <iostream>
 
 namespace bias
 {
 
     }
 
+
     void AlignmentSettingsDialog::initialize()
     {
         setupUi(this);
+        setAttribute(Qt::WA_DeleteOnClose);
+        setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
+        initializeGridTab();
+        initializeEllipseTab();
+        updateSettings(settings_);
+    }
 
-        setAttribute(Qt::WA_DeleteOnClose);
 
-        updateSettings(settings_);
+    void AlignmentSettingsDialog::initializeGridTab()
+    {
+        unsigned int minNumRow = AlignmentSettings::GRID_MIN_NUM_ROW;
+        unsigned int maxNumRow = AlignmentSettings::GRID_MAX_NUM_ROW;
+        for (unsigned int i=minNumRow, cnt=0; i<maxNumRow; i++, cnt++)
+        {
+            gridRowsComboBoxPtr_ -> addItem(QString::number(i));
+            gridRowsValueToIndexMap_[i] = cnt;
+
+        }
+
+        unsigned int minNumCol = AlignmentSettings::GRID_MIN_NUM_COL;
+        unsigned int maxNumCol = AlignmentSettings::GRID_MAX_NUM_COL;
+        for (unsigned int i=minNumCol, cnt=0; i<maxNumCol; i++, cnt++)
+        {
+            gridColsComboBoxPtr_ -> addItem(QString::number(i));
+            gridColsValueToIndexMap_[i] = cnt;
+        }
+    }
+
+
+    void AlignmentSettingsDialog::initializeEllipseTab()
+    {
     }
 
 
     {
         settings_ = settings;
 
-        gridVisibleCheckBoxPtr_ -> setChecked(true);
+        // Grid tab settings
+        gridVisibleCheckBoxPtr_ -> setChecked(settings_.gridVisible);
+        unsigned int rowsIndex = gridRowsValueToIndexMap_[settings_.gridNumRow];
+        gridRowsComboBoxPtr_ -> setCurrentIndex(rowsIndex);
+        unsigned int colsIndex = gridColsValueToIndexMap_[settings_.gridNumCol];
+        gridColsComboBoxPtr_ -> setCurrentIndex(colsIndex);
 
+        std::cout << rowsIndex << " " << colsIndex << std::endl;
+
+        // Ellipse tab settings
+        ellipseVisibleCheckBoxPtr_ -> setChecked(settings_.ellipseVisible);
     }
 
 

src/gui/alignment_settings_dialog.hpp

 #define BIAS_ALIGNMENT_SETTINSG_DIALOG_HPP
 
 #include <QDialog>
+#include <QMap>
 #include "ui_alignment_settings_dialog.h"
 #include "alignment_settings.hpp"
 
         private:
 
             AlignmentSettings settings_;
+            QMap<unsigned int, unsigned int> gridRowsValueToIndexMap_;
+            QMap<unsigned int, unsigned int> gridColsValueToIndexMap_;
              
             void initialize();
+            void initializeGridTab();
+            void initializeEllipseTab();
             void connectWidgets();
             void updateSettings(AlignmentSettings settings);
 

src/gui/alignment_settings_dialog.ui

    <rect>
     <x>0</x>
     <y>0</y>
-    <width>527</width>
-    <height>330</height>
+    <width>546</width>
+    <height>377</height>
    </rect>
   </property>
   <property name="windowTitle">
    <item>
     <widget class="QTabWidget" name="tabWidget">
      <property name="currentIndex">
-      <number>1</number>
+      <number>0</number>
      </property>
      <widget class="QWidget" name="gridTabPtr">
       <attribute name="title">
        </item>
       </layout>
      </widget>
-     <widget class="QWidget" name="circleTabPtr_">
+     <widget class="QWidget" name="ellipseTabPtr_">
       <attribute name="title">
-       <string>Circle</string>
+       <string>Ellipse</string>
       </attribute>
       <layout class="QVBoxLayout" name="verticalLayout">
        <item>
-        <widget class="QWidget" name="circleVisibleWidgetPtr_" native="true">
+        <widget class="QWidget" name="ellipseVisibleWidgetPtr_" native="true">
          <layout class="QHBoxLayout" name="horizontalLayout_2">
           <item>
-           <widget class="QCheckBox" name="circleVisibleCheckBoxPtr_">
+           <widget class="QCheckBox" name="ellipseVisibleCheckBoxPtr_">
             <property name="layoutDirection">
              <enum>Qt::LeftToRight</enum>
             </property>
         </widget>
        </item>
        <item>
-        <widget class="QWidget" name="circlePosXWidgetPtr_" native="true">
+        <widget class="QWidget" name="ellipsePosXWidgetPtr_" native="true">
          <layout class="QHBoxLayout" name="horizontalLayout_4">
           <item>
-           <widget class="QLabel" name="circlePosXLabelPtr_">
+           <widget class="QLabel" name="ellipsePosXLabelPtr_">
             <property name="sizePolicy">
              <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
               <horstretch>0</horstretch>
             </property>
             <property name="minimumSize">
              <size>
-              <width>30</width>
+              <width>40</width>
               <height>0</height>
              </size>
             </property>
             <property name="maximumSize">
              <size>
-              <width>30</width>
+              <width>40</width>
               <height>16777215</height>
              </size>
             </property>
            </spacer>
           </item>
           <item>
-           <widget class="QSlider" name="circlePosXSliderPtr_">
+           <widget class="QSlider" name="ellipsePosXSliderPtr_">
             <property name="orientation">
              <enum>Qt::Horizontal</enum>
             </property>
            </spacer>
           </item>
           <item>
-           <widget class="QLineEdit" name="circlePosXLineEditPtr_">
+           <widget class="QLineEdit" name="ellipsePosXLineEditPtr_">
             <property name="sizePolicy">
              <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
               <horstretch>0</horstretch>
         <widget class="QWidget" name="widget_5" native="true">
          <layout class="QHBoxLayout" name="horizontalLayout_5">
           <item>
-           <widget class="QLabel" name="circlePosYLabelPtr_">
+           <widget class="QLabel" name="ellipsePosYLabelPtr_">
             <property name="sizePolicy">
              <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
               <horstretch>0</horstretch>
             </property>
             <property name="minimumSize">
              <size>
-              <width>30</width>
+              <width>40</width>
               <height>0</height>
              </size>
             </property>
             <property name="maximumSize">
              <size>
-              <width>30</width>
+              <width>40</width>
               <height>16777215</height>
              </size>
             </property>
            </spacer>
           </item>
           <item>
-           <widget class="QSlider" name="circlePosYSliderPtr_">
+           <widget class="QSlider" name="ellipsePosYSliderPtr_">
             <property name="orientation">
              <enum>Qt::Horizontal</enum>
             </property>
            </spacer>
           </item>
           <item>
-           <widget class="QLineEdit" name="circlePosYLineEditPtr_">
+           <widget class="QLineEdit" name="ellipsePosYLineEditPtr_">
             <property name="sizePolicy">
              <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
               <horstretch>0</horstretch>
         </widget>
        </item>
        <item>
-        <widget class="QWidget" name="circleRadiusWidgetPtr_" native="true">
+        <widget class="QWidget" name="ellipseRadiusXWidgetPtr_" native="true">
          <layout class="QHBoxLayout" name="horizontalLayout_6">
           <item>
-           <widget class="QLabel" name="circleRadiusLabelPtr_">
+           <widget class="QLabel" name="ellipseRadiusXLabelPtr_">
             <property name="sizePolicy">
              <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
               <horstretch>0</horstretch>
             </property>
             <property name="minimumSize">
              <size>
-              <width>30</width>
+              <width>40</width>
               <height>0</height>
              </size>
             </property>
             <property name="maximumSize">
              <size>
-              <width>30</width>
+              <width>40</width>
               <height>16777215</height>
              </size>
             </property>
             <property name="text">
-             <string>Radius </string>
+             <string>Radius X</string>
             </property>
            </widget>
           </item>
            </spacer>
           </item>
           <item>
-           <widget class="QSlider" name="circleRadiusSliderPtr_">
+           <widget class="QSlider" name="ellipseRadiusXSliderPtr_">
             <property name="orientation">
              <enum>Qt::Horizontal</enum>
             </property>
            </spacer>
           </item>
           <item>
-           <widget class="QLineEdit" name="circleRadiusLineEditPtr_">
+           <widget class="QLineEdit" name="ellipseRadiusXLineEditPtr_">
             <property name="sizePolicy">
              <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
               <horstretch>0</horstretch>
         </widget>
        </item>
        <item>
+        <widget class="QWidget" name="ellipseRadiusYWidgetPtr_" native="true">
+         <layout class="QHBoxLayout" name="horizontalLayout_10">
+          <item>
+           <widget class="QLabel" name="ellipseRadiusYLabelPtr_">
+            <property name="sizePolicy">
+             <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
+              <horstretch>0</horstretch>
+              <verstretch>0</verstretch>
+             </sizepolicy>
+            </property>
+            <property name="minimumSize">
+             <size>
+              <width>40</width>
+              <height>0</height>
+             </size>
+            </property>
+            <property name="maximumSize">
+             <size>
+              <width>40</width>
+              <height>16777215</height>
+             </size>
+            </property>
+            <property name="text">
+             <string>Radius Y </string>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <spacer name="horizontalSpacer_15">
+            <property name="orientation">
+             <enum>Qt::Horizontal</enum>
+            </property>
+            <property name="sizeType">
+             <enum>QSizePolicy::Fixed</enum>
+            </property>
+            <property name="sizeHint" stdset="0">
+             <size>
+              <width>15</width>
+              <height>20</height>
+             </size>
+            </property>
+           </spacer>
+          </item>
+          <item>
+           <widget class="QSlider" name="ellipseRadiusYSliderPtr_">
+            <property name="orientation">
+             <enum>Qt::Horizontal</enum>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <spacer name="horizontalSpacer_16">
+            <property name="orientation">
+             <enum>Qt::Horizontal</enum>
+            </property>
+            <property name="sizeType">
+             <enum>QSizePolicy::Fixed</enum>
+            </property>
+            <property name="sizeHint" stdset="0">
+             <size>
+              <width>15</width>
+              <height>20</height>
+             </size>
+            </property>
+           </spacer>
+          </item>
+          <item>
+           <widget class="QLineEdit" name="ellipseRadiusYLineEditPtr_">
+            <property name="sizePolicy">
+             <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+              <horstretch>0</horstretch>
+              <verstretch>0</verstretch>
+             </sizepolicy>
+            </property>
+            <property name="minimumSize">
+             <size>
+              <width>60</width>
+              <height>0</height>
+             </size>
+            </property>
+            <property name="maximumSize">
+             <size>
+              <width>60</width>
+              <height>16777215</height>
+             </size>
+            </property>
+           </widget>
+          </item>
+         </layout>
+        </widget>
+       </item>
+       <item>
+        <widget class="Line" name="line_8">
+         <property name="orientation">
+          <enum>Qt::Horizontal</enum>
+         </property>
+        </widget>
+       </item>
+       <item>
         <widget class="QWidget" name="widget_7" native="true">
          <layout class="QHBoxLayout" name="horizontalLayout_7">
           <item>
-           <widget class="QLabel" name="circleColorLabelPtr_">
+           <widget class="QLabel" name="ellipseColorLabelPtr_">
             <property name="text">
              <string>Color:</string>
             </property>
            </widget>
           </item>
           <item>
-           <widget class="QLabel" name="circleColorImageLabelPtr_">
+           <widget class="QLabel" name="ellipseColorImageLabelPtr_">
             <property name="sizePolicy">
              <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
               <horstretch>0</horstretch>
            </spacer>
           </item>
           <item>
-           <widget class="QPushButton" name="circleColorChangePushButtonPtr_">
+           <widget class="QPushButton" name="ellipseColorChangePushButtonPtr_">
             <property name="text">
              <string>Change</string>
             </property>

src/gui/camera_window.cpp

             }
 
             // Draw alignement circle
-            if (alignmentSettings_.circleVisible)
+            if (alignmentSettings_.ellipseVisible)
             {
                 float scaleX = float(scaledPixmapWidth)/float(origPixmapWidth);
                 float scaleY = float(scaledPixmapHeight)/float(origPixmapHeight);
-                QPainter circlePainter(&pixmapScaled);
-                QPen circlePen = QPen(alignmentSettings_.circleQColor);
-                circlePen.setWidth(alignmentSettings_.circlePenWidth);
-                circlePainter.setPen(circlePen);
-                circlePainter.drawEllipse(
-                        (unsigned int)(scaleX*alignmentSettings_.circlePosX),
-                        (unsigned int)(scaleY*alignmentSettings_.circlePosY),
-                        (unsigned int)(2*scaleX*alignmentSettings_.circleRadius),
-                        (unsigned int)(2*scaleY*alignmentSettings_.circleRadius)
+                QPainter ellipsePainter(&pixmapScaled);
+                QPen ellipsePen = QPen(alignmentSettings_.ellipseQColor);
+                ellipsePen.setWidth(alignmentSettings_.ellipsePenWidth);
+                ellipsePainter.setPen(ellipsePen);
+                ellipsePainter.drawEllipse(
+                        (unsigned int)(scaleX*alignmentSettings_.ellipsePosX),
+                        (unsigned int)(scaleY*alignmentSettings_.ellipsePosY),
+                        (unsigned int)(2*scaleX*alignmentSettings_.ellipseRadiusX),
+                        (unsigned int)(2*scaleY*alignmentSettings_.ellipseRadiusY)
                         );
-                circlePainter.end();
+                ellipsePainter.end();
             }
         }