WiseImage Open Architecture Lessons “Mission Impossible”

20
WiseImage Open Architecture Lessons “Mission Impossible”

Transcript of WiseImage Open Architecture Lessons “Mission Impossible”

Page 1: WiseImage Open Architecture Lessons “Mission Impossible”

WiseImage Open Architecture

Lessons

“Mission Impossible”

Page 2: WiseImage Open Architecture Lessons “Mission Impossible”

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”

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”

Step 1:Measure Distance

Page 5: WiseImage Open Architecture Lessons “Mission Impossible”

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”

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”

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”

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”

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”

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”

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”

Step 3: Execution

Run your code

Page 13: WiseImage Open Architecture Lessons “Mission Impossible”

Final point

• How to process images:– Tools collection– Batch commands

Page 14: WiseImage Open Architecture Lessons “Mission Impossible”

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”

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”

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”

Form creation

• Create a new form• Add your controls• Save the form

Page 18: WiseImage Open Architecture Lessons “Mission Impossible”

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”

The magic of forms

• Open the sample script Bonus\RasterResize.js

• Run it

Page 20: WiseImage Open Architecture Lessons “Mission Impossible”

Gifts

• Interactive Image scaling – wrap.js

• “Back to the Future” – text_rotate.js

• GIS sample