854 |
852 |
855 #( |
853 #( |
856 #(#MenuItem |
854 #(#MenuItem |
857 #label: '8-Plane' |
855 #label: '8-Plane' |
858 #translateLabel: true |
856 #translateLabel: true |
|
857 #value: #colorMapMode: |
859 #activeHelpKey: #colorMap8 |
858 #activeHelpKey: #colorMap8 |
860 #argument: '8-plane' |
859 #argument: '8-plane' |
861 #indication: #colorMapMode:value: |
860 #choice: #colorMapMode |
|
861 #choiceValue: '8-plane' |
862 ) |
862 ) |
863 #(#MenuItem |
863 #(#MenuItem |
864 #label: '4-Plane' |
864 #label: '4-Plane' |
865 #translateLabel: true |
865 #translateLabel: true |
|
866 #value: #colorMapMode: |
866 #activeHelpKey: #colorMap4 |
867 #activeHelpKey: #colorMap4 |
867 #argument: '4-plane' |
868 #argument: '4-plane' |
868 #indication: #colorMapMode:value: |
869 #choice: #colorMapMode |
|
870 #choiceValue: '4-plane' |
869 ) |
871 ) |
870 #(#MenuItem |
872 #(#MenuItem |
871 #label: '2-Plane' |
873 #label: '2-Plane' |
872 #translateLabel: true |
874 #translateLabel: true |
|
875 #value: #colorMapMode: |
873 #activeHelpKey: #colorMap2 |
876 #activeHelpKey: #colorMap2 |
874 #argument: '2-plane' |
877 #argument: '2-plane' |
875 #indication: #colorMapMode:value: |
878 #choice: #colorMapMode |
|
879 #choiceValue: '2-plane' |
876 ) |
880 ) |
877 #(#MenuItem |
881 #(#MenuItem |
878 #label: '1-Plane' |
882 #label: '1-Plane' |
879 #translateLabel: true |
883 #translateLabel: true |
|
884 #value: #colorMapMode: |
880 #activeHelpKey: #colorMap1 |
885 #activeHelpKey: #colorMap1 |
881 #argument: '1-plane' |
886 #argument: '1-plane' |
882 #indication: #colorMapMode:value: |
887 #choice: #colorMapMode |
|
888 #choiceValue: '1-plane' |
883 ) |
889 ) |
884 #(#MenuItem |
890 #(#MenuItem |
885 #label: '-' |
891 #label: '-' |
886 ) |
892 ) |
887 #(#MenuItem |
893 #(#MenuItem |
888 #label: '8-Plane + Mask' |
894 #label: '8-Plane + Mask' |
889 #translateLabel: true |
895 #translateLabel: true |
|
896 #value: #colorMapMode: |
890 #activeHelpKey: #colorMap8M |
897 #activeHelpKey: #colorMap8M |
891 #argument: '8-plane + mask' |
898 #argument: '8-plane + mask' |
892 #indication: #colorMapMode:value: |
899 #choice: #colorMapMode |
|
900 #choiceValue: '8-plane + mask' |
893 ) |
901 ) |
894 #(#MenuItem |
902 #(#MenuItem |
895 #label: '4-Plane + Mask' |
903 #label: '4-Plane + Mask' |
896 #translateLabel: true |
904 #translateLabel: true |
|
905 #value: #colorMapMode: |
897 #activeHelpKey: #colorMap4M |
906 #activeHelpKey: #colorMap4M |
898 #argument: '4-plane + mask' |
907 #argument: '4-plane + mask' |
899 #indication: #colorMapMode:value: |
908 #choice: #colorMapMode |
|
909 #choiceValue: '4-plane + mask' |
900 ) |
910 ) |
901 #(#MenuItem |
911 #(#MenuItem |
902 #label: '2-Plane + Mask' |
912 #label: '2-Plane + Mask' |
903 #translateLabel: true |
913 #translateLabel: true |
|
914 #value: #colorMapMode: |
904 #activeHelpKey: #colorMap2M |
915 #activeHelpKey: #colorMap2M |
905 #argument: '2-plane + mask' |
916 #argument: '2-plane + mask' |
906 #indication: #colorMapMode:value: |
917 #choice: #colorMapMode |
|
918 #choiceValue: '2-plane + mask' |
907 ) |
919 ) |
908 #(#MenuItem |
920 #(#MenuItem |
909 #label: '1-Plane + Mask' |
921 #label: '1-Plane + Mask' |
910 #translateLabel: true |
922 #translateLabel: true |
|
923 #value: #colorMapMode: |
911 #activeHelpKey: #colorMap1M |
924 #activeHelpKey: #colorMap1M |
912 #argument: '1-plane + mask' |
925 #argument: '1-plane + mask' |
913 #indication: #colorMapMode:value: |
926 #choice: #colorMapMode |
|
927 #choiceValue: '1-plane + mask' |
914 ) |
928 ) |
915 #(#MenuItem |
929 #(#MenuItem |
916 #label: '-' |
930 #label: '-' |
917 ) |
931 ) |
918 #(#MenuItem |
932 #(#MenuItem |
991 #( |
1003 #( |
992 #(#MenuItem |
1004 #(#MenuItem |
993 #label: 'Left Mouse Button' |
1005 #label: 'Left Mouse Button' |
994 #nameKey: #leftMouseKeyButton |
1006 #nameKey: #leftMouseKeyButton |
995 #activeHelpKey: #mouseKeyColorMode |
1007 #activeHelpKey: #mouseKeyColorMode |
996 #argument: '1' |
1008 #enabled: #imageIsLoaded |
997 #labelImage: #(#ResourceRetriever nil #leftMouseKeyIcon) |
1009 #labelImage: #(#ResourceRetriever nil #leftMouseKeyIcon) |
998 #indication: #mouseKeyColorMode:value: |
1010 #choice: #mouseKeyColorMode |
|
1011 #choiceValue: 1 |
999 ) |
1012 ) |
1000 #(#MenuItem |
1013 #(#MenuItem |
1001 #label: 'Right Mouse Button' |
1014 #label: 'Right Mouse Button' |
1002 #nameKey: #rightMouseKeyButton |
1015 #nameKey: #rightMouseKeyButton |
1003 #activeHelpKey: #mouseKeyColorMode |
1016 #activeHelpKey: #mouseKeyColorMode |
1004 #argument: '2' |
1017 #enabled: #imageIsLoaded |
1005 #labelImage: #(#ResourceRetriever nil #rightMouseKeyIcon) |
1018 #labelImage: #(#ResourceRetriever nil #rightMouseKeyIcon) |
1006 #indication: #mouseKeyColorMode:value: |
1019 #choice: #mouseKeyColorMode |
|
1020 #choiceValue: 2 |
1007 ) |
1021 ) |
1008 ) nil |
1022 ) nil |
1009 nil |
1023 nil |
1010 ) |
1024 ) |
1011 ! |
1025 ! |
1065 ) |
1079 ) |
1066 #(#MenuItem |
1080 #(#MenuItem |
1067 #label: 'Point' |
1081 #label: 'Point' |
1068 #activeHelpKey: #drawModePoint |
1082 #activeHelpKey: #drawModePoint |
1069 #enabled: #imageIsLoaded |
1083 #enabled: #imageIsLoaded |
1070 #argument: 'point' |
1084 #choice: #editMode |
1071 #indication: #editMode:value: |
1085 #choiceValue: #point |
1072 ) |
1086 ) |
1073 #(#MenuItem |
1087 #(#MenuItem |
1074 #label: 'Box' |
1088 #label: 'Box' |
1075 #activeHelpKey: #drawModeBox |
1089 #activeHelpKey: #drawModeBox |
1076 #enabled: #imageIsLoaded |
1090 #enabled: #imageIsLoaded |
1077 #argument: 'box' |
1091 #choice: #editMode |
1078 #indication: #editMode:value: |
1092 #choiceValue: #box |
1079 ) |
1093 ) |
1080 #(#MenuItem |
1094 #(#MenuItem |
1081 #label: 'Filled Box' |
1095 #label: 'Filled Box' |
1082 #activeHelpKey: #drawModeFilledBox |
1096 #activeHelpKey: #drawModeFilledBox |
1083 #enabled: #imageIsLoaded |
1097 #enabled: #imageIsLoaded |
1084 #argument: 'filledBox' |
1098 #choice: #editMode |
1085 #indication: #editMode:value: |
1099 #choiceValue: #filledBox |
1086 ) |
1100 ) |
1087 #(#MenuItem |
1101 #(#MenuItem |
1088 #label: 'Fill' |
1102 #label: 'Fill' |
1089 #activeHelpKey: #drawModeFill |
1103 #activeHelpKey: #drawModeFill |
1090 #enabled: #imageIsLoaded |
1104 #enabled: #imageIsLoaded |
1091 #argument: 'fill' |
1105 #choice: #editMode |
1092 #indication: #editMode:value: |
1106 #choiceValue: #fill |
1093 ) |
1107 ) |
1094 #(#MenuItem |
1108 #(#MenuItem |
1095 #label: 'Copy' |
1109 #label: 'Copy' |
1096 #activeHelpKey: #drawModeCopy |
1110 #activeHelpKey: #drawModeCopy |
1097 #enabled: #imageIsLoaded |
1111 #enabled: #imageIsLoaded |
1098 #argument: 'copy' |
1112 #choice: #editMode |
1099 #indication: #editMode:value: |
1113 #choiceValue: #copy |
1100 ) |
1114 ) |
1101 #(#MenuItem |
1115 #(#MenuItem |
1102 #label: 'Paste' |
1116 #label: 'Paste' |
1103 #activeHelpKey: #drawModePaste |
1117 #activeHelpKey: #drawModePaste |
1104 #enabled: #imageIsLoaded |
1118 #enabled: #imageIsLoaded |
1105 #argument: 'paste' |
1119 #choice: #editMode |
1106 #indication: #editMode:value: |
1120 #choiceValue: #paste |
1107 ) |
1121 ) |
1108 #(#MenuItem |
1122 #(#MenuItem |
1109 #label: 'Paste Under' |
1123 #label: 'Paste Under' |
1110 #activeHelpKey: #drawModePasteUnder |
1124 #activeHelpKey: #drawModePasteUnder |
1111 #enabled: #imageIsLoaded |
1125 #enabled: #imageIsLoaded |
1112 #argument: 'pasteUnder' |
1126 #choice: #editMode |
1113 #indication: #editMode:value: |
1127 #choiceValue: #pasteUnder |
1114 ) |
1128 ) |
1115 ) nil |
1129 ) nil |
1116 nil |
1130 nil |
1117 ) |
1131 ) |
1118 ! ! |
1132 ! ! |
1251 !ImageEditor methodsFor:'change & update'! |
1265 !ImageEditor methodsFor:'change & update'! |
1252 |
1266 |
1253 findColorMapMode |
1267 findColorMapMode |
1254 "finds the colorMapMode for a new image" |
1268 "finds the colorMapMode for a new image" |
1255 |
1269 |
1256 self image depth > 8 ifTrue: [colorMapMode := ''. self listOfColors removeAll. ^nil]. |
1270 self image depth > 8 ifTrue: [colorMapMode value: ''. self listOfColors removeAll. ^nil]. |
1257 colorMapMode := self image depth printString, '-plane'. |
1271 |
|
1272 colorMapMode setValue: self image depth printString, '-plane'. |
|
1273 |
1258 self listOfColors isEmpty |
1274 self listOfColors isEmpty |
1259 ifTrue: |
1275 ifTrue: |
1260 [ |
1276 [ |
1261 self colorMapMode: colorMapMode value: nil |
1277 self colorMapMode: colorMapMode value |
1262 ]. |
1278 ]. |
1263 imageEditView selectColors: (Array with: (self listOfColors at: 1) with: (self listOfColors at: 2 ifAbsent: [self listOfColors at: 1])). |
1279 imageEditView selectColors: (Array with: (self listOfColors at: 1) with: (self listOfColors at: 2 ifAbsent: [self listOfColors at: 1])). |
1264 |
1280 |
1265 self image mask notNil |
1281 self image mask notNil |
1266 ifTrue: |
1282 ifTrue: |
1267 [ |
1283 [ |
1268 colorMapMode := colorMapMode, ' + mask'. |
1284 colorMapMode setValue: colorMapMode value, ' + mask'. |
|
1285 |
1269 (self listOfColors detect: [:clr| clr = (Color basicNew setColorId:0)] ifNone: nil) isNil |
1286 (self listOfColors detect: [:clr| clr = (Color basicNew setColorId:0)] ifNone: nil) isNil |
1270 ifTrue: |
1287 ifTrue: |
1271 [ |
1288 [ |
1272 self listOfColors addFirst: (Color basicNew setColorId:0). |
1289 self listOfColors addFirst: (Color basicNew setColorId:0). |
1273 imageEditView selectColors: (Array with: (self listOfColors at: 2 ifAbsent: [self listOfColors at: 1]) with: (self listOfColors at: 1)). |
1290 imageEditView selectColors: (Array with: (self listOfColors at: 2 ifAbsent: [self listOfColors at: 1]) with: (self listOfColors at: 1)). |
1522 self updateLabelsAndHistory. |
1539 self updateLabelsAndHistory. |
1523 ! ! |
1540 ! ! |
1524 |
1541 |
1525 !ImageEditor methodsFor:'menu modes'! |
1542 !ImageEditor methodsFor:'menu modes'! |
1526 |
1543 |
1527 colorMapMode: aMode |
1544 colorMapMode |
1528 "returns whether colorMapMode is equal to aMode" |
1545 "returns colorMapMode" |
1529 |
1546 |
1530 ^colorMapMode = aMode |
1547 colorMapMode isNil ifTrue: [colorMapMode := '' asValue]. |
1531 ! |
1548 |
1532 |
1549 ^colorMapMode |
1533 editMode: aMode |
1550 ! |
1534 "returns whether editMode is equal to aMode" |
1551 |
1535 |
1552 editMode |
1536 ^ imageEditView notNil and:[imageEditView editMode = aMode] |
1553 "returns editMode" |
1537 ! |
1554 |
1538 |
1555 editMode isNil |
1539 editMode: aMode value: aValue |
1556 ifTrue: |
1540 "sets the editMode to aMode" |
1557 [ |
1541 |
1558 editMode := #point asValue. |
1542 imageEditView editMode: aMode |
1559 editMode onChangeSend: #value to: [imageEditView editMode: editMode value] |
1543 ! |
|
1544 |
|
1545 mouseKeyColorMode: aMode |
|
1546 "sets the mouseKeyColorMode to aMode" |
|
1547 |
|
1548 imageEditView isNil ifTrue:[ |
|
1549 ^ true |
|
1550 ]. |
1560 ]. |
1551 ^imageEditView mouseKeyColorMode = aMode |
1561 |
1552 ! |
1562 ^editMode |
1553 |
1563 ! |
1554 mouseKeyColorMode: aMode value: aValue |
1564 |
1555 "sets the mouseKeyColorMode to aMode" |
1565 mouseKeyColorMode |
1556 |
1566 "returns mouseKeyColorMode" |
1557 imageEditView mouseKeyColorMode: aMode. |
1567 |
1558 |
1568 mouseKeyColorMode isNil |
1559 self selectionOfColor value: (self listOfColors indexOf: imageEditView selectedColor). |
1569 ifTrue: |
|
1570 [ |
|
1571 mouseKeyColorMode := 1 asValue. |
|
1572 mouseKeyColorMode onChangeSend: #value to: [imageEditView mouseKeyColorMode: mouseKeyColorMode value. self selectionOfColor value: (self listOfColors indexOf: imageEditView selectedColor).] |
|
1573 ]. |
|
1574 |
|
1575 ^mouseKeyColorMode |
1560 ! ! |
1576 ! ! |
1561 |
1577 |
1562 !ImageEditor methodsFor:'queries'! |
1578 !ImageEditor methodsFor:'queries'! |
1563 |
1579 |
1564 hasMask |
1580 hasMask |
1565 ^ colorMapMode notNil and:[colorMapMode endsWith:'mask'] |
1581 ^ colorMapMode notNil and:[colorMapMode value endsWith:'mask'] |
1566 |
1582 |
1567 "Created: / 18.8.1998 / 17:17:38 / cg" |
1583 "Created: / 18.8.1998 / 17:17:38 / cg" |
1568 ! |
1584 ! |
1569 |
1585 |
1570 preferredExtent |
1586 preferredExtent |
1676 depth == 1 ifTrue:[ |
1693 depth == 1 ifTrue:[ |
1677 quest := 'Keep colormap (or use standard B&W)' |
1694 quest := 'Keep colormap (or use standard B&W)' |
1678 ] ifFalse:[ |
1695 ] ifFalse:[ |
1679 quest := 'Keep colormap (or use standard)' |
1696 quest := 'Keep colormap (or use standard)' |
1680 ]. |
1697 ]. |
1681 ((colorMapMode == aMode) |
1698 ((colorMapMode value = aMode) |
1682 or:[self confirm:(resources string:quest)]) ifTrue:[ |
1699 or:[self confirm:(resources string:quest)]) ifTrue:[ |
1683 "/ keep the colormap |
1700 "/ keep the colormap |
1684 depth > oldImage depth ifTrue:[ |
1701 depth > oldImage depth ifTrue:[ |
1685 "/ easy - simply copy the part |
1702 "/ easy - simply copy the part |
1686 numColors := 1 bitShift:oldImage depth. |
1703 numColors := 1 bitShift:oldImage depth. |
2066 |width height cMap imageClass image| |
2082 |width height cMap imageClass image| |
2067 |
2083 |
2068 width := 128 min: (Integer readFromString: ((aspects at:#selectionOfSize) value upTo: $x) onError:[24]). |
2084 width := 128 min: (Integer readFromString: ((aspects at:#selectionOfSize) value upTo: $x) onError:[24]). |
2069 height := 128 min: (Integer readFromString: ((aspects at:#selectionOfSize) value copy reverse upTo: $x) reverse onError:[24]). |
2085 height := 128 min: (Integer readFromString: ((aspects at:#selectionOfSize) value copy reverse upTo: $x) reverse onError:[24]). |
2070 |
2086 |
2071 cMap := (self class listOfColorMaps at: (colorMapMode := (aspects at:#selectionOfColorMap) value)). |
2087 cMap := (self class listOfColorMaps at: (colorMapMode value: (aspects at:#selectionOfColorMap) value) value). |
2072 imageClass := Image implementorForDepth: ((cMap size log: 2) asInteger). |
2088 imageClass := Image implementorForDepth: ((cMap size log: 2) asInteger). |
2073 image := imageClass width: width height: height fromArray: (ByteArray new: width*height). |
2089 image := imageClass width: width height: height fromArray: (ByteArray new: width*height). |
2074 |
2090 |
2075 (colorMapMode copy reverse readStream nextWord reverse = 'mask') |
2091 (colorMapMode value endsWith: 'mask') |
2076 ifTrue: |
2092 ifTrue: |
2077 [ |
2093 [ |
2078 image mask: (Depth1Image width: width height: height depth: 1 fromArray: (ByteArray new: width*height)) clearMaskedPixels |
2094 image mask: (Depth1Image width: width height: height depth: 1 fromArray: (ByteArray new: width*height)) clearMaskedPixels |
2079 ]. |
2095 ]. |
2080 image colorMap: cMap. |
2096 image colorMap: cMap. |