Commits

iorodeo committed 71f20ef

Worked on format7 settings dialog.

Comments (0)

Files changed (4)

src/gui/camera_window.cpp

 
     void CameraWindow::updateDisplayOnTimer()
     {
-        std::cout << "update display on timer" << std::endl;
+        //std::cout << "update display on timer" << std::endl;
 
         // Get information from image dispatcher
         // -------------------------------------------------------------------
             bool addFrameCount
             )
     {
-        // Updates pixmap of image on Qlabel - sizing based on QLabel size
-
-        QPixmap pixmapScaled =  pixmapOriginal.scaled(
+        // Draw ROI
+        QPixmap pixmapCopy = QPixmap(pixmapOriginal);
+
+        if (addFrameCount && (!format7SettingsDialogPtr_.isNull()))
+        {
+            if (format7SettingsDialogPtr_ -> isRoiShowChecked())
+            {
+                int x = format7SettingsDialogPtr_ -> getRoiXOffset();
+                int y = format7SettingsDialogPtr_ -> getRoiYOffset();
+                int w = format7SettingsDialogPtr_ -> getRoiXWidth();
+                int h = format7SettingsDialogPtr_ -> getRoiYHeight();
+                QPainter roiPainter(&pixmapCopy);
+                QPen roiPen = QPen(QColor(255,0,0));
+                roiPen.setWidth(4);
+                roiPainter.setPen(roiPen);
+                roiPainter.drawRect(QRect(x,y,w,h));
+                roiPainter.end();
+
+            }
+        }
+
+
+        //// Updates pixmap of image on Qlabel - sizing based on QLabel size
+        //QPixmap pixmapScaled =  pixmapOriginal.scaled(
+        //        imageLabelPtr -> size(),
+        //        Qt::KeepAspectRatio, 
+        //        Qt::SmoothTransformation
+        //        );
+        QPixmap pixmapScaled =  pixmapCopy.scaled(
                 imageLabelPtr -> size(),
                 Qt::KeepAspectRatio, 
                 Qt::SmoothTransformation
                 );
+
         
         // Flip and rotate pixmap if required
         if (flipAndRotate) {

src/gui/format7_settings_dialog.cpp

 #include "format7_settings_dialog.hpp"
 #include "validators.hpp"
-#include "camera_facade.hpp"
 #include "lockable.hpp"
 #include <algorithm>
 #include <QGraphicsScene>
 
 namespace bias 
 {
+    const unsigned int sliderSingleStep = 1;
+    const unsigned int sliderPageStep = 10;
+
     // Public methods
     // ----------------------------------------------------------------------------------
     Format7SettingsDialog::Format7SettingsDialog(QWidget *parent) : QDialog(parent)
         initialize();
     }
 
+
     Format7SettingsDialog::Format7SettingsDialog(
             std::shared_ptr<Lockable<Camera>> cameraPtr, 
             QWidget *parent
         initialize();
     }
 
+
+    bool Format7SettingsDialog::isRoiOffChecked()
+    {
+        return roiOffRadioButtonPtr_ -> isChecked();
+    }
+
+
+    bool Format7SettingsDialog::isRoiShowChecked()
+    {
+        return roiShowRadioButtonPtr_ -> isChecked();
+    }
+
+
+    bool Format7SettingsDialog::isRoiEnableChecked()
+    {
+        return roiEnableRadioButtonPtr_ -> isChecked();
+    }
+
+
+    int Format7SettingsDialog::getRoiXOffset()
+    {
+        return settings_.offsetX;
+    }
+
+
+    int Format7SettingsDialog::getRoiYOffset()
+    {
+        return settings_.offsetY;
+    }
+
+
+    int Format7SettingsDialog::getRoiXWidth()
+    {
+        return settings_.width;
+    }
+
+
+    int Format7SettingsDialog::getRoiYHeight()
+    {
+        return settings_.height;
+    }
+
     // Private slots
     // ----------------------------------------------------------------------------------
     void Format7SettingsDialog::modeComboBoxChanged(int index)
 
     void Format7SettingsDialog::roiXOffsetSliderChanged(int value)
     {
-        roiXOffsetLineEditPtr_ -> setText(QString::number(value));
-        std::cout << __PRETTY_FUNCTION__ << ", value = " << value << std::endl;
+        int adjustedValue = value*info_.offsetHStepSize;  
+        settings_.offsetX = adjustedValue;
+        roiXOffsetLineEditPtr_ -> setText(QString::number(adjustedValue));
+        adjustOnXOffsetChange();
     }
 
 
     void Format7SettingsDialog::roiYOffsetSliderChanged(int value)
     {
-        roiYOffsetLineEditPtr_ -> setText(QString::number(value));
-        std::cout << __PRETTY_FUNCTION__ << ", value = " << value << std::endl;
+        int adjustedValue = value*info_.offsetVStepSize; 
+        settings_.offsetY = adjustedValue;
+        roiYOffsetLineEditPtr_ -> setText(QString::number(adjustedValue));
+        adjustOnYOffsetChange();
     }
 
 
     void Format7SettingsDialog::roiXWidthSliderChanged(int value)
     {
-        roiXWidthLineEditPtr_ -> setText(QString::number(value));
-        std::cout << __PRETTY_FUNCTION__ << ", value = " << value << std::endl;
+        int adjustedValue = value*info_.imageHStepSize;
+        settings_.width = adjustedValue;
+        roiXWidthLineEditPtr_ -> setText(QString::number(adjustedValue));
+        adjustOnXWidthChange();
     }
 
 
     void Format7SettingsDialog::roiYHeightSliderChanged(int value)
     {
-        roiYHeightLineEditPtr_ -> setText(QString::number(value));
-        std::cout << __PRETTY_FUNCTION__ << ", value = " << value << std::endl;
+        int adjustedValue = value*info_.imageVStepSize;
+        settings_.height = adjustedValue;
+        roiYHeightLineEditPtr_ -> setText(QString::number(adjustedValue));
+        adjustOnYHeightChange();
     }
 
 
     {
         QString valueString = roiXOffsetLineEditPtr_ -> text();
         int value = valueString.toInt();
-        roiYOffsetSliderPtr_ -> setValue(value);
-        std::cout << __PRETTY_FUNCTION__ << ", value = " << value << std::endl;
+        roiXOffsetSliderPtr_ -> blockSignals(true);
+        roiXOffsetSliderPtr_ -> setValue(value);
+        roiXOffsetSliderPtr_ -> blockSignals(false);
+        adjustOnXOffsetChange();
     }
 
 
     {
         QString valueString = roiYOffsetLineEditPtr_ -> text();
         int value = valueString.toInt();
+        roiYOffsetSliderPtr_ -> blockSignals(true);
         roiYOffsetSliderPtr_ -> setValue(value);
-        std::cout << __PRETTY_FUNCTION__ << ", value = " << value << std::endl;
+        roiYOffsetSliderPtr_ -> blockSignals(false);
+        adjustOnYOffsetChange();
     }
 
 
     {
         QString valueString = roiXWidthLineEditPtr_ -> text();
         int value = valueString.toInt();
+        roiXWidthSliderPtr_ -> blockSignals(true);
         roiXWidthSliderPtr_ -> setValue(value);
-        std::cout << __PRETTY_FUNCTION__ << ", value = " << value << std::endl;
+        roiXWidthSliderPtr_ -> blockSignals(false);
+        adjustOnXWidthChange();
     }
 
 
     {
         QString valueString = roiYHeightLineEditPtr_ -> text();
         int value = valueString.toInt();
+        roiYHeightSliderPtr_ -> blockSignals(true);
         roiYHeightSliderPtr_ -> setValue(value);
-        std::cout << __PRETTY_FUNCTION__ << ", value = " << value << std::endl;
+        roiYHeightSliderPtr_ -> blockSignals(false);
+        adjustOnYHeightChange();
     }
 
 
         }
     }
 
+
+    void Format7SettingsDialog::roiMaxSizePushButtonClicked()
+    {
+        std::cout << __PRETTY_FUNCTION__ << std::endl;
+    }
+
     
     // Private methods
     // ----------------------------------------------------------------------------------
         roiOffRadioButtonPtr_ -> setChecked(true);
         roiShowRadioButtonPtr_ -> setChecked(false);
         roiEnableRadioButtonPtr_ -> setChecked(false);
+        changed_ = false;
 
-        connectWidgets();
+
+        if (cameraPtr_ == NULL)
+        {
+            return;
+        }
 
         cameraPtr_ -> acquireLock();
-        Format7Settings settings = cameraPtr_ -> getFormat7Settings();
-        Format7Info info = cameraPtr_ -> getFormat7Info(settings.mode);
+        settings_ = cameraPtr_ -> getFormat7Settings();
+        info_ = cameraPtr_ -> getFormat7Info(settings_.mode);
         ImageModeList modeList = cameraPtr_ -> getListOfSupportedImageModes();
         PixelFormatList formatList = cameraPtr_ -> getListOfSupportedPixelFormats(
-                settings.mode
+                settings_.mode
                 );
         cameraPtr_ -> releaseLock();
 
         }
 
         // Set ROI Step labels
