Drawing lines

myhmyh Global Mapper UserPosts: 21
edited February 2009 in SDK
Hi
Dear Mike

when i draw a one line , many lines are drawn parallel !?
One line is Red and others are gray !

my code is like this :
"
theDrwLineStyle.mPenColor = RGB(255,0,0);
theDrwLineStyle.mFont.mWeight = FW_BOLD;
GM_SetLineFeatureDrawStyle(theMLayer,0,&theDrwLineStyle);

for(int m=0;m<80;m++){
Points[m].mX=100+m;
Points[m].mY=200;
}

theDrwLineFeature.mNumPoints= 80;
theDrwLineFeature.mLineStyle= theDrwLineStyle;
theDrwLineFeature.mPointList= Points;

GM_AddLineToCustomVectorLayer(theMLayer,&theDrwLineFeature,TRUE);

GM_DrawFlags_t32 aDrawFlags=0x00001000 ;

CRect mDrwRect= pMapWindow->GetDrawWndRect();
GM_DrawLayerList(dc,&theMLayer,1,aDrawFlags,&pMapWindow->GetCurrentViewRect(),\ mDrwRect.left,mDrwRect.top,mDrwRect.Width(),mDrwRect.Height());
"
another question 1: for normal drawing on vector and raster or ... what is correct value for "aDrawFlags" ?

another question 2 : is it possible creating a custom 3D layer and drawing on it ?

Tanks a lot.

Comments

  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited September 2008
    Do you have a screenshot of what you are seeing? Can you show me the rest of your initialization of the 'theDrwLineFeature' and 'theDrwLineStyle' variables? I'm guessing this is where the issue is.

    For 'aDrawFlags' the GM_DrawFlags_EraseBackground parameter is most common. It looks like you are passing in the GM_DrawFlags_SeparateVectorLayers flag (0x1000), which actually won't have any effect if you are only drawing a single layer.

    You can use the GM_CreateCustomElevGridLayer function to create an elevation grid layer for display in both 2D and 3D, along with any data draped on top of it.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • myhmyh Global Mapper User Posts: 21
    edited September 2008
    Mike

    i apolegize for first problem ,i solved it :
    in OnPaint Event , according to the mouse events ,some times i have changes in
    line coordinates !

    1- But i dont know why first line color was RED and others were GRAY whereas only i had changes in coordinates !?

    2- I tried to delete GRAY lines But i cant Get their Features ,(we have not more than one Index ),is it possible clearing
    or deleting these lines without having them Indexes ?

    New question:
    After drawing a line or area ,i want users can be able to select these ,
    and these will be shown selected.(such as selection in Photoshop or ...) :
    Is a easy way to this or i should Manually do all of this difficult way ?

    Thanks a lot.
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited September 2008
    I don't know why you would get multiple gray lines as you use different coordinates. Are you erasing your background before drawing and are you just updating the coordinates of an existing line feature or are you creating a new line feature and custom vector layer all the time?

    You can use the GM_FindNearestFeatures function to find features near the mouse, then change the drawing style to reflect that they are selected while you have them selected.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • myhmyh Global Mapper User Posts: 21
    edited September 2008
    Mike
    i toled that i solved this problem but it is Marvelous for me ( if you have enough time ).

    what is updated all times is :
    "
    theDrwLineStyle.mPenColor = RGB(255,0,0);
    theDrwLineStyle.mFont.mWeight = FW_BOLD;
    GM_SetLineFeatureDrawStyle(theMLayer,0,&theDrwLineStyle);

    for(int m=0;m<80;m++){
    Points[m].mX=gPoint.x; // changing of coordinates with mouse move events
    Points[m].mY=200+m;
    }

    theDrwLineFeature.mNumPoints= 80;
    theDrwLineFeature.mLineStyle= theDrwLineStyle;
    theDrwLineFeature.mPointList= Points;

    GM_AddLineToCustomVectorLayer(theMLayer,&theDrwLineFeature,TRUE);
    GM_DrawFlags_t32 aDrawFlags=0x00001000 ;
    CRect mDrwRect= pMapWindow[iCntOfOpenMapFiles]->GetDrawWndRect();
    GM_DrawLayerList(dc,&theMLayer,1,aDrawFlags,&pMapWindow[iCntOfOpenMapFiles]->GetCurrentViewRect(),\
    mDrwRect.left,mDrwRect.top,mDrwRect.Width(),mDrwRect.Height());

    "

    Your patience is admirable.
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited September 2008
    It looks to me like you are adding a new line feature every time that your mouse moves. If you instead just want to create one line feature and continually update its coordinates, just call GM_AddLineToCustomVectorLayer once to create the feature, then on mouse move events call GM_SetLineFeaturePointList to update the point list for the feature that you already created, then redraw. That way you won't get duplicate lines.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • myhmyh Global Mapper User Posts: 21
    edited September 2008
    Mike
    Ok , excellent ,
    According to the your advice i just called GM_AddLineToCustomVectorLayer once to create the feature and called GM_SetLineFeaturePointList to update the point list for the feature, and duplicate lines went away!

    Q: there is Create CustomVectorLayer and AddLine To CustomVectorLayer functions ,
    also we have Create CustomRasterLayer but why isnt AddLine To CustomRasterLayer
    function ? (perhaps i didnt find)

    Thank you very much.
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited September 2008
    A raster layer is there to contain imagery/scanned maps and not vector data. You can only add vector features (like lines) to a vector layer. If you need to display vector data over raster data, just create/load multiple layers and draw them all at once.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • myhmyh Global Mapper User Posts: 21
    edited October 2008
    Hello

    Mike

    How to i can get points between mouse down and mouse up on layers ?
    ( for passing to Point list in AreaFeature and LineFeature )
    1- for Lines ?
    2- for Areas ?

    Best Regards
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited October 2008
    Just add a handler for WM_MOUSEMOVE messages and keep track of the mouse movements while you have a mouse button down and do whatever you need with that information.
  • myhmyh Global Mapper User Posts: 21
    edited October 2008
    Mike !!!
    I have had this mouse handlers .
    i want get points on straight line between mouse down and mouse up on layers ?
    and get points in area between some straight line between mouse downs and mouse ups on layers ?

    thanks .
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited October 2008
    I'm not really clear on what you are after. If you have the mouse handlers you can save whatever list of points that you need as the mouse is moved. You can create new custom features from that list of points (use GM_ConvertCoordPixelToGround to get the ground coordinates associated with a pixel coordinate on the map), then add them to a custom vector layer for rendering.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • myhmyh Global Mapper User Posts: 21
    edited October 2008
    I dont want all of points in mouse movement.
    in need with only two point (mouse dwon point and mouse up point ) i want Draw a direct line between them.
    And i want get all points in Area between some corner points .

    Thanks alot .
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited October 2008
    Just have a WM_LBUTTONDOWN and WM_LBUTTONUP message handler and capture the clicked screen coordinates there. You can then use GM_ConvertCoordPixelToGround to convert those points to the currently selected projection if you wanted to add them to a SDK layer.

    If you have a bounding box to search in you can use GM_FindNearestFeatures to get all of the points within that bounding box.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • diofantisdiofantis Global Mapper User Posts: 35Trusted User
    edited February 2009
    Hi Mike,

    i have a problem when i try to draw a line, in vb.net 2005.
    i get an error code 2.

    i attach the source code that i am using, so if you see any errors or if you have a different solution/approach or even better a sample in vb.net then please let me know.

    Thanks in advance.
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited February 2009
    I think the problem is the use of the VB 'Boolean' type in your declarations. If I remember correctly the VB 'Boolean' type is a 32-bit integer, while the 'boolean' type in the SDK is defined as an 'unsigned char', which is an 8-bit type. I think you need to replace your use of the 'Boolean' type with 'Byte' or 'UInt8'.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
Sign In or Register to comment.