Previous Next         Current Page: NeXtMidas Training / Macros - Part 1 (Basics) / Lab 9 / Instructions
Start Here   
Background   
Common Midas Concepts   
Getting Started   
Working with Files   
Option Trees   
Macros - Part 1 (Basics)   
   + Macro Basics   
   + Lab 1   
   + Lab 2   
   + Loops and Control Structures   
   + Lab 3   
   + Lab 4*   
   + Procedures and Subroutines   
   + Lab 5   
   + Lab 6*   
   + Pipes in a Macro   
   + Lab 7   
   + Lab 8   
   + Messages in a Macro   
   - Lab 9   
      - Instructions   
      - Solution   
   + Lab 10   
Macros - Part 2 (Graphics)   
Primitives   
Installing NeXtMidas   
Applets & WebStart   
Mapping (NeXtEarth)   
Remote Midas InterFace (RMIF)   
Using NetBeans   
X-Midas Interoperability   
Remoting an X-Midas App.   


  • Lab 9 (Part A):
    • For this lab you will see how to receive messages in a macro.
    • Create a new macro mcrlab9 in the TRAIN option tree.
    • In this lab we will be getting messages from a PLOT. In order for the PLOT to stay up and allow the macro to receive messages, it needs to be in a pipe section.
      • In the body of your macro add a pipe section.
      • The first line of the pipe section should look like this:
          pipe on
            panel
        This will bring up a PANEL. The use of PANEL will be discussed in the next section. For now all that is important is that clicking the 'X' in the panel will end the macro.
      • In the pipe section, bring up a PLOT of nxm.sys.dat.world.shp
      • Give the plot an ID of MYPLOT and set the /MSGID=... switch.
    • Part B will cover the details of processMessage procedure. For now just make it print out the message received.
      procedure processMessage m:msg
        say "Got message name=^msg.name info=^msg.info data=^msg.data"
      return
    • Now use UPDATE to add your macro to the command dictionary.
    • Run your macro. Take note of the messages printed out when you do the following:
      1. Click on the plot.
      2. Zoom in on the plot. (This is done by dragging a box using the left mouse button.)
      3. UnZoom in the plot. (This is done by clicking the right mouse button.)
      4. Make a "dragbox" in the plot. (This is similar to zooming, but hold down the shift key while dragging.)
  • Lab 9 (Part B):
    • In the processMessage add a check for a dragbox message. When you see a dragbox message, add the following to print out its data:
          result msg.data(0)
          result msg.data(1)
          result msg.data(2)
          result msg.data(3)
    • When you re-run the macro notice how the data for the dragbox message is equal to the min and max values of the dragbox.
  • Lab 9 (Part C):
    • Now we want to use a FEATURE to mark the location of any "dragbox" made by the user.
    • Create a feature on the line right after PLOT you can just paste in this code.
      FEATURE label=box1 table={NAME=BOX1,TYPE=BOX,COLOR=WHITE,ENABLE=1} plot=myplot
      
    • The coordinates of a feature are with box1.x and box1.y being the center points and box1.dx and box1.dy being the deltas (box width and height).
      • You will need to take the min and max values you printed out in Part B and compute the x,y and dx,dy for the box.
      • Once you have computed them you will need to set them.
    • Try doing a dragbox now... what do you see.
    • Hint: If you get stuck, try running %test_box in the test area of the SYS option tree. It should help you out.
  • Lab 11 (Part X):
    • This is not actually part of the lab...
    • If you finish the lab quickly try adding a second plot to your macro.
      • This time use the other map of the world nxm.sys.dat.world.prm.
      • Also add a box feature to that plot.
      • You will probably want to make a procedure here that will take in the message and the feature name and set the values accordingly.
      • Now add two more features, one for each plot and color them red.
      • The red feature should show any dragbox drawn on the other plot.