-        QString xOffsetStepText = QString("Step = %1").arg(info.offsetHStepSize);
+        QString xOffsetStepText = QString("Step = %1").arg(info_.offsetHStepSize);
         roiXOffsetStepLabelPtr_ -> setText(xOffsetStepText);
 
-        QString yOffsetStepText = QString("Step = %1").arg(info.offsetVStepSize);
+        QString yOffsetStepText = QString("Step = %1").arg(info_.offsetVStepSize); 
         roiYOffsetStepLabelPtr_ -> setText(yOffsetStepText);
 
-        QString xWidthStepText = QString("Step = %1").arg(info.imageHStepSize);
+        QString xWidthStepText = QString("Step = %1").arg(info_.imageHStepSize);
         roiXWidthStepLabelPtr_ -> setText(xWidthStepText);
 
-        QString yHeightStepText = QString("Step = %1").arg(info.imageVStepSize);
-        roiYHeightStepLabelPtr_ -> setText(yHeightStepText);
+        QString yHeightInfoText = QString("Step = %1").arg(info_.imageVStepSize); 
+        roiYHeightStepLabelPtr_ -> setText(yHeightInfoText);
 
+        setRanges();
 
-        setupLineEditValidators(settings, info);
+        // Set Slider values
+        roiXOffsetSliderPtr_ -> setValue(settings_.offsetX/info_.offsetHStepSize);
+        roiYOffsetSliderPtr_ -> setValue(settings_.offsetY/info_.offsetVStepSize);
+        roiXWidthSliderPtr_ -> setValue(settings_.width/info_.imageHStepSize);
+        roiYHeightSliderPtr_ -> setValue(settings_.height/info_.imageVStepSize);
+
+        // Set line edit values
+        roiXOffsetLineEditPtr_ -> setText(QString::number(settings_.offsetX));
+        roiYOffsetLineEditPtr_ -> setText(QString::number(settings_.offsetY));
+        roiXWidthLineEditPtr_ -> setText(QString::number(settings_.width));
+        roiYHeightLineEditPtr_ -> setText(QString::number(settings_.height));
+
+        connectWidgets();
 
         // TEMP DEBUG
         // ----------------------------------
         std::cout << std::endl;
         std::cout << "settings" << std::endl;
