ImageEditor.st
changeset 405 8546da96ab11
parent 401 30ecf82e3ae7
child 415 f792d83774b3
equal deleted inserted replaced
404:35982cf1482f 405:8546da96ab11
     2  COPYRIGHT (c) 1997 by eXept Software AG / Thomas Zwick
     2  COPYRIGHT (c) 1997 by eXept Software AG / Thomas Zwick
     3               All Rights Reserved
     3               All Rights Reserved
     4 
     4 
     5  This software is furnished under a license and may be used
     5  This software is furnished under a license and may be used
     6  only in accordance with the terms of that license and with the
     6  only in accordance with the terms of that license and with the
     7  inclusion of the above copyright notice.   This software may not
     7  inclusion of the above copyright notice. This software may not
     8  be provided or otherwise made available to, or used by, any
     8  be provided or otherwise made available to, or used by, any
     9  other person.  No title to or ownership of the software is
     9  other person. No title to or ownership of the software is
    10  hereby transferred.
    10  hereby transferred.
    11 "
    11 "
    12 
    12 
    13 ToolApplicationModel subclass:#ImageEditor
    13 ToolApplicationModel subclass:#ImageEditor
    14 	instanceVariableNames:'colorMapMode selectedColorIndex postOpenAction'
    14 	instanceVariableNames:'colorMapMode selectedColorIndex postOpenAction'
    24  COPYRIGHT (c) 1997 by eXept Software AG / Thomas Zwick
    24  COPYRIGHT (c) 1997 by eXept Software AG / Thomas Zwick
    25               All Rights Reserved
    25               All Rights Reserved
    26 
    26 
    27  This software is furnished under a license and may be used
    27  This software is furnished under a license and may be used
    28  only in accordance with the terms of that license and with the
    28  only in accordance with the terms of that license and with the
    29  inclusion of the above copyright notice.   This software may not
    29  inclusion of the above copyright notice. This software may not
    30  be provided or otherwise made available to, or used by, any
    30  be provided or otherwise made available to, or used by, any
    31  other person.  No title to or ownership of the software is
    31  other person. No title to or ownership of the software is
    32  hereby transferred.
    32  hereby transferred.
    33 "
    33 "
    34 !
    34 !
    35 
    35 
    36 documentation
    36 documentation
   522      
   522      
   523        #(#FullSpec
   523        #(#FullSpec
   524           #'window:' 
   524           #'window:' 
   525            #(#WindowSpec
   525            #(#WindowSpec
   526               #'name:' 'Image Editor'
   526               #'name:' 'Image Editor'
   527               #'layout:' #(#LayoutFrame 364 0 199 0 863 0 544 0)
   527               #'layout:' #(#LayoutFrame 368 0 254 0 867 0 599 0)
   528               #'label:' 'Image Editor'
   528               #'label:' 'Image Editor'
   529               #'min:' #(#Point 400 320)
   529               #'min:' #(#Point 400 320)
   530               #'max:' #(#Point 1152 900)
   530               #'max:' #(#Point 1152 900)
   531               #'bounds:' #(#Rectangle 364 199 864 545)
   531               #'bounds:' #(#Rectangle 368 254 868 600)
   532               #'menu:' #menu
   532               #'menu:' #menu
   533               #'usePreferredExtent:' false
   533               #'usePreferredExtent:' false
   534           )
   534           )
   535           #'component:' 
   535           #'component:' 
   536            #(#SpecCollection
   536            #(#SpecCollection
   650                                         #'labelPosition:' #topLeft
   650                                         #'labelPosition:' #topLeft
   651                                         #'style:' #(#FontDescription #helvetica #medium #roman 12)
   651                                         #'style:' #(#FontDescription #helvetica #medium #roman 12)
   652                                     )
   652                                     )
   653                                      #(#VerticalPanelViewSpec
   653                                      #(#VerticalPanelViewSpec
   654                                         #'name:' 'verticalPanelView1'
   654                                         #'name:' 'verticalPanelView1'
   655                                         #'layout:' #(#LayoutFrame 1 0.0 -68 1 70 0 0 1.0)
   655                                         #'layout:' #(#LayoutFrame 1 0.0 -68 1 83 0 0 1.0)
   656                                         #'component:' 
   656                                         #'component:' 
   657                                          #(#SpecCollection
   657                                          #(#SpecCollection
   658                                             #'collection:' 
   658                                             #'collection:' 
   659                                              #(
   659                                              #(
   660                                                #(#LabelSpec
   660                                                #(#LabelSpec
   661                                                   #'name:' 'classNameLabel'
   661                                                   #'name:' 'classNameLabel'
   662                                                   #'label:' 'Class:'
   662                                                   #'label:' 'Class:'
   663                                                   #'adjust:' #right
   663                                                   #'adjust:' #right
   664                                                   #'extent:' #(#Point 69 21)
   664                                                   #'extent:' #(#Point 82 21)
   665                                               )
   665                                               )
   666                                                #(#LabelSpec
   666                                                #(#LabelSpec
   667                                                   #'name:' 'selectorLabel'
   667                                                   #'name:' 'selectorLabel'
   668                                                   #'label:' 'Selector:'
   668                                                   #'label:' 'Selector:'
   669                                                   #'adjust:' #right
   669                                                   #'adjust:' #right
   670                                                   #'extent:' #(#Point 69 20)
   670                                                   #'extent:' #(#Point 82 20)
   671                                               )
   671                                               )
   672                                                #(#LabelSpec
   672                                                #(#LabelSpec
   673                                                   #'name:' 'fileNameLabel'
   673                                                   #'name:' 'fileNameLabel'
   674                                                   #'label:' 'File Name:'
   674                                                   #'label:' 'File Name:'
   675                                                   #'adjust:' #right
   675                                                   #'adjust:' #right
   676                                                   #'extent:' #(#Point 69 21)
   676                                                   #'extent:' #(#Point 82 21)
   677                                               )
   677                                               )
   678                                             )
   678                                             )
   679                                         )
   679                                         )
   680                                         #'horizontalLayout:' #fit
   680                                         #'horizontalLayout:' #fit
   681                                         #'verticalLayout:' #fit
   681                                         #'verticalLayout:' #fit
   682                                         #'horizontalSpace:' 3
   682                                         #'horizontalSpace:' 3
   683                                         #'verticalSpace:' 3
   683                                         #'verticalSpace:' 3
   684                                     )
   684                                     )
   685                                      #(#VerticalPanelViewSpec
   685                                      #(#VerticalPanelViewSpec
   686                                         #'name:' 'verticalPanelView2'
   686                                         #'name:' 'verticalPanelView2'
   687                                         #'layout:' #(#LayoutFrame 72 0.0 -68 1 -6 1 0 1.0)
   687                                         #'layout:' #(#LayoutFrame 85 0.0 -68 1 -6 1 0 1.0)
   688                                         #'component:' 
   688                                         #'component:' 
   689                                          #(#SpecCollection
   689                                          #(#SpecCollection
   690                                             #'collection:' 
   690                                             #'collection:' 
   691                                              #(
   691                                              #(
   692                                                #(#InputFieldSpec
   692                                                #(#InputFieldSpec
   693                                                   #'name:' 'resourceClassInputField'
   693                                                   #'name:' 'resourceClassInputField'
   694                                                   #'activeHelpKey:' #classNameInputField
   694                                                   #'activeHelpKey:' #classNameInputField
   695                                                   #'model:' #valueOfResourceClass
   695                                                   #'model:' #valueOfResourceClass
   696                                                   #'immediateAccept:' false
   696                                                   #'immediateAccept:' false
   697                                                   #'extent:' #(#Point 142 21)
   697                                                   #'extent:' #(#Point 129 21)
   698                                               )
   698                                               )
   699                                                #(#InputFieldSpec
   699                                                #(#InputFieldSpec
   700                                                   #'name:' 'resourceSelectorInputField'
   700                                                   #'name:' 'resourceSelectorInputField'
   701                                                   #'activeHelpKey:' #selectorInputFieldHelp
   701                                                   #'activeHelpKey:' #selectorInputFieldHelp
   702                                                   #'model:' #valueOfResourceSelector
   702                                                   #'model:' #valueOfResourceSelector
   703                                                   #'immediateAccept:' false
   703                                                   #'immediateAccept:' false
   704                                                   #'acceptOnTab:' false
   704                                                   #'acceptOnTab:' false
   705                                                   #'extent:' #(#Point 142 20)
   705                                                   #'extent:' #(#Point 129 20)
   706                                               )
   706                                               )
   707                                                #(#InputFieldSpec
   707                                                #(#InputFieldSpec
   708                                                   #'name:' 'fileNameInputField'
   708                                                   #'name:' 'fileNameInputField'
   709                                                   #'activeHelpKey:' #fileNameInputFieldHelp
   709                                                   #'activeHelpKey:' #fileNameInputFieldHelp
   710                                                   #'model:' #valueOfFileName
   710                                                   #'model:' #valueOfFileName
   711                                                   #'immediateAccept:' false
   711                                                   #'immediateAccept:' false
   712                                                   #'acceptOnTab:' false
   712                                                   #'acceptOnTab:' false
   713                                                   #'extent:' #(#Point 142 21)
   713                                                   #'extent:' #(#Point 129 21)
   714                                               )
   714                                               )
   715                                             )
   715                                             )
   716                                         )
   716                                         )
   717                                         #'horizontalLayout:' #fit
   717                                         #'horizontalLayout:' #fit
   718                                         #'verticalLayout:' #fit
   718                                         #'verticalLayout:' #fit
   762                     #'level:' 1
   762                     #'level:' 1
   763                     #'adjust:' #left
   763                     #'adjust:' #left
   764                 )
   764                 )
   765                  #(#LabelSpec
   765                  #(#LabelSpec
   766                     #'name:' 'timeLabel'
   766                     #'name:' 'timeLabel'
   767                     #'layout:' #(#LayoutFrame -65 1 -22 1 0 1.0 0 1.0)
   767                     #'layout:' #(#LayoutFrame -80 1 -22 1 0 1.0 0 1.0)
   768                     #'labelChannel:' #valueOfTimeLabel
   768                     #'labelChannel:' #valueOfTimeLabel
   769                     #'level:' 1
   769                     #'level:' 1
   770                     #'adjust:' #right
   770                     #'adjust:' #right
   771                 )
   771                 )
   772                  #(#LabelSpec
   772                  #(#LabelSpec
   773                     #'name:' 'coordLabel'
   773                     #'name:' 'coordLabel'
   774                     #'layout:' #(#LayoutFrame -170 1 -22 1 -65 1 0 1.0)
   774                     #'layout:' #(#LayoutFrame -170 1 -22 1 -80 1 0 1.0)
   775                     #'labelChannel:' #valueOfCoordLabel
   775                     #'labelChannel:' #valueOfCoordLabel
   776                     #'level:' 1
   776                     #'level:' 1
   777                     #'adjust:' #left
   777                     #'adjust:' #left
   778                 )
   778                 )
   779               )
   779               )
  1112     ^colorMapMode = aMode
  1112     ^colorMapMode = aMode
  1113 !
  1113 !
  1114 
  1114 
  1115 colorMapMode: aMode value: aValue
  1115 colorMapMode: aMode value: aValue
  1116 
  1116 
  1117     |depth newColorMap newImage image newColors oldFileName| 
  1117     |depth newColorMap newImage image newColors realColorMap oldFileName| 
  1118 
  1118 
  1119     newColorMap := self class listOfColorMaps at: aMode.
  1119     newColorMap := self class listOfColorMaps at: aMode.
  1120     depth := (newColorMap size log: 2) asInteger. 
  1120     depth := (newColorMap size log: 2) asInteger. 
  1121     newImage := (Image implementorForDepth: depth) new.  
  1121     newImage := (Image implementorForDepth: depth) new.  
  1122     oldFileName := self image fileName.
  1122     oldFileName := self image fileName.
  1151         ].
  1151         ].
  1152     ]
  1152     ]
  1153     ifFalse:
  1153     ifFalse:
  1154     [ 
  1154     [ 
  1155         image mask: nil.
  1155         image mask: nil.
  1156     ].
  1156     ]. 
  1157     newColors := (image realColorMap copyFrom: 1 to: (newColorMap size min: image realColorMap size)) asOrderedCollection.
  1157     realColorMap := OrderedCollection new.
       
  1158     image realColorMap do:
       
  1159     [:clr|
       
  1160         (realColorMap includes: clr) ifFalse: [realColorMap add: clr]
       
  1161     ].
       
  1162     newColors := realColorMap copyFrom: 1 to: (newColorMap size min: realColorMap size).
  1158     newColorMap do:
  1163     newColorMap do:
  1159     [:clr|
  1164     [:clr|
  1160         ((newColors size < newColorMap size) and: [(newColors includes: clr) not]) 
  1165         ((newColors size < newColorMap size) and: [(newColors includes: clr) not]) 
  1161         ifTrue:
  1166         ifTrue:
  1162         [      
  1167         [      
  1163             newColors add: clr
  1168             newColors add: clr
  1164         ]
  1169         ]
  1165     ].
  1170     ].       
  1166     image colorMap: newColors.
  1171     image colorMap: newColors.
  1167     colorMapMode := aMode.
  1172     colorMapMode := aMode.
  1168     (self imageEditView image: image) notNil
  1173     (self imageEditView image: image) notNil
  1169     ifTrue:
  1174     ifTrue:
  1170     [
  1175     [