Example: Edit a Drawing with Transform Dialog Templates

In this example we open a drawing and edit objects in the drawing using the Transform dialog Template tab.




We begin by opening a drawing of Mexico that shows provinces as areas.   We choose Edit - Transform to launch the Transform dialog.




The dialog opens, choosing by default the only geom field in the drawing, a field called Geom.   If we click on any template the action of that template will be immediately previewed in the drawing window.




For example, if we click on Convert to Line that template will immediately be previewed in the drawing as if it were applied to the Geom field's geometry.



We can see that the Convert to Line template converts objects, such as the area objects in the drawing, into line objects that correspond to the area boundaries.   If we do not click the Update Field button this is just a preview and makes no change to the data.


Clicking another template will instantly preview the action of that template as well.





For example, clicking Convert to Point shows a preview if we convert the area objects to point objects at the coordinates which define the areas.




Clicking Enclosing Box ...





... shows a preview of replacing the areas with rectangular areas that precisely enclose each area.  




Note that in the illustration above enclosing boxes are drawn in whatever happens to be the display order of area objects.   Normally in the case of overlapping objects we would control the order of display by using layers in a map.  If display order matters, it is not a good idea to create area objects which overlap each other within the same drawing.  Instead, we should use layers to control display order.


Let us now do a selection.  To see the areas as they were without any preview we could either close the Transform dialog and open it again or we could just click Convert to Area, which has a preview that results in no change to the original view since all of the objects are areas anyway.


We will now explore how the operation of the Transform dialog can be restricted to the selection.  We begin by Ctrl-clicking onto some areas in the drawing to select them.   See the Selection topic for selecting objects in a drawing with the mouse.




First, by Ctrl-clicking it we have selected the area shown above.   Note that we do not need to close the Transform dialog to make selections in the drawing.   The Transform dialog stays alive and active as we go back and forth between clicking in the Transform dialog and clicking into the drawing window.





Next, we check the Restrict to selection box, click Rotate and then enter 45 into the Angle box which appeared when we clicked the Rotate template.



Right away the drawing window shows a preview of what the Rotate template does.  Note that the selected area has been rotated 45 degrees.  Because of overlap and the order in which areas are drawn the rotated area is partially above some areas and partially below others.





We can see that effect a bit more clearly by clicking Enclosing Box.  




In the preview we can see how the Enclosing Box template has been applied to just the selected object.  If we like, we can select more areas in the drawing by Ctrl-clicking on them.




As we Ctrl-click each object to add it to the selection, the Enclosing Box template preview automatically will apply to that object as well.




The Enclosing Box template now applies to all three selected areas.   Next, we go back into the Transform dialog and uncheck the Restrict to selection box.




Instantly, the preview in the drawing window updates to apply the Enclosing Box template to all of the areas.




If we click on a different template ...





... that too will be applied to all the objects and not just to the selected ones.




At any time we can check or uncheck the Restrict to selection box.





If we check it again ...




... once more only the selected areas will have the Rotate template preview applied to them.   If we Alt-Ctrl-click one of the selected areas to de-select it...




Then it will no longer be part of the selection and the Rotate preview will not apply to it.


So far all we have done has resulted in a preview in the drawing window of changes the Transform template would make.   To commit those changes we must press the Update Field button.


Or, if we prefer instead of making changes to the original data we can write the changes to a new component.  This will create a new component that contains only the modified objects, that is, just the rotated areas, which are created by the template.


To do so we change the Update Field action in the pull-down menu to Add Component.




We can then click on Add Component.




Two new components, a new table and a drawing for that table, will be created in the Project pane.


We can double-click open the Mexico Table Geom Drawing to see that this new drawing shows the two selected provinces in Mexico as rotated by the template.  These two rotated provinces are copies of the original data, as rotated.   The original Mexico Drawing has not been changed.




Automatically Creating a Query


If desired, we can take a look at the SQL query that the template uses to work its magic.




To do so, press the Edit Query button and the SQL used by the template will be loaded into the Command Window as an automatically generated SQL query.




The above query shows how the Rotate template works, and it also shows the call to the Selection query function that implements a restriction to only selected objects.   The PRAGMA controls the progress bar, not likely to be seen given how fast queries work unless we have a very large drawing.  The THREADS statement implements parallelization to the maximum number of CPU cores available.


We can modify this query or save it for later use.   Pressing the Edit Query button does not change the original drawing.  It simply opens up a Command Window with an SQL query that would be used by the template if we pressed the Update Field button.


Objects that are created as a result of Transform operations will whenever possible inherit the data content of the fields for that record.   If we replace a state in Mexico with the Enclosing Box for that state, the alteration when we choose Upgrade Field is to the contents of the geom field.   Other fields for that record, for example, any field that gives the population of the state, remain unchanged.


See Also

Transform Dialog


Transform Options


Command Window




Transform Templates


Transform Templates - Boolean


Transform Templates - Datetime


Transform Templates - Geom


Transform Templates - Numeric


Transform Templates - Text


Example: Two Drawings from the Same Table - Take a table with a geom field that is visualized by a drawing.  Add a second geom field to the table and create an rtree index on that field so it can be visualized by a drawing.   Copy the first drawing, paste it and adjust the pasted copy so it uses the second geom field. Demonstrate how to use the Transform dialog to show "live" modifications in the second drawing compared to the first drawing.


Example: Copy one Column into Another Column with Transform - How to use the Transform dialog to copy the contents of one column in a table into another column, but only for selected records.  Uses the Products table from the Nwind example data set.  


Example: Transform Field Values using an Expression in the Transform Dialog -  How the Expressions tab of the Transform Dialog may be used to change the values of fields.   We include an example of changing the price of selected products and using two different Transform dialogs open at the same time for two different table windows.


Example: Construct JSON String using Select and Transform - Use the Select and Transform dialogs to manually construct a JSON string using values from other fields in a table. Shows how we can manipulate text to build desired contents in a field.


Example: Use a Transform Dialog Expression to Create Buffers in a Drawing - Use the Expression tab of the Transform Dialog to create three different sizes of buffers for different lines in a drawing and then automatically create a query which does the same thing.  Includes examples of using the Add Component button and also the Edit Query button.


Example: Clip Areas with a Transform Dialog Expression - Use the Expression tab of the Transform dialog to clip areas in a drawing to fit within horizontal bounds.   Includes examples of using the Add Component button and also the Edit Query button.


Example: Smooth Lines with a Transform Dialog Expression - Use the Expression tab of the Transform dialog to make lines smoother in a drawing so that longer lines are smoothed more.  Includes examples of using the Edit Query button to show how different queries are created automatically depending on if we want to update a field or to add a new component.


Example: Transform Templates, Expressions and Queries - We learn to use a function by clicking on a template in the Transform dialog, seeing what it does in a preview, looking at the query Manifold creates and then trying out the function in the Expression tab.


Example: Transfer Options and Merge Areas - Using the Merge Areas Transform dialog template, an exploration of the difference between using Copy and Sum for transfer options.