ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Fly over hint
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

bmesser

United Kingdom
234 Posts

Posted - Nov 17 2012 :  02:06:39  Show Profile  Reply
Hi

I have a TImageEnVect component displaying a rainfall radar image overlaid in a layer over the map. At the moment I have a single object a "spot" that I place on top of that layer that I can drag around the screen that I use to access values from the rainfall layer by the color of the pixel the mouse pointer is over. What I would like to do is combine some text with the colored ellipse "spot" to give me a value I can get from a look-up on the color'. Do I have to maintain two objects to achieve this an iekEllipse and an iekText and synch them together or is there a way I can combine the two in a single object?

Bruce.

w2m

USA
1990 Posts

Posted - Nov 17 2012 :  09:22:13  Show Profile  Reply
As far as I know, there is no way to combine two objects into 1, but you can keep both objects selected so they move as a single object.

You can do this by making the 'Spot' selectable, moveable and visible and make the text moveable and visible.... but NOT selectable.
// This adds a ellipse 'Spot' and a text object but only the 'Spot'
// is selectable. Therefor the two objects act as one with respect to movement.
procedure TFormMain.AddSpot1Click(Sender: TObject);
var
  i: integer;
  SpothObj: integer;
  TexthObj: integer;
  ix: integer;
  iy: integer;
  iRight: integer;
  iBottom: integer;
  iListItem: TListItem;
begin
  if AddSpot1.Down then
    with ImageEnVect1 do
    begin
      // Add the spot
      SpothObj := AddNewObject;
      ObjStyle[SpothObj] := [];
      // make spot object Selectable, Moveable and Visible
      ObjStyle[SpothObj] := [ievsSelectable, ievsMoveable, ievsVisible];
      ObjKind[SpothObj] := iekEllipse;
      ObjName[SpothObj] := 'Spot';
      ObjWidth[SpothObj] := 10;
      objHeight[SpothObj] := 10;
      ObjLeft[SpothObj] := ImageEnVect1.ClientWidth div 2;
      ObjTop[SpothObj] := ImageEnVect1.ClientHeight div 2;
      objBrushColor[SpothObj] := clMaroon;
      objBrushStyle[SpothObj] := bsSolid;
      MouseInteractVt := [miPutEllipse];
      // add the text
      TexthObj := AddNewObject;
      ObjStyle[TexthObj] := [];
      // make text object moveable and visible bit not selectable
      // Text object moves along with Spot object
      ObjStyle[TexthObj] := [ ievsMoveable, ievsVisible];
      ObjKind[TexthObj] := iekText;
      ObjName[TexthObj] := 'Text';
      ix := ObjLeft[SpothObj] + ObjWidth[SpothObj] + 10;
      iy := ObjTop[SpothObj] - 5;
      ObjPenWidth[TexthObj] := 0;
      ObjText[TexthObj] := 'Spot';
      ObjLeft[TexthObj] := ix;
      ObjTop[TexthObj] := iy;
      ObjHeight[TexthObj] := 16;
      ObjPenColor[TexthObj] := clBlack;
      ObjPenStyle[TexthObj] := psClear;
      //ObjTextAutoSize[Texthobj] := True;
      SelAllObjects;
      for i := 0 to ObjectsCount - 1 do
      begin
        iListItem := ListViewObjects1.Items.Add;
        iListItem.Caption := IntToStr(ListViewObjects1.Items.Count);
        iListItem.SubItems.Add(string(ObjName[i]));
        iListItem.SubItems.Add(IntToStr(ObjWidth[i]) + ' x ' +
          IntToStr(ImageEnVect1.ObjHeight[i]));
        iListItem.Selected := True;
      end;
      Update;
      AddSpot1.Down := False;
      SelectObject1.Down := True;
      ImageEnVect1.MouseInteractVt := [miObjectSelect];
    end
  else if SelectObject1.Down then
    ImageEnVect1.MouseInteractVt := [miObjectSelect];
end;

// Move the 'Text' along with the 'Spot'
procedure TFormMain.ImageEnVect1ObjectMoveResize(Sender: TObject; hobj, Grip: Integer; var OffsetX,
  OffsetY: Integer);
var
  iTextObj: integer;
begin
  if hobj = 0 then
  begin
    iTextObj := hobj + 1;
    ImageEnVect1.ObjLeft[iTextObj] := ImageEnVect1.ObjLeft[hobj] + ImageEnVect1.ObjWidth[hobj] + 10;
    ImageEnVect1.ObjTop[iTextObj] := ImageEnVect1.ObjTop[hobj];
  end;
end;

William Miller
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: