Example: Edit a Drawing with Transform Templates

In this example we open a drawing and apply Transform panel templates, using preview in blue preview color to see what the templates do.




We begin by opening a drawing of Mexico that shows provinces as areas.   In the Contents pane we choose the Transform panel.  




In the Transform panel we chose 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 area objects 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 of converting the area objects to point objects at the coordinates which define the areas.




Clicking Enclosing Rect ...




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




In the illustration above enclosing rects 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.


To see the areas as they were without any preview we click the (no action) template row at the top of the list of templates in the Transform panel.


We will now explore how the operation of the Transform panel 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 can select the area shown above, the Mexican province of Durango.  




The selected area is displayed in red selection color.




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



Right away the drawing window shows a preview of what the Rotate template does.  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 Rect.  




In the preview we can see how the Enclosing Rect 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 Rect template preview automatically will apply to that object as well.




The Enclosing Rect template now applies to all three selected areas.   Next, we uncheck the Restrict to selection box.




Instantly, the preview in the drawing window updates to apply the Enclosing Rect 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 Shift-Ctrl-click one of the selected areas to de-select it...




...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 Rotate 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 query text in the Command Window is:


-- $manifold$


-- Auto-generated

-- Transform - Rotate - Update Field


PRAGMA ('progress.percentnext' = '100');


  SELECT [Position],


    GeomRotate([Geom], GeomCenter([Geom], 0), 45) AS [n_Geom]

  FROM CALL Selection([Mexico], TRUE)

  THREADS SystemCpuCount()

) SET [Geom] = [n_Geom];



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.


Transform Options - 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 Rect 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.   When we create new components using the Add Component button we can control how fields are transferred using the Transform Options dialog.


See Also



Contents Pane


Contents - Select


Contents - Transform


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 panel 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 panel 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 Panel - How the Expressions tab of the Transform panel may be used to change the values of fields.  


Example: Construct JSON String using Select and Transform - Use the Select panel and the Transform panel 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 Expression to Create Buffers in a Drawing - Use the Expression tab of the  Transform panel 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: Transform Templates, Expressions and Queries - We learn to use a function by clicking on a template in the Transform panel , 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 panel template, an exploration of the difference between using Copy and Sum for transfer options.