Commits

iorodeo committed 1de2ff8

Added lineEdit for setting number for samples to the plot and measure programs.

  • Participants
  • Parent commits 9eb74a6

Comments (0)

Files changed (6)

File python/Colorimeter/colorimeter/gui/basic/basic.py

 
     def connectActions(self):
         super(BasicMainWindow,self).connectActions()
-        self.samplesLineEdit.editingFinished.connect(self.samplesChanged_Callback)
         self.plotCheckBox.stateChanged.connect(self.plotCheckBox_Callback)
         for color in constants.COLOR2LED_DICT:
             checkBox = getattr(self,'{0}CheckBox'.format(color))
     def initialize(self):
         super(BasicMainWindow,self).initialize()
         self.measValues = None
-        self.numSamples = None
         self.aboutText = constants.BASIC_ABOUT_TEXT
         self.samplesValidator = QtGui.QIntValidator(0,2**16-1,self.samplesLineEdit)
         self.samplesLineEdit.setValidator(self.samplesValidator)
         else:
             self.updatePlot(create=True)
 
-    def connectClicked_Callback(self):
-        super(BasicMainWindow,self).connectClicked_Callback()
-        if self.dev is None:
-            self.samplesLineEdit.setText('')
-        else:
-            self.samplesLineEdit.setText('{0}'.format(self.numSamples))
-
     def calibratePressed_Callback(self):
         super(BasicMainWindow,self).calibratePressed_Callback()
         self.transmissionTextEdit.setText('')
         checkBox = getattr(self,'{0}CheckBox'.format(color))
         return checkBox.isChecked()
 
-    def samplesChanged_Callback(self):
-        valueStr = str(self.samplesLineEdit.text())
-        value = int(valueStr)
-        if value != self.numSamples:
-            self.numSamples = value
-            self.dev.setNumSamples(value)
-
     def getData(self):
         freqValues, tranValues, absoValues = self.measValues
         colorNames = sorted(constants.COLOR2LED_DICT.keys())
             self.measurePushButton.setEnabled(False)
             self.transmissionGroupBox.setEnabled(False)
             self.absorbanceGroupBox.setEnabled(False)
-            self.samplesLineEdit.setEnabled(False)
             self.redCheckBox.setEnabled(False)
             self.greenCheckBox.setEnabled(False)
             self.blueCheckBox.setEnabled(False)
             self.calibratePushButton.setEnabled(True)
             self.transmissionGroupBox.setEnabled(True)
             self.absorbanceGroupBox.setEnabled(True)
-            self.samplesLineEdit.setEnabled(True)
             self.portLineEdit.setEnabled(False)
             if self.isCalibrated:
                 self.measurePushButton.setEnabled(True)

File python/Colorimeter/colorimeter/gui/measure/measure.ui

    <rect>
     <x>0</x>
     <y>0</y>
-    <width>600</width>
-    <height>537</height>
+    <width>666</width>
+    <height>461</height>
    </rect>
   </property>
   <property name="windowTitle">
       </property>
       <layout class="QHBoxLayout" name="horizontalLayout_3">
        <item>
+        <widget class="QLabel" name="label_5">
+         <property name="text">
+          <string>Samples</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QLineEdit" name="samplesLineEdit">
+         <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>
+        </widget>
+       </item>
+       <item>
+        <spacer name="horizontalSpacer_7">
+         <property name="orientation">
+          <enum>Qt::Horizontal</enum>
+         </property>
+         <property name="sizeType">
+          <enum>QSizePolicy::Fixed</enum>
+         </property>
+         <property name="sizeHint" stdset="0">
+          <size>
+           <width>10</width>
+           <height>20</height>
+          </size>
+         </property>
+        </spacer>
+       </item>
+       <item>
         <widget class="QPushButton" name="calibratePushButton">
          <property name="text">
           <string>Calibrate</string>
     <rect>
      <x>0</x>
      <y>0</y>
-     <width>600</width>
+     <width>666</width>
      <height>23</height>
     </rect>
    </property>

File python/Colorimeter/colorimeter/gui/measure/measure_ui.py

 
 # Form implementation generated from reading ui file 'measure.ui'
 #