-        settings.print();
+        settings_.print();
         std::cout << std::endl;
         std::cout << "info" << std::endl;
-        info.print();
+        info_.print();
         // ----------------------------------
     }
 
                 this,
                 SLOT(roiEnableRadioButtonChanged(bool))
                );
+
+        connect(
+                roiMaxSizePushButtonPtr_,
+                SIGNAL(clicked()),
+                this,
+                SLOT(roiMaxSizePushButtonClicked())
+               );
     }
 
 
-    void Format7SettingsDialog::setupLineEditValidators(
-            Format7Settings settings, 
-            Format7Info info
-            )
+    void Format7SettingsDialog::setRanges()
     {
         QPointer<IntValidatorWithFixup> validatorPtr;
+        int bottom;
+        int top;
+        int step;
 
-        // Fixup for x offset lineEdit 
+        // Set fixup and slider range for x offset
+        bottom = 0;
+        top = info_.maxWidth - info_.imageHStepSize;
+        step = info_.offsetHStepSize;
         validatorPtr = new IntValidatorWithFixup(roiXOffsetLineEditPtr_);
-        validatorPtr -> setBottom(0);
-        validatorPtr -> setTop(100);
+        validatorPtr -> setRange(bottom,top);
         roiXOffsetLineEditPtr_ -> setValidator(validatorPtr);
+        roiXOffsetSliderPtr_ -> setRange(bottom/step, top/step);
+        roiXOffsetSliderPtr_ -> setSingleStep(sliderSingleStep);
+        roiXOffsetSliderPtr_ -> setPageStep(sliderPageStep);
 
-        // Fixup for y offset lineEdit
+        // Set fixup and slider range for y offset 
+        bottom = 0;
+        top = info_.maxHeight - info_.imageVStepSize;
+        step = info_.offsetVStepSize;
         validatorPtr = new IntValidatorWithFixup(roiYOffsetLineEditPtr_);
-        validatorPtr -> setBottom(0);
-        validatorPtr -> setTop(100);
-        roiXOffsetLineEditPtr_ -> setValidator(validatorPtr);
+        validatorPtr -> setRange(bottom,top);
+        roiYOffsetLineEditPtr_ -> setValidator(validatorPtr);
+        roiYOffsetSliderPtr_ -> setRange(bottom/step, top/step);
+        roiXOffsetSliderPtr_ -> setSingleStep(sliderSingleStep);
+        roiXOffsetSliderPtr_ -> setPageStep(sliderPageStep);
 
-        // Fixup for x width lineEdit
+        // Set fixup and slider range for x width 
+        bottom = info_.imageHStepSize;
+        top = info_.maxWidth;
+        step = info_.imageHStepSize;
         validatorPtr = new IntValidatorWithFixup(roiXWidthLineEditPtr_);
-        validatorPtr -> setBottom(0);
-        validatorPtr -> setTop(100);
+        validatorPtr -> setRange(bottom, top);
         roiXWidthLineEditPtr_ -> setValidator(validatorPtr);
+        roiXWidthSliderPtr_ -> setRange(bottom/step, top/step);
+        roiXWidthSliderPtr_ -> setSingleStep(sliderSingleStep);
+        roiXWidthSliderPtr_ -> setPageStep(sliderPageStep);
 
-        // Fixup for y height lineEdit
+        // Set fixup and slider range for y height 
+        bottom = info_.imageVStepSize;
+        top = info_.maxHeight;
+        step = info_.imageVStepSize;
         validatorPtr = new IntValidatorWithFixup(roiYHeightLineEditPtr_);
-        validatorPtr -> setBottom(0);
-        validatorPtr -> setTop(100);
-        roiXWidthLineEditPtr_ -> setValidator(validatorPtr);
+        validatorPtr -> setRange(bottom,top);
+        roiYHeightLineEditPtr_ -> setValidator(validatorPtr);
+        roiYHeightSliderPtr_ -> setRange(bottom/step, top/step);
+        roiYHeightSliderPtr_ -> setSingleStep(sliderSingleStep);
+        roiYHeightSliderPtr_ -> setPageStep(sliderPageStep);
         
     }
 
