comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: problem:symbol not be showed in IdlgrPlot object etc.
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: problem:symbol not be showed in IdlgrPlot object etc. [message #46005] Thu, 27 October 2005 10:57 Go to next message
Rick Towler is currently offline  Rick Towler
Messages: 821
Registered: August 1998
Senior Member
Listen up all objects graphics users:

I never can say this enough. When working with object graphics and
something isn't displaying as expected, work from the bottom up testing
your elements until you determine where things are going wrong. And the
tool for testing? XOBJVIEW. You'll be surprised what you will learn :)

This isn't directed at you specifically, Shengbaojun, but I did stress
that point in my responses to your earlier post. Especially since your
application was complicated by the C# + axIDLWidgetControl aspect.

I pasted your code into IDL, provided my own XY data, and in less than a
minute was displaying your symbols in XOBJVIEW and provides a simplified
test environment. The first thing I noticed was that your symbols no
longer are centered on your data points:

pro test_sym

xy = rotate([[findgen(10)], [findgen(10)]],180)

;define the symbol
pentagon=OBJ_NEW('IDLgrPolygon', [0.1,0.5,0.9,0.7,0.3], $
[0.6,0.9,0.6,0.1,0.1], $
COLOR=Color_cities)
symModel = OBJ_NEW('IDLgrModel')
symModel -> Add, pentagon
symModel -> Scale, 0.5, 0.5, 1
symModel -> Translate, -1, -1, 0
ocitiesSymbol = OBJ_NEW('IDLgrSymbol', symModel)
oSymbol2 = OBJ_NEW('IDLgrSymbol', 1, SIZE=0.5)

oPlotCities=OBJ_NEW('IDLgrPolyline',xy[0,*],xy[1,*], $
Symbol=ocitiesSymbol,$
_Extra=extra,$
;Thick=2 ,$
LINESTYLE = 6)

oPlot2=OBJ_NEW('IDLgrPolyline',xy[0,*],xy[1,*], $
Symbol=oSymbol2,$
COLOR=[255,0,0], $
_Extra=extra,$
LINESTYLE = 6)

oModel = OBJ_NEW('IDLgrModel')
oModel->ADD,[oPlotCities,oPlot2]

XOBJVIEW, oModel, /block

OBJ_DESTROY, [oModel, symModel, ocitiesSymbol, oSymbol2]

end


My guess is that since the Cartesian coords returned from the MAP_PROJ
functions are very large, the offset created by your incorrect transform
has move your symbols out of the view.

Either understand how transforms are applied or don't transform your
symbols. If you isometrically scale an object whose data is not
centered about the origin it will move the center of that object. So
the first thing you need to do is translate your object such that it is
centered on the origin. Your data range is 0 to 1 so your original
translation of [-1,-1,0] is incorrect. You only need to translate it
-0.5 units in X and Y.

symModel -> Translate, -0.5, -0.5, 0

Now that your symbol is centered on the origin you can scale it (note
that I have provided scaling factors appropriate for my code above and
you would want to scale it to your data):

symModel -> Scale, 0.5, 0.5, 1

Make the changes to the above code and the symbols should line up and
they will probably appear in your display.


Also, I personally would use IDLgrPolyline instead of IDLgrPlot.


In regards to your second question:

command="MouseMove,IDLDrawWidget1,"+e.x.ToString()+","+myYY.ToString();

I don't think you are referencing your draw widget correctly. AFAICT,
the string "IDLDrawWidget1" has no context in either your C# code or
your IDL code. It is just a collection of chars. You need to send the
draw id: axIDLDrawWidget1.DrawID. Something like

char drawIDstr[20];
_itoa(axIDLDrawWidget1.DrawID, drawIDstr, 10);
command="MouseMove,"drawIDstr","+e.x.ToString()+","+myYY.ToString();

Note that I'm not a C# programmer so there probably is a better way to
do the conversion but you get the point.


-Rick


shengbaojun wrote:
> Hello,I have draw the background map.Thanks for Mr.Rick Towler and
> Mr.Mark Hadfield a lot.
> But I met some difficulties when I try something else,so could you give
> me some adivce please.
>
> 1, I want to draw some cities above the background map,but the symbols
> can not be showed.
> I use the code as follows:
> ;-----------------------------------------------------
> ;draw cities
> cityUV = map_proj_forward(lon, lat, $
> map=map_info.smap $
> )
> ;define the symbol
> pentagon=OBJ_NEW('IDLgrPolygon', [0.1,0.5,0.9,0.7,0.3], $
> [0.6,0.9,0.6,0.1,0.1], $
> COLOR=Color_cities $
> )
> symModel = OBJ_NEW('IDLgrModel')
> symModel -> Add, pentagon
> symModel -> Scale, 8, 8, 1
> symModel -> Translate, -1, -1, 0
> ocitiesSymbol = OBJ_NEW('IDLgrSymbol', symModel)
> ; ocitiesSymbol=OBJ_NEW('IDLgrSymbol',4,$
> ; color=Color_NoData,$
> ; thick=8.0,$
> ; size=[9.0,9.0]$
> ; )
> map_info.ocitiesSymbol=ocitiesSymbol
>
> oPlotCities=OBJ_NEW('IDLgrPlot',cityUV[0,*],cityUV[1,*], $
> Symbol=ocitiesSymbol,$
> _Extra=extra,$
> ;Thick=2 ,$
> LINESTYLE =6 $
> )
>
> map_info.omodel->ADD,oPlotCities
> map_info.owindow->DRAW,map_info.oview,/draw_instance
> ;--------------------------------------------------------
> If I change the LINESTYLE value from 6 to 3,The lines has been
> showed,but the Symbols also can not be showed .
>
> 2,I use the develop model of C# plus axIDLWidgetControl 3.0,I write
> the mouse event in C#,so I must obtain the value of IDL's variable from
> IDL's .pro file.But I can not get them .The code is as follows:
>
> IDL's code
> //////////////////////////////////////////////////////////// ///////////
>
> PRO MouseMove,drawid,x,y
>
> common lonlat_mousemovex,lonlat_mousemovey
> widget_control,drawid,get_uvalue=map_info,/no_copy
>
> if size(map_info, /type) eq 0 then return
> result = map_info.owindow -> pickdata(map_info.oview, $
> map_info.omodel,$
> [x,y], xy)
> lonlat_mousemove = map_proj_inverse(xy, map = map_info.smap)
> map_info.lonlat_mousemovex=lonlat_mousemove[0]
> map_info.lonlat_mousemovey=lonlat_mousemove[1]
> widget_control,drawid,set_uvalue=map_info,/no_copy
> END
>
> C# 's code
> ///////////////////////////////////////////////////////
> private void axIDLDrawWidget1_MouseMoveEvent(object sender,
> AxIDLDRAWX3Lib._DIDLDrawX3Events_MouseMoveEvent
>
> e)
> {
>
> int myYY=axIDLDrawWidget1.Height-e.y;
> string
> command="MouseMove,IDLDrawWidget1,"+e.x.ToString()+","+myYY.ToString();
> int temp=axIDLDrawWidget1.ExecuteStr(command);
> temp=axIDLDrawWidget1.ExecuteStr("widget_control,IDLDrawWidget1,get_value=map_info ");
> object
> lonlat_mousemovex=axIDLDrawWidget1.GetNamedData("map_info.lonlat_mousemovex ");
> object
> lonlat_mousemovey=axIDLDrawWidget1.GetNamedData("map_info.lonlat_mousemovey ");
> }
>
> I try my best to test above codes,but did not success.
> I wish you can help me.
>
> Thanks you
>
Re: problem:symbol not be showed in IdlgrPlot object etc. [message #46011 is a reply to message #46005] Wed, 26 October 2005 23:02 Go to previous messageGo to next message
shengbaojun is currently offline  shengbaojun
Messages: 8
Registered: October 2005
Junior Member
Thanks for your reply
As a fact ,I can see nothing whether using the user_defined or the
standard symbols. And I can see the connectting lines when I set the
linestyle value from 6 to 3 or 2,So It is not the coordinate 's
problem.
My user-defined symbol can be seen perfectly in other PRO files such as
"xplot.pro",So I missed the direction,I don't know why they can't be
showed in my code.

I have fulfilled the most function in C# plus axIDLWidgetControl
3.0,including drawing cities using color dot, And there is no problem
when I finished such above problem.BUT THAT IS DEVELOPED IN DIRECT
DRAWING MODEL,And now,I must translate them from direct drawing model
to Object drawing model,then these problem happened!

Could you please give me you advice
Thanks a lot
Re: problem:symbol not be showed in IdlgrPlot object etc. [message #46012 is a reply to message #46011] Wed, 26 October 2005 21:09 Go to previous messageGo to next message
Mark Hadfield is currently offline  Mark Hadfield
Messages: 783
Registered: May 1995
Senior Member
shengbaojun wrote:
> Hello,I have draw the background map.Thanks for Mr.Rick Towler and
> Mr.Mark Hadfield a lot.
> But I met some difficulties when I try something else,so could you give
> me some adivce please.
>
> 1, I want to draw some cities above the background map,but the symbols
> can not be showed.
> I use the code as follows:
> ;-----------------------------------------------------
> ;draw cities
> cityUV = map_proj_forward(lon, lat, $
> map=map_info.smap $
> )
> ;define the symbol
> pentagon=OBJ_NEW('IDLgrPolygon', [0.1,0.5,0.9,0.7,0.3], $
> [0.6,0.9,0.6,0.1,0.1], $
> COLOR=Color_cities $
> )
> symModel = OBJ_NEW('IDLgrModel')
> symModel -> Add, pentagon
> symModel -> Scale, 8, 8, 1
> symModel -> Translate, -1, -1, 0
> ocitiesSymbol = OBJ_NEW('IDLgrSymbol', symModel)
> ; ocitiesSymbol=OBJ_NEW('IDLgrSymbol',4,$
> ; color=Color_NoData,$
> ; thick=8.0,$
> ; size=[9.0,9.0]$
> ; )
> map_info.ocitiesSymbol=ocitiesSymbol
>
> oPlotCities=OBJ_NEW('IDLgrPlot',cityUV[0,*],cityUV[1,*], $
> Symbol=ocitiesSymbol,$
> _Extra=extra,$
> ;Thick=2 ,$
> LINESTYLE =6 $
> )
>
> map_info.omodel->ADD,oPlotCities
> map_info.owindow->DRAW,map_info.oview,/draw_instance
> ;--------------------------------------------------------
> If I change the LINESTYLE value from 6 to 3,The lines has been
> showed,but the Symbols also can not be showed .

Can you see the symbols when you use one of the standard symbol types
(eg type 4, or diamonds, which you've commented out)?

If you can see the standard symbols but not the user-defined ones, then
you must have done something odd in setting up the symbol polygon or
model. Actually, I can see from your code that you *have* done something
odd. The guideline in the IDL documentation is that a user-defined
symbol's data should extend from -1 to +1 in the x & y directions. The
SIZE property is then used to scale the symbol to an appropriate size
for the plot. Your symbol polygon extends from 0 to 1 and then you scale
and translate the symbol model. I don't know why you did this, but I'm
sure it's a not a good idea.
>
> 2,I use the develop model of C# plus axIDLWidgetControl 3.0,I write
> the mouse event in C#,so I must obtain the value of IDL's variable from
> IDL's .pro file.But I can not get them .The code is as follows:

Woooaa. That's way beyond me, sorry.

I don't know how to put this without sounding condescending, but are you
sure you know enough about basic IDL programming to start trying to mix
it with C#?

--
Mark Hadfield "Kei puwaha te tai nei, Hoea tahi tatou"
m.hadfield@niwa.co.nz
National Institute for Water and Atmospheric Research (NIWA)
Re: problem:symbol not be showed in IdlgrPlot object etc. [message #46136 is a reply to message #46005] Mon, 31 October 2005 01:23 Go to previous message
shengbaojun is currently offline  shengbaojun
Messages: 8
Registered: October 2005
Junior Member
Thanks a lot for reply,
The foundation of my project is using object drawing model in IDL's
IDLDrawWidget control 3.0.

At first,The PolyLines can be connected using LineStyle value eq 2 or 3
and without using *coord_conv in 'IDLgrPolyLine'.But ,the Symbols can't
be seen.I don't konw WHY it is.

The Second, VB、VC etc. must use axIDLDrawWidget1.DrawID as draw
id;But,C# can use IDLDrawWidget1 as draw id directly,I have filfulled
it.The world map can be draw corretly.
But,the communication mechanism seems changed.I can use GetNamedData or
CopyNamedArray to get variable value from IDL in DIRECT DRAWING
MODEL,And now ,I must use SetOutputWnd to get the IDL's value in OBJECT
DRAWING MODEL.

My quesion is:
1. I have filfull the background map drawing,using the IDLgrPolyLine
and the data source is *.shp,I want to overlay some symbols to this
background map,the polylines can be drawn,but the symbols can't be
drawn.

2. Are there a good method to get variable value from IDL 's Object
program model in C# environment.And now ,I use SetOutputWnd but not
GetNamedData.

Can everyone help me!
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: the AVHRR NDVI data series analysis
Next Topic: middle mouse button emulation in widget_draw

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 19:30:14 PDT 2025

Total time taken to generate the page: 0.00781 seconds