Entering the coordinates of points explicitly?

Discuss the drawing application
Post Reply
Teiwaz
Posts: 2
Joined: Fri Dec 16, 2016 5:42 am

Entering the coordinates of points explicitly?

Post by Teiwaz »

Question:

Is there any way to edit the location of a point by just typing in the coordinates I want?

Say, I want a line from (1,1) to (10.5, 11.125) exactly. Is there any dialog I can use to select the points on the line and set their coordinates exactly where I want them?

I'm not looking for snap guides which I'd have to reset between editing every point. I'm not looking to move the entire shape form the position and size menu. Just a single point within the shape.

Is this possible? It seems like it should be the most basic of basic functionality. When you select a point, it displays the coordinates in the lower status bar. But I can't find a way to edit them.
OpenOffice 4.0.0 with Windows 7
User avatar
robleyd
Moderator
Posts: 5264
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Entering the coordinates of points explicitly?

Post by robleyd »

Unless I'm misunderstanding your question, can you not right click on the line and select 'Position and size...' ?
Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.8.3.2; SlackBuild for 24.8.3 by Eric Hameleers
---------------------
Roses are Red, Violets are Blue
Unexpected '{' on line 32
.
Teiwaz
Posts: 2
Joined: Fri Dec 16, 2016 5:42 am

Re: Entering the coordinates of points explicitly?

Post by Teiwaz »

robleyd wrote:Unless I'm misunderstanding your question, can you not right click on the line and select 'Position and size...' ?
I'm trying to set the location of a point, as in a single vertex, not the entire line. Position and size only allows the entire shape to be moved.
OpenOffice 4.0.0 with Windows 7
User avatar
robleyd
Moderator
Posts: 5264
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Entering the coordinates of points explicitly?

Post by robleyd »

Aahh, I get it :oops: Can't help, sorry
Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.8.3.2; SlackBuild for 24.8.3 by Eric Hameleers
---------------------
Roses are Red, Violets are Blue
Unexpected '{' on line 32
.
User avatar
keme
Volunteer
Posts: 3738
Joined: Wed Nov 28, 2007 10:27 am
Location: Egersund, Norway

Re: Entering the coordinates of points explicitly?

Post by keme »

Workaround: Right click in your drawing and insert snap points. Draw lines between the snap points.

To make it workable, you may need to disable grid snap, and enable guide-line/-point snap:
  • Select menu item Tools - Options
  • Expand/select branch Draw - Grid
  • Untick Snap to grid in the Grid section.
  • Tick To snap lines in the Snap section.
  • Adjust snap range for a comfortable drawing experience.
Apache OO 4.1.12 and LibreOffice 7.5, mostly on Ms Windows 10
User avatar
Zizi64
Volunteer
Posts: 11419
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Entering the coordinates of points explicitly?

Post by Zizi64 »

Say, I want a line from (1,1) to (10.5, 11.125) exactly. Is there any dialog I can use to select the points on the line and set their coordinates exactly where I want them?
You can write a macro for this task based on the API functions...
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
Posts: 11419
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Entering the coordinates of points explicitly?

Post by Zizi64 »

Here is a not perfect example for adjusting the points of a selected polygon or a simple line.
(Use the icons of the custom toolbar named 'New Toolbar1' of the atached .odg document.)
NewToolbar1.png
NewToolbar1.png (2.31 KiB) Viewed 5823 times
NewToolbar1_b.png
NewToolbar1_b.png (13.43 KiB) Viewed 5823 times
(I have used some bult-in icons for the associated to the subroutines on the Custom toolbar. These icons are used for another functions too in the AOO/LO.)
You can adjust the StartPoint, or the EndPoint or all of the points of a selected Polygons by usage of my macros.


There are three pages in my example file:
Set_Point_Coordinates_of_a_Polygon.odg
(17.39 KiB) Downloaded 309 times

The first page contains some basic polygon shapes.

The second page shows the difference between the Startpoint and the Endpoint of a used Line-Array combo. (The StartPoint an EndPoint are not determined by the kind of the shape of the array. The conventional StartPoint and EndPoint property of a line is not depend on the type of the shape located at the beginning or at the end of the line. Maybe a Dot is the "EndPont" maybe an Arrow is the "EndPoint".)

The third page contains some non-Polygon type objects. But you can convert these objects to Polygon by a built-in feature, attached to the Custom toolbar. (It is available from the menu, too.) Then you will able modify the coordinates of their points - when this method is appropriate for you.

The helper functions for the determination of the selected objects was created by Danny Brewer. I just modified them - when it was necessary.
Last edited by Zizi64 on Sun Dec 18, 2016 10:25 am, edited 2 times in total.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
Posts: 11419
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Entering the coordinates of points explicitly?

Post by Zizi64 »

The macro code that is located in the attached .odg document:

Code: Select all

REM  *****  BASIC  *****

 Option Explicit

Sub EditStartPoint

 Dim oDoc As Object
 Dim PolyPolygonShape As Object
 Dim StartPoint As New com.sun.star.awt.Point 
 Dim Margin as Long
 Dim Value as Long
 Dim PointsNumber as integer
 Dim i as Integer
 Dim InputStr as String
     
	oDoc = ThisComponent
	If IsNull(oDoc) Then
		Exit Sub
	EndIf

	PolyPolygonShape = MyGetCurrentlySelectedSingleShape(oDoc, False)
	If IsNull(PolyPolygonShape) then
		exit sub
	End if	
	PointsNumber = UBound(PolyPolygonShape.PolyPolygon(0))
	
 Dim Points(PointsNumber) As New com.sun.star.awt.Point
	Array(Points()) = PolyPolygonShape.PolyPolygon

	Margin = oDoc.getDrawPages().getByIndex(0).BorderLeft
	InputStr = ""	
	Value = PolyPolygonShape.PolyPolygon(0)(0).x - Margin
	InputStr = InputBox ("StartPoint X coordinate [mm]", "Please type in:", format(Value/100,"0.##"), 3000, 2000)
	If InputStr<>"" then Value = int(100*CDbl(InputStr))
	Points(0).x = Value + Margin

Margin = oDoc.getDrawPages().getByIndex(0).BorderTop
	InputStr = ""
	Value = PolyPolygonShape.PolyPolygon(0)(0).y - Margin
	InputStr = InputBox ("StartPoint Y coordinate [mm]", "Please type in:", format(Value/100,"0.##"), 3000, 2000)
	If InputStr<>"" then Value = int(100*CDbl(InputStr))
	Points(0).y = Value + Margin
	
	For i= 1 to PointsNumber
		Points(i).x = PolyPolygonShape.PolyPolygon(0)(i).x
		Points(i).y = PolyPolygonShape.PolyPolygon(0)(i).y
	next i
	
 PolyPolygonShape.PolyPolygon = Array(Points())
 
End sub
'___________________________________________________________________________________________________________________

 
Sub EditEndPoint

 Dim oDoc As Object
 Dim PolyPolygonShape As Object
 Dim EndPoint As New com.sun.star.awt.Point 
 Dim Margin as Long
 Dim Value as Long
 Dim PointsNumber as integer
 Dim i as Integer
 Dim InputStr as String
     
	oDoc = ThisComponent
	If IsNull(oDoc) Then
		Exit Sub
	EndIf

	PolyPolygonShape = MyGetCurrentlySelectedSingleShape(oDoc, False)
	If IsNull(PolyPolygonShape) then
		exit sub
	End if	
	PointsNumber = UBound(PolyPolygonShape.PolyPolygon(0))
	
 Dim Points(PointsNumber) As New com.sun.star.awt.Point
	Array(Points()) = PolyPolygonShape.PolyPolygon
	
	For i= 0 to PointsNumber-1
		Points(i).x = PolyPolygonShape.PolyPolygon(0)(i).x
		Points(i).y = PolyPolygonShape.PolyPolygon(0)(i).y
	next i
	
	Margin = oDoc.getDrawPages().getByIndex(0).BorderLeft
	InputStr = ""
	Value = PolyPolygonShape.PolyPolygon(0)(PointsNumber).x - Margin
	InputStr = InputBox ("EndPoint X coordinate [mm]", "Please type in:", format(Value/100,"0.##"), 3000, 2000)
	If InputStr<>"" then Value = int(100*CDbl(InputStr))
	Points(PointsNumber).x = Value + Margin

	Margin = oDoc.getDrawPages().getByIndex(0).BorderTop
	InputStr = ""
	Value = PolyPolygonShape.PolyPolygon(0)(PointsNumber).y - Margin
	InputStr = InputBox ("EndPoint Y coordinate [mm]", "Please type in:", format(Value/100,"0.##"), 3000, 2000)
	If InputStr<>"" then Value = int(100*CDbl(InputStr))
	Points(PointsNumber).y = Value + Margin
	
 PolyPolygonShape.PolyPolygon = Array(Points())
 
End sub
'___________________________________________________________________________________________________________________

 
Sub EditAllPoints

 Dim oDoc As Object
 Dim PolyPolygonShape As Object
 Dim StartPoint As New com.sun.star.awt.Point 
 Dim Margin as Long
 Dim Value as Long
 Dim PointsNumber as integer
 Dim i as Integer
 Dim InputStr as String
 
	oDoc = ThisComponent
	If IsNull(oDoc) Then
		Exit Sub
	EndIf

	PolyPolygonShape = MyGetCurrentlySelectedSingleShape(oDoc, False)
	If IsNull(PolyPolygonShape) then
		exit sub
	End if	
	PointsNumber = UBound(PolyPolygonShape.PolyPolygon(0))
	
 Dim Points(PointsNumber) As New com.sun.star.awt.Point
	Array(Points()) = PolyPolygonShape.PolyPolygon	

	For i= 0 to PointsNumber
		Margin = oDoc.getDrawPages().getByIndex(0).BorderLeft
		InputStr = ""
		Value = PolyPolygonShape.PolyPolygon(0)(i).x - Margin
		InputStr = InputBox ("X coordinate of the Point Nr: "&str(i)&" [mm]", "Please type in:", format(Value/100,"0.##"), 3000, 2000)
		If InputStr<>"" then Value = int(100*CDbl(InputStr))
		Points(i).x = Value + Margin

		Margin = oDoc.getDrawPages().getByIndex(0).BorderTop
		InputStr = ""
		Value = PolyPolygonShape.PolyPolygon(0)(i).y - Margin
		InputStr = InputBox ("Y coordinate of the Point Nr: "&str(i)&" [mm]", "Please type in:", format(Value/100,"0.##"), 3000, 2000)
		If InputStr<>"" then Value = int(100*CDbl(InputStr))
		Points(i).y = Value + Margin
	next i
	
 PolyPolygonShape.PolyPolygon = Array(Points())
 
End sub
'___________________________________________________________________________________________________________________ 



'**************************************************************************************
' Next functions based on Danny B's macro collection downloaded from the old oooForum.
' a version of the original code is available from this topic of the AOO forum:
' https://forum.openoffice.org/en/forum/viewtopic.php?f=7&t=15217&start=0
' and on this place:
' http://nab.pcug.org.au/20090204_bas_source/dannyb.bas
'**************************************************************************************

Function MyDrawingGetSelection(ByVal oDrawDocCtrl as object) as object

 Dim oSelectedShapes as object
 Dim oDrawDocCtrl2 as object
 
	If Not HasUnoInterfaces( oDrawDocCtrl, "com.sun.star.frame.XController" ) Then
		
		'xray oDrawDocCtrl		 
		oDrawDocCtrl2 = MyGetDocumentController( oDrawDocCtrl )
	else 
		oDrawDocCtrl2 = oDrawDocCtrl
	EndIf

	If IsEmpty( oDrawDocCtrl2.getSelection() ) Then
		oSelectedShapes = createUnoService( "com.sun.star.drawing.ShapeCollection" )
	else 
		oSelectedShapes = oDrawDocCtrl2.getSelection()
	EndIf
   
 MyDrawingGetSelection() = oSelectedShapes
 
End Function
'___________________________________________________________________________________________________________________ 


Function MyGetCurrentlySelectedSingleShape(ByVal oDrawDoc, Optional bSilent ) As Object

 Dim oSelectedShapes as object
 Dim oSingleSelectedShape as object

   If IsMissing( bSilent ) Then
      bSilent = False
   EndIf
   
   oSelectedShapes = MyDrawingGetSelection(oDrawDoc)
   If oSelectedShapes.getCount() <= 0 Then
      If Not bSilent Then
         MsgBox( "There is not object selected" )
         Exit Function
      EndIf
   
	ElseIf oSelectedShapes.getCount() > 1 Then
		If Not bSilent Then
			MsgBox( "Please select one shape only" )
			Exit Function
		EndIf   
	Else
		oSingleSelectedShape = oSelectedShapes.getByIndex(0)      
		myGetCurrentlySelectedSingleShape() = oSingleSelectedShape
	EndIf
End Function 
'___________________________________________________________________________________________________________________ 


Function MyGetDocumentController( oDoc As Object ) As Object

 Dim oCtrl As Object
   
	If oDoc.supportsService( "com.sun.star.document.OfficeDocument" ) Then
		oCtrl = oDoc.getCurrentController()
	ElseIf HasUnoInterfaces( oDoc, "com.sun.star.frame.XController" ) Then
		oCtrl = oDoc
	ElseIf HasUnoInterfaces( oDoc, "com.sun.star.frame.XFrame" ) Then
		oFrame = oDoc
		oCtrl = oFrame.getController()
	Else
		MsgBox( "GetDocController called with incorrect parameter." )
	EndIf
   
 MyGetDocumentController() = oCtrl
 
End Function
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
Post Reply