-    
+
+    void Format7SettingsDialog::adjustOnXOffsetChange()
+    {
+        while ((settings_.width + settings_.offsetX) > info_.maxWidth)
+        {
+            settings_.width -= info_.imageHStepSize;
+        }
+        roiXWidthSliderPtr_ -> blockSignals(true);
+        roiXWidthSliderPtr_ -> setValue(settings_.width/info_.imageHStepSize);
+        roiXWidthSliderPtr_ -> blockSignals(false);
+        roiXWidthLineEditPtr_ -> setText(QString::number(settings_.width));
+    }
+
+
+    void  Format7SettingsDialog::adjustOnYOffsetChange()
+    {
+        while ((settings_.height + settings_.offsetY) > info_.maxHeight)
+        {
+            settings_.height -= info_.imageVStepSize;
+        }
+        roiYHeightSliderPtr_ -> blockSignals(true);
+        roiYHeightSliderPtr_ -> setValue(settings_.height/info_.imageVStepSize);
+        roiYHeightSliderPtr_ -> blockSignals(false);
+        roiYHeightLineEditPtr_ -> setText(QString::number(settings_.height));
+    }
+
+
+    void Format7SettingsDialog::adjustOnXWidthChange()
+    {
+        while ((settings_.width + settings_.offsetX) > info_.maxWidth)
+        {
+            settings_.offsetX -= info_.offsetHStepSize;
+        }
+        roiXOffsetSliderPtr_ -> blockSignals(true);
+        roiXOffsetSliderPtr_ -> setValue(settings_.offsetX/info_.offsetHStepSize);
+        roiXOffsetSliderPtr_ -> blockSignals(false);
+        roiXOffsetLineEditPtr_ -> setText(QString::number(settings_.offsetX));
+    }
+
+    void Format7SettingsDialog::adjustOnYHeightChange()
+    {
+        while((settings_.height + settings_.offsetY) > info_.maxHeight)
+        {
+            settings_.offsetY -= info_.offsetVStepSize;
+        }
+        roiYOffsetSliderPtr_ -> blockSignals(true);
+        roiYOffsetSliderPtr_ -> setValue(settings_.offsetY/info_.offsetVStepSize);
+        roiYOffsetSliderPtr_ -> blockSignals(false);
+        roiYOffsetLineEditPtr_ -> setText(QString::number(settings_.offsetY));
+    }
 
 } // namespace bias

src/gui/format7_settings_dialog.hpp

 #define BIAS_FORMAT7_SETTINGS_DIALOG_HPP
 
 #include "ui_format7_settings_dialog.h"
-#include "camera_facade_fwd.hpp"
+#include "camera_facade.hpp"
 #include <QDialog>
 #include <memory>
 
                     std::shared_ptr<Lockable<Camera>> cameraPtr,
                     QWidget *parent=0
                     );
