Przeglądaj źródła

Fixed DICOM without pixel metrics & duplicate calibration display

david 3 lat temu
rodzic
commit
9eedf6f594

+ 7 - 6
api.ipsocloud.com/api/v1/Models/AcquireInterface.class.php

@@ -184,7 +184,7 @@ namespace Models {
         $retval=null;
         exec($cmdLine, $output, $retval);
         // error
-        if($retval !== 0 || (count($output)!=2 && count($output)!=3)) {
+        if($retval !== 0) {
           return [
             'result' => 'ERROR',
             'cmdLine' => $cmdLine,
@@ -192,11 +192,12 @@ namespace Models {
             'retval' => $retval
           ];
         }
-
-        $tab = explode(' ',trim($output[0]));
-        $metrics['pxwidth'] = floatval($tab[2])*10.0;
-        $tab = explode(' ',trim($output[1]));
-        $metrics['pxheight'] = floatval($tab[2])*10.0;
+        if(count($output)>=2) {
+          $tab = explode(' ',trim($output[0]));
+          $metrics['pxwidth'] = floatval($tab[2])*10.0;
+          $tab = explode(' ',trim($output[1]));
+          $metrics['pxheight'] = floatval($tab[2])*10.0;
+        }
         if(count($output)==3) {
           $tab = explode(' ',trim($output[2]));
           $metrics['frameCount'] = intval(str_replace(['[', ']'], '', $tab[2]));

+ 6 - 4
api.ipsocloud.com/api/v1/Models/PatientInterface.class.php

@@ -792,10 +792,12 @@ namespace Models {
                 ];
               }
             }
-            $tab = explode(' ',trim($output[0]));
-            $metrics['pxwidth'] = floatval($tab[2])*10.0;
-            $tab = explode(' ',trim($output[1]));
-            $metrics['pxheight'] = floatval($tab[2])*10.0;
+            if(count($output)) {
+              $tab = explode(' ',trim($output[0]));
+              $metrics['pxwidth'] = floatval($tab[2])*10.0;
+              $tab = explode(' ',trim($output[1]));
+              $metrics['pxheight'] = floatval($tab[2])*10.0;
+            }
     
             // insert new media
             $statement = $this->DataInterface->DatabaseConnection->prepare(

+ 27 - 27
www.ipsocloud.com/webapp_webpack/src/pages/measure.f7.html

@@ -146,7 +146,7 @@
         }
         let isDicom = (this.media[this.currentMediaIndex].filename.indexOf('.dicom')!==-1);
         if(isDicom && 
-           (this.media[this.currentMediaIndex].metrics.pxwidth>=0 && this.media[this.currentMediaIndex].metrics.pxheight>=0)) {
+           (this.media[this.currentMediaIndex].metrics.pxwidth!=0 && this.media[this.currentMediaIndex].metrics.pxheight!=0)) {
           $$('#measure-calibration').addClass('disabled');
         }
         else {
@@ -274,16 +274,7 @@
         // DICOM
         if(this.media[idx].filename.indexOf('.dicom')!==-1) {
           //console.log('dicom', this.media[idx]);
-          let hasCalibration = false;
-          for(let m=0; m<this.media[idx].measure.length; ++m) {
-            if(this.media[idx].measure[m].type=='calibration') {
-              hasCalibration = true;
-              break;
-            }
-          }
-          if(!hasCalibration) {
-            this.addDicomCalibration(idx);
-          }
+          this.addDicomCalibration(idx);
         }
 
         //
@@ -305,22 +296,31 @@
         }
       },
       addDicomCalibration: function(idx) {
-        this.media[idx].measure.push({
-          ID: 0,
-          type: 'calibration',
-          computation: {
-            distance: 20
-          },
-          fk_media: 0,
-          fk_user: 0,
-          points: [{
-            x: this.media[idx].metrics.width-40,
-            y: 50
-          }, {
-            x: this.media[idx].metrics.width-40,
-            y: (50 + 20 / this.media[idx].metrics.pxheight)
-          }]
-        });
+        let hasCalibration = false;
+        for(let m=0; m<this.media[idx].measure.length; ++m) {
+          if(this.media[idx].measure[m].type=='calibration') {
+            hasCalibration = true;
+            break;
+          }
+        }
+        if(!hasCalibration && this.media[idx].metrics.pxwith!=0 && this.media[idx].metrics.pxheight!=0) {
+          this.media[idx].measure.push({
+            ID: 0,
+            type: 'calibration',
+            computation: {
+              distance: 20
+            },
+            fk_media: 0,
+            fk_user: 0,
+            points: [{
+              x: this.media[idx].metrics.width-40,
+              y: 50
+            }, {
+              x: this.media[idx].metrics.width-40,
+              y: (50 + 20 / this.media[idx].metrics.pxheight)
+            }]
+          });
+        }        
       },
       updateMeasureList: function() {
         let txt = '';