-# Created: Sat Apr 20 19:33:55 2013
+# Created: Wed Apr 24 17:23:18 2013
 #      by: PyQt4 UI code generator 4.7.2
 #
 # WARNING! All changes made in this file will be lost!
 class Ui_MainWindow(object):
     def setupUi(self, MainWindow):
         MainWindow.setObjectName("MainWindow")
-        MainWindow.resize(600, 537)
+        MainWindow.resize(666, 461)
         self.centralwidget = QtGui.QWidget(MainWindow)
         self.centralwidget.setObjectName("centralwidget")
         self.verticalLayout = QtGui.QVBoxLayout(self.centralwidget)
         self.widget_3.setObjectName("widget_3")
         self.horizontalLayout_3 = QtGui.QHBoxLayout(self.widget_3)
         self.horizontalLayout_3.setObjectName("horizontalLayout_3")
+        self.label_5 = QtGui.QLabel(self.widget_3)
+        self.label_5.setObjectName("label_5")
+        self.horizontalLayout_3.addWidget(self.label_5)
+        self.samplesLineEdit = QtGui.QLineEdit(self.widget_3)
+        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
+        sizePolicy.setHorizontalStretch(0)
+        sizePolicy.setVerticalStretch(0)
+        sizePolicy.setHeightForWidth(self.samplesLineEdit.sizePolicy().hasHeightForWidth())
+        self.samplesLineEdit.setSizePolicy(sizePolicy)
+        self.samplesLineEdit.setMinimumSize(QtCore.QSize(100, 0))
+        self.samplesLineEdit.setMaximumSize(QtCore.QSize(100, 16777215))
+        self.samplesLineEdit.setObjectName("samplesLineEdit")
+        self.horizontalLayout_3.addWidget(self.samplesLineEdit)
+        spacerItem5 = QtGui.QSpacerItem(10, 20, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum)
+        self.horizontalLayout_3.addItem(spacerItem5)
         self.calibratePushButton = QtGui.QPushButton(self.widget_3)
         self.calibratePushButton.setObjectName("calibratePushButton")
         self.horizontalLayout_3.addWidget(self.calibratePushButton)
         self.clearPushButton = QtGui.QPushButton(self.widget_3)
         self.clearPushButton.setObjectName("clearPushButton")
         self.horizontalLayout_3.addWidget(self.clearPushButton)
-        spacerItem5 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
-        self.horizontalLayout_3.addItem(spacerItem5)
+        spacerItem6 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
+        self.horizontalLayout_3.addItem(spacerItem6)
         self.measurePushButton = QtGui.QPushButton(self.widget_3)
         self.measurePushButton.setObjectName("measurePushButton")
         self.horizontalLayout_3.addWidget(self.measurePushButton)
         self.verticalLayout.addWidget(self.widget_3)
         MainWindow.setCentralWidget(self.centralwidget)
         self.menubar = QtGui.QMenuBar(MainWindow)
-        self.menubar.setGeometry(QtCore.QRect(0, 0, 600, 23))
+        self.menubar.setGeometry(QtCore.QRect(0, 0, 666, 23))
         self.menubar.setObjectName("menubar")
         self.menuFile = QtGui.QMenu(self.menubar)
         self.menuFile.setObjectName("menuFile")
         self.greenRadioButton.setText(QtGui.QApplication.translate("MainWindow", "green", None, QtGui.QApplication.UnicodeUTF8))
         self.blueRadioButton.setText(QtGui.QApplication.translate("MainWindow", "blue", None, QtGui.QApplication.UnicodeUTF8))
         self.whiteRadioButton.setText(QtGui.QApplication.translate("MainWindow", "white", None, QtGui.QApplication.UnicodeUTF8))
+        self.label_5.setText(QtGui.QApplication.translate("MainWindow", "Samples", None, QtGui.QApplication.UnicodeUTF8))
         self.calibratePushButton.setText(QtGui.QApplication.translate("MainWindow", "Calibrate", None, QtGui.QApplication.UnicodeUTF8))
         self.clearPushButton.setText(QtGui.QApplication.translate("MainWindow", "Clear", None, QtGui.QApplication.UnicodeUTF8))
         self.measurePushButton.setText(QtGui.QApplication.translate("MainWindow", "Measure", None, QtGui.QApplication.UnicodeUTF8))

File python/Colorimeter/colorimeter/gui/plot/plot.ui

    <rect>
     <x>0</x>
     <y>0</y>
-    <width>514</width>
-    <height>442</height>
+    <width>665</width>
+    <height>420</height>
    </rect>
   </property>
   <property name="windowTitle">
          </property>
          <property name="sizeHint" stdset="0">
           <size>
-           <width>134</width>
+           <width>40</width>
            <height>20</height>
           </size>
          </property>
      </widget>
     </item>
     <item>
+     <widget class="Line" name="line_2">
+      <property name="orientation">
+       <enum>Qt::Horizontal</enum>
+      </property>
+     </widget>
+    </item>
+    <item>
      <widget class="QWidget" name="widget_3" native="true">
       <property name="sizePolicy">
        <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
       </property>
       <layout class="QHBoxLayout" name="horizontalLayout_3">
        <item>
+        <widget class="QLabel" name="samplesLabel">
+         <property name="text">
+          <string>Samples</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QLineEdit" name="samplesLineEdit">
+         <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>
+        </widget>
+       </item>
+       <item>
+        <spacer name="horizontalSpacer_4">
+         <property name="orientation">
+          <enum>Qt::Horizontal</enum>
+         </property>
+         <property name="sizeType">
+          <enum>QSizePolicy::Fixed</enum>
+         </property>
+         <property name="sizeHint" stdset="0">
+          <size>
+           <width>10</width>
+           <height>20</height>
+          </size>
+         </property>
+        </spacer>
+       </item>
+       <item>
         <widget class="QPushButton" name="calibratePushButton">
          <property name="text">
           <string>Calibrate</string>
     <rect>
      <x>0</x>
      <y>0</y>
-     <width>514</width>
+     <width>665</width>
      <height>23</height>
     </rect>
    </property>

File python/Colorimeter/colorimeter/gui/plot/plot_ui.py

 
 # Form implementation generated from reading ui file 'plot.ui'
 #
-# Created: Sat Apr 20 19:32:57 2013
+# Created: Wed Apr 24 17:26:56 2013
 #      by: PyQt4 UI code generator 4.7.2
 #
 # WARNING! All changes made in this file will be lost!
 class Ui_MainWindow(object):
     def setupUi(self, MainWindow):
         MainWindow.setObjectName("MainWindow")
-        MainWindow.resize(514, 442)
+        MainWindow.resize(665, 420)
         self.centralwidget = QtGui.QWidget(MainWindow)
         self.centralwidget.setObjectName("centralwidget")
         self.verticalLayout = QtGui.QVBoxLayout(self.centralwidget)
         self.whiteRadioButton = QtGui.QRadioButton(self.ledColorWidget)
         self.whiteRadioButton.setObjectName("whiteRadioButton")
         self.horizontalLayout_2.addWidget(self.whiteRadioButton)
-        spacerItem1 = QtGui.QSpacerItem(134, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
+        spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
         self.horizontalLayout_2.addItem(spacerItem1)
         self.verticalLayout.addWidget(self.ledColorWidget)
         self.frame = QtGui.QFrame(self.centralwidget)
         self.tableWidget.setRowCount(0)
         self.horizontalLayout_4.addWidget(self.tableWidget)
         self.verticalLayout.addWidget(self.frame)
+        self.line_2 = QtGui.QFrame(self.centralwidget)
+        self.line_2.setFrameShape(QtGui.QFrame.HLine)
+        self.line_2.setFrameShadow(QtGui.QFrame.Sunken)
+        self.line_2.setObjectName("line_2")
+        self.verticalLayout.addWidget(self.line_2)
         self.widget_3 = QtGui.QWidget(self.centralwidget)
         sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed)
         sizePolicy.setHorizontalStretch(0)
         self.widget_3.setObjectName("widget_3")
         self.horizontalLayout_3 = QtGui.QHBoxLayout(self.widget_3)
         self.horizontalLayout_3.setObjectName("horizontalLayout_3")
