WiseImage Open Architecture Lessons “Mission Impossible”
-
Upload
horatio-simpson -
Category
Documents
-
view
217 -
download
0
Transcript of WiseImage Open Architecture Lessons “Mission Impossible”
![Page 1: WiseImage Open Architecture Lessons “Mission Impossible”](https://reader036.fdocuments.us/reader036/viewer/2022062423/5697bfdb1a28abf838cb090e/html5/thumbnails/1.jpg)
WiseImage Open Architecture
Lessons
“Mission Impossible”
![Page 2: WiseImage Open Architecture Lessons “Mission Impossible”](https://reader036.fdocuments.us/reader036/viewer/2022062423/5697bfdb1a28abf838cb090e/html5/thumbnails/2.jpg)
Objectives
• Learn how to use Active Script studio
• Create a new command that scales your image– Measure the distance– Convert it to paper units– Get prompted for a desired distance– Scale the image
![Page 3: WiseImage Open Architecture Lessons “Mission Impossible”](https://reader036.fdocuments.us/reader036/viewer/2022062423/5697bfdb1a28abf838cb090e/html5/thumbnails/3.jpg)
Preparation
• Open Active Script Studio• Observe the tools
– File operations
– Edit, Search and Undo
– Run, FormWizard and Reference
• Let’s start
![Page 4: WiseImage Open Architecture Lessons “Mission Impossible”](https://reader036.fdocuments.us/reader036/viewer/2022062423/5697bfdb1a28abf838cb090e/html5/thumbnails/4.jpg)
Step 1:Measure Distance
![Page 5: WiseImage Open Architecture Lessons “Mission Impossible”](https://reader036.fdocuments.us/reader036/viewer/2022062423/5697bfdb1a28abf838cb090e/html5/thumbnails/5.jpg)
Step 1: Discussion
• Root objects like Document, Command
• Interaction with user – messages, prompts, forms
• Choosers – important interactive objects
![Page 6: WiseImage Open Architecture Lessons “Mission Impossible”](https://reader036.fdocuments.us/reader036/viewer/2022062423/5697bfdb1a28abf838cb090e/html5/thumbnails/6.jpg)
Step 1: Execution
• Save your script
• Create a toolbar for your brilliant commands
• Assign a new button to your command
• Run it!
![Page 7: WiseImage Open Architecture Lessons “Mission Impossible”](https://reader036.fdocuments.us/reader036/viewer/2022062423/5697bfdb1a28abf838cb090e/html5/thumbnails/7.jpg)
Step 2: Paper Units
• Coordinate systems: WCS, UCS, units
• What are paper units?
• How to convert data to paper units and back to world units?
• Useful transformation object - Transformer
![Page 8: WiseImage Open Architecture Lessons “Mission Impossible”](https://reader036.fdocuments.us/reader036/viewer/2022062423/5697bfdb1a28abf838cb090e/html5/thumbnails/8.jpg)
Step 2: Code changes
Add transformation functionfunction ToPaperUnits(val){ with (Document.CoordinateSystem.PaperUnit) { val = W2U.Direct(val); return D2S(val); }}
Command.Alert("Distance is " + org_dist);
Modify your previous code by replacing
with
Command.Alert("Distance is " + ToPaperUnits(org_dist));
![Page 9: WiseImage Open Architecture Lessons “Mission Impossible”](https://reader036.fdocuments.us/reader036/viewer/2022062423/5697bfdb1a28abf838cb090e/html5/thumbnails/9.jpg)
Step 2: Execution
Change units to inches
Run the command again
Run your command
What is the difference?
![Page 10: WiseImage Open Architecture Lessons “Mission Impossible”](https://reader036.fdocuments.us/reader036/viewer/2022062423/5697bfdb1a28abf838cb090e/html5/thumbnails/10.jpg)
Step 3: Be Interactive!
• Script commands can be interactive
• How to get response from user?– Alert – a simple reply yes or no– Prompt – get some literate response– Forms – the most sophisticated and flexible
way
![Page 11: WiseImage Open Architecture Lessons “Mission Impossible”](https://reader036.fdocuments.us/reader036/viewer/2022062423/5697bfdb1a28abf838cb090e/html5/thumbnails/11.jpg)
Step 3: Code changes
Modify your previous code by replacing
var res = Command.Prompt( "You have measured the distance " + ToPaperUnits(org_dist) + "\r\nEnter the required distance", "Scale Image");try { var new_dist = ToWorldUnits(res); if (new_dist == 0.0) Command.Quit(); Command.Alert(new_dist);}catch (e) { Command.Alert(e);}// TODO: Add ToWorldUnits() code
Command.Alert("Distance is " + org_dist);
with
![Page 12: WiseImage Open Architecture Lessons “Mission Impossible”](https://reader036.fdocuments.us/reader036/viewer/2022062423/5697bfdb1a28abf838cb090e/html5/thumbnails/12.jpg)
Step 3: Execution
Run your code
![Page 13: WiseImage Open Architecture Lessons “Mission Impossible”](https://reader036.fdocuments.us/reader036/viewer/2022062423/5697bfdb1a28abf838cb090e/html5/thumbnails/13.jpg)
Final point
• How to process images:– Tools collection– Batch commands
![Page 14: WiseImage Open Architecture Lessons “Mission Impossible”](https://reader036.fdocuments.us/reader036/viewer/2022062423/5697bfdb1a28abf838cb090e/html5/thumbnails/14.jpg)
Final point: Code changes
Modify your previous code by replacing
with (Tools("Resample")) { ToolParam("ResampleType") = 1; ToolParam("Scale") = 100.0 * new_dist / org_dist; ToolParam("ResampleFlag") = true; WiseRun(); Document.View.Invalidate();}
with
Command.Alert("Distance is " + org_dist);
![Page 15: WiseImage Open Architecture Lessons “Mission Impossible”](https://reader036.fdocuments.us/reader036/viewer/2022062423/5697bfdb1a28abf838cb090e/html5/thumbnails/15.jpg)
Final point: Fulfillment
• Load the sample image
• Run your command
• Enjoy
Do you know any other way how to do the same?
![Page 16: WiseImage Open Architecture Lessons “Mission Impossible”](https://reader036.fdocuments.us/reader036/viewer/2022062423/5697bfdb1a28abf838cb090e/html5/thumbnails/16.jpg)
Be Interactive – part 2
• HTML forms
• Form Designer is part of Active Script Studio
• Form Wizard will help you to create good looking forms.
![Page 17: WiseImage Open Architecture Lessons “Mission Impossible”](https://reader036.fdocuments.us/reader036/viewer/2022062423/5697bfdb1a28abf838cb090e/html5/thumbnails/17.jpg)
Form creation
• Create a new form• Add your controls• Save the form
![Page 18: WiseImage Open Architecture Lessons “Mission Impossible”](https://reader036.fdocuments.us/reader036/viewer/2022062423/5697bfdb1a28abf838cb090e/html5/thumbnails/18.jpg)
FormWizard
• Create a new simple script function Main(){}
• Save it
• Run FormWizard
• Just follow instructions
• Run your script
![Page 19: WiseImage Open Architecture Lessons “Mission Impossible”](https://reader036.fdocuments.us/reader036/viewer/2022062423/5697bfdb1a28abf838cb090e/html5/thumbnails/19.jpg)
The magic of forms
• Open the sample script Bonus\RasterResize.js
• Run it
![Page 20: WiseImage Open Architecture Lessons “Mission Impossible”](https://reader036.fdocuments.us/reader036/viewer/2022062423/5697bfdb1a28abf838cb090e/html5/thumbnails/20.jpg)
Gifts
• Interactive Image scaling – wrap.js
• “Back to the Future” – text_rotate.js
• GIS sample