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
 How do I set the llyr->LinePoint2 value to be valid?
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

supersk

99 Posts

Posted - Feb 26 2024 :  21:47:14  Show Profile  Reply
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?

xequte

38610 Posts

Posted - Feb 27 2024 :  00:19:03  Show Profile  Reply
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
Go to Top of Page

supersk

99 Posts

Posted - Feb 27 2024 :  00:39:08  Show Profile  Reply
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?
Go to Top of Page

xequte

38610 Posts

Posted - Feb 27 2024 :  02:16:08  Show Profile  Reply
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
Go to Top of Page

supersk

99 Posts

Posted - Feb 27 2024 :  19:45:05  Show Profile  Reply
Thanks.So, How to control the shape and direction of the line when generating the line?
Go to Top of Page

xequte

38610 Posts

Posted - Feb 27 2024 :  20:42:33  Show Profile  Reply
Sorry, presently there is no way to do that. We'll add it to the to-do list.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: