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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 How do I set the llyr->LinePoint2 value to be valid?

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
supersk Posted - Feb 26 2024 : 21:47:14
I want to use TIELineLayer to draw a set of parallel lines.The code is as follows:

void __fastcall TImageForm::AddInteractivelayer(LayerKind lyrKind, TIEShape userShape)
{
     ImgEnMain->MouseInteractLayers = TIEMouseInteractLayers() << mlClickCreateLineLayers << mlEditLayerPoints;
     ImgEnMain->Cursor = crIESmallArrow;
}

void __fastcall TImageForm::ImgEnMainLayerMoveSize(TObject *Sender, int layer, TIELayerEvent event,
		  double &PosX, double &PosY, double &Width, double &Height)
{
    if (layer == -1 || layer == 0) {
	return;
    }
    TIELineLayer* llyr = NULL;
    llyr = dynamic_cast<TIELineLayer*>(ImgEnMain->Layers[layer]);
    if (llyr != NULL) {
	if (MeasureType == LayerKind::ParallelSpaceLayer &&
	    llyr->GroupIndex > PARALINEBASE && mbNeedDrawPLine) {
	    TPoint DrawStart1,  DrawStart2, DrawEnd1, DrawEnd2;
	    int PLineIndex = ImgEnMain->CurrentLayer->GroupIndex;
	    if (PLineIndex < PARALINEBASE)  return false;

	     TIELineLayer* llyr = NULL;
	     llyr = dynamic_cast<TIELineLayer*>(ImgEnMain->CurrentLayer);
	     if (llyr == NULL) return false;

	     //Get the first line
 
	     TIELineLayer* tmpllyr = NULL;
	     for( int i = 1; i < ImgEnMain->LayersCount; i++){
		tmpllyr = dynamic_cast<TIELineLayer*>(ImgEnMain->Layers[i]);
		if (tmpllyr != NULL) {
			if (tmpllyr->GroupIndex == PLineIndex &&
				ImgEnMain->CurrentLayer->LayerIndex != tmpllyr->LayerIndex) {
				DrawStart2 = tmpllyr->LinePoint1;
				DrawEnd2 = tmpllyr->LinePoint2;
                              break;
		 }
	    }
            double slope1;
	    if (DrawStart2.X == DrawEnd2.X) {
		slope1 = -NaN;
	    }else{
		slope1 = 1.0*(DrawStart2.Y - DrawEnd2.Y)/(DrawStart2.X - DrawEnd2.X);
	    }
	    double intercept;

	    DrawStart1 = llyr->LinePoint1;
	    intercept = DrawStart2.Y - slope1 * DrawStart1.X;
	    DrawEnd1.X = BitmapX; //Bitmap Coordinate;
	    DrawEnd1.Y = slope1 * DrawEnd1.X + intercept;
	    llyr->LinePoint2 = DrawEnd1;
	}
}

When I draw the second line, The second line is not parallel to the first line.Why?
5   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Feb 27 2024 : 20:42:33
Sorry, presently there is no way to do that. We'll add it to the to-do list.

Nigel
Xequte Software
www.imageen.com
supersk Posted - Feb 27 2024 : 19:45:05
Thanks.So, How to control the shape and direction of the line when generating the line?
xequte Posted - Feb 27 2024 : 02:16:08
Hi

The line end points cannot be manipulated during the creation/sizing process because it will clash with the internal handling.



Nigel
Xequte Software
www.imageen.com
supersk Posted - Feb 27 2024 : 00:39:08
What I want to achieve is to draw the first line, and then drag the mouse to draw the second line, which is parallel to the first line, and keep the two lines parallel throughout the second line. So, I want to control the end coordinates of the second line to do that, but it doesn't seem to work. Why?
xequte Posted - Feb 27 2024 : 00:19:03
Hi

If you want line layers to be parallel, why not assign the second the same Rotate value as the first?

https://www.imageen.com/help/TIELayer.Rotate.html

Nigel
Xequte Software
www.imageen.com