+        self.samplesLabel = QtGui.QLabel(self.widget_3)
+        self.samplesLabel.setObjectName("samplesLabel")
+        self.horizontalLayout_3.addWidget(self.samplesLabel)
+        self.samplesLineEdit = QtGui.QLineEdit(self.widget_3)
+        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
+        sizePolicy.setHorizontalStretch(0)
+        sizePolicy.setVerticalStretch(0)
+        sizePolicy.setHeightForWidth(self.samplesLineEdit.sizePolicy().hasHeightForWidth())
+        self.samplesLineEdit.setSizePolicy(sizePolicy)
+        self.samplesLineEdit.setMinimumSize(QtCore.QSize(100, 0))
+        self.samplesLineEdit.setMaximumSize(QtCore.QSize(100, 16777215))
+        self.samplesLineEdit.setObjectName("samplesLineEdit")
+        self.horizontalLayout_3.addWidget(self.samplesLineEdit)
+        spacerItem2 = QtGui.QSpacerItem(10, 20, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum)
+        self.horizontalLayout_3.addItem(spacerItem2)
         self.calibratePushButton = QtGui.QPushButton(self.widget_3)
         self.calibratePushButton.setObjectName("calibratePushButton")
         self.horizontalLayout_3.addWidget(self.calibratePushButton)
         self.clearPushButton = QtGui.QPushButton(self.widget_3)
         self.clearPushButton.setObjectName("clearPushButton")
         self.horizontalLayout_3.addWidget(self.clearPushButton)
-        spacerItem2 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
-        self.horizontalLayout_3.addItem(spacerItem2)
+        spacerItem3 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
+        self.horizontalLayout_3.addItem(spacerItem3)
         self.measurePushButton = QtGui.QPushButton(self.widget_3)
         self.measurePushButton.setObjectName("measurePushButton")
         self.horizontalLayout_3.addWidget(self.measurePushButton)
         self.verticalLayout.addWidget(self.widget_3)
         MainWindow.setCentralWidget(self.centralwidget)
         self.menubar = QtGui.QMenuBar(MainWindow)
-        self.menubar.setGeometry(QtCore.QRect(0, 0, 514, 23))
+        self.menubar.setGeometry(QtCore.QRect(0, 0, 665, 23))
         self.menubar.setObjectName("menubar")
         self.menuFile = QtGui.QMenu(self.menubar)
         self.menuFile.setObjectName("menuFile")
         self.greenRadioButton.setText(QtGui.QApplication.translate("MainWindow", "green", None, QtGui.QApplication.UnicodeUTF8))
         self.blueRadioButton.setText(QtGui.QApplication.translate("MainWindow", "blue", None, QtGui.QApplication.UnicodeUTF8))
         self.whiteRadioButton.setText(QtGui.QApplication.translate("MainWindow", "white", None, QtGui.QApplication.UnicodeUTF8))
+        self.samplesLabel.setText(QtGui.QApplication.translate("MainWindow", "Samples", None, QtGui.QApplication.UnicodeUTF8))
         self.calibratePushButton.setText(QtGui.QApplication.translate("MainWindow", "Calibrate", None, QtGui.QApplication.UnicodeUTF8))
         self.clearPushButton.setText(QtGui.QApplication.translate("MainWindow", "Clear", None, QtGui.QApplication.UnicodeUTF8))
         self.measurePushButton.setText(QtGui.QApplication.translate("MainWindow", "Measure", None, QtGui.QApplication.UnicodeUTF8))

File python/Colorimeter/colorimeter/main_window.py

         super(MainWindowCommon,self).__init__(parent)
 
     def connectActions(self):
+        self.samplesLineEdit.editingFinished.connect(self.samplesChanged_Callback)
         self.portLineEdit.editingFinished.connect(self.portChanged_Callback)
         self.connectPushButton.pressed.connect(self.connectPressed_Callback)
         self.connectPushButton.clicked.connect(self.connectClicked_Callback)
         self.aboutCaption = 'About'
         self.aboutText = 'About Default Text'
         self.sensorMode = 'standard'
+        self.numSamples = None
 
         # Set default port based on system
         osType = platform.system()
             QtGui.QMessageBox.warning(self,msgTitle, msgText)
 
     def connectPressed_Callback(self):
-        if self.dev == None:
+        if self.dev is None:
             self.connectPushButton.setText('Disconnect')
             self.connectPushButton.setFlat(True)
             self.portLineEdit.setEnabled(False)
             self.statusbar.showMessage('Connecting...')
 
     def connectClicked_Callback(self):
-        if self.dev == None:
-            if constants.DEVEL_FAKE_MEASURE:
-                self.dev = 'dummy' 
-                connected = True
-            else:
-                try:
-                    self.dev = Colorimeter(self.port)
-                    self.numSamples = self.dev.getNumSamples()
-                    connected = True
-                except Exception, e:
-                    msgTitle = 'Connection Error'
-                    msgText = 'unable to connect to device: {0}'.format(str(e))
-                    QtGui.QMessageBox.warning(self,msgTitle, msgText)
-                    self.connectPushButton.setText('Connect')
-                    self.statusbar.showMessage('Not Connected')
-                    connected = False
-                    self.dev = None
+        if self.dev is None:
+            self.connectDevice()
+        else:
+            self.disconnectDevice()
+        self.updateWidgetEnabled()
+        self.connectPushButton.setFlat(False)
 
+    def connectDevice(self):
+        if constants.DEVEL_FAKE_MEASURE:
+            self.dev = 'dummy' 
+        else:
+            try:
+                self.dev = Colorimeter(self.port)
+                self.numSamples = self.dev.getNumSamples()
+            except Exception, e:
+                msgTitle = 'Connection Error'
+                msgText = 'unable to connect to device: {0}'.format(str(e))
+                QtGui.QMessageBox.warning(self,msgTitle, msgText)
+                self.connectPushButton.setText('Connect')
+                self.statusbar.showMessage('Not Connected')
+                self.dev = None
+            if self.dev is not None:
                 try:
                     if self.isStandardRgbLEDMode():
                         self.dev.setSensorModeColorSpecific()
                     msgTitle = 'Set LED Mode Error'
                     msgText = 'error setting device LED mode: {0}'.format(str(e))
                     QtGui.QMessageBox.warning(self,msgTitle, msgText)
+                self.samplesLineEdit.setText('{0}'.format(self.numSamples))
+
+    def disconnectDevice(self):
+        if constants.DEVEL_FAKE_MEASURE:
+            self.dev = None
         else:
-            if constants.DEVEL_FAKE_MEASURE:
-                self.dev = None
-            else:
-                self.connectPushButton.setText('Connect')
-                try:
-                    self.cleanUpAndCloseDevice()
-                except Exception, e:
-                    QtGui.QMessageBox.critical(self,'Error', str(e))
-            connected = False
+            self.connectPushButton.setText('Connect')
+            try:
+                self.cleanUpAndCloseDevice()
+            except Exception, e:
+                QtGui.QMessageBox.critical(self,'Error', str(e))
+        self.samplesLineEdit.setText('')
 
-        self.updateWidgetEnabled()
-        self.connectPushButton.setFlat(False)
+    def samplesChanged_Callback(self):
+        valueStr = str(self.samplesLineEdit.text())
+        value = int(valueStr)
+        if value != self.numSamples:
+            self.numSamples = value
+            if self.dev is not None:
+                self.dev.setNumSamples(value)
 
     def calibratePressed_Callback(self):
         self.measurePushButton.setEnabled(False)
         if self.dev is None:
             self.actionStandardRgbLED.setEnabled(False)
             self.actionCustomLED.setEnabled(False)
+            self.samplesLineEdit.setEnabled(False)
         else:
             self.actionStandardRgbLED.setEnabled(True)
             self.actionCustomLED.setEnabled(True)
+            self.samplesLineEdit.setEnabled(True)
 
     def main(self):
         self.show()