+            bool isRoiOffChecked();
+            bool isRoiShowChecked();
+            bool isRoiEnableChecked();
+            int getRoiXOffset();
+            int getRoiYOffset();
+            int getRoiXWidth();
+            int getRoiYHeight();
 
         private slots:
             void modeComboBoxChanged(int index);
             void roiOffRadioButtonChanged(bool checked);
             void roiShowRadioButtonChanged(bool checked);
             void roiEnableRadioButtonChanged(bool checked);
+            void roiMaxSizePushButtonClicked();
 
         private:
 
             std::shared_ptr<Lockable<Camera>> cameraPtr_;
+            Format7Settings settings_;
+            Format7Info info_;
+            bool changed_;
 
             void initialize();
             void connectWidgets();
-            void setupLineEditValidators(
-                    Format7Settings settings, 
-                    Format7Info info
-                    );
+            void setRanges();
+
+            void adjustOnXOffsetChange();
+            void adjustOnYOffsetChange();
+            void adjustOnXWidthChange();
+            void adjustOnYHeightChange();
+
 
     }; // class Format7SettingsDialog
 

src/gui/format7_settings_dialog.ui

    <rect>
     <x>0</x>
     <y>0</y>
-    <width>570</width>
-    <height>389</height>
+    <width>609</width>
+    <height>393</height>
    </rect>
   </property>
   <property name="sizePolicy">
              <height>16777215</height>
             </size>
            </property>
+           <property name="font">
+            <font>
+             <weight>50</weight>
+             <bold>false</bold>
+            </font>
+           </property>
           </widget>
          </item>
          <item>
              <height>16777215</height>
             </size>
            </property>
+           <property name="font">
+            <font>
+             <weight>50</weight>
+             <bold>false</bold>
+            </font>
+           </property>
           </widget>
          </item>
          <item>
            <property name="orientation">
             <enum>Qt::Horizontal</enum>
            </property>
+           <property name="tickPosition">
+            <enum>QSlider::NoTicks</enum>
+           </property>
+           <property name="tickInterval">
+            <number>0</number>
+           </property>
           </widget>
          </item>
          <item>
             </font>
            </property>
            <property name="text">
-            <string>Step = __</string>
+            <string> Step = __</string>
            </property>
           </widget>
          </item>
            <property name="orientation">
             <enum>Qt::Horizontal</enum>
            </property>
+           <property name="tickPosition">
+            <enum>QSlider::NoTicks</enum>
+           </property>
+           <property name="tickInterval">
+            <number>0</number>
+           </property>
           </widget>
          </item>
          <item>
             </font>
            </property>
            <property name="text">
-            <string>Step = __</string>
+            <string> Step = __</string>
            </property>
           </widget>
          </item>
            <property name="orientation">
             <enum>Qt::Horizontal</enum>
            </property>
+           <property name="tickPosition">
+            <enum>QSlider::NoTicks</enum>
+           </property>
+           <property name="tickInterval">
+            <number>0</number>
+           </property>
           </widget>
          </item>
          <item>
            <property name="orientation">
             <enum>Qt::Horizontal</enum>
            </property>
+           <property name="tickPosition">
+            <enum>QSlider::NoTicks</enum>
+           </property>
+           <property name="tickInterval">
+            <number>0</number>
+           </property>
           </widget>
          </item>
          <item>
             </font>
            </property>
            <property name="text">
-            <string>Step = __</string>
+            <string> Step = __</string>
            </property>
           </widget>
          </item>
        <widget class="QWidget" name="widget_5" native="true">
         <layout class="QHBoxLayout" name="horizontalLayout_2">
          <item>
+          <widget class="QPushButton" name="roiMaxSizePushButtonPtr_">
+           <property name="sizePolicy">
+            <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+             <horstretch>0</horstretch>
+             <verstretch>0</verstretch>
+            </sizepolicy>
+           </property>
+           <property name="minimumSize">
+            <size>
+             <width>100</width>
+             <height>0</height>
+            </size>
+           </property>
+           <property name="maximumSize">
+            <size>
+             <width>100</width>
+             <height>16777215</height>
+            </size>
+           </property>
+           <property name="font">
+            <font>
+             <weight>50</weight>
+             <bold>false</bold>
+            </font>
+           </property>
+           <property name="text">
+            <string>Maximum Size</string>
+           </property>
+          </widget>
+         </item>
+         <item>
           <spacer name="horizontalSpacer_2">
            <property name="orientation">
             <enum>Qt::Horizontal</enum>