Drag&Drop - HiStructClient/femcad-doc GitHub Wiki

Dragging info object example

draggingInfo = {
   # list of available transformations
   transformations = [
      {
         type = "translateX",
         parameterName = "pos_localX",
         parameterUnitDivider: 1,
         min = -20,
         max = 30,
         step = 0.05,
         snapingOrdValues = [0, 5, 10, 15]
      },
      {
         type = "translate",
         parameterName = "pos_globalY",
         parameterUnitDivider: 1,
         direction = [0, 1, 0],
         min = -100,
         max = 100,
         step = 0.5
      },
      {
         type = "scaleX",
         parameterName = "width",
         parameterUnitDivider: 1,
         min = 2,
         max = 12,
         step = 1
      }
   ],

   # origin of LCS
   referencePointArr = [2, 4.5, 6],

   # LCS axes
   x = [1, 0, 0], 
   y = [0, 1, 0],
   z = [0, 0, 1],

   # definition of snapping to other objects
   snap = {
      id = "Road",
      targetFilter = ["Road", "Silo", "Cone"],
      customSnapLines = [[0, 0, 0], [1, 0, 0](/HiStructClient/femcad-doc/wiki/[0,-0,-0],-[1,-0,-0), [1, 0, 0], [1, 1, 0](/HiStructClient/femcad-doc/wiki/1,-0,-0],-[1,-1,-0)]
   },

   # bounding box corner points
   boundingBox = {
      min = [-1, -1, -1],
      max = [1, 1, 1]
   },

   # configuration of edit box behavior and appearance
   visualConfig = {
         editMode = "advanced",
         disableTranslate = False,
         disableRealTimeTranslate = False,
         disableRealTimeScale = True,
   },

   # setup parent LCS
   parentLcsType = "gcs",
}

Data model

interface ITransformationDefinition {
    transformations: ITransformation[];
    referencePointArr: [number, number, number];
    boundingBox: { min: [number, number, number], max: [number, number, number] };
    x: [number, number, number];
    y: [number, number, number];
    z: [number, number, number];
    snap?: {
        id?: string,
        targetFilter?: string[],
        customSnapLines?: [number, number, number][][],
    };
    visualConfig?: {
        editMode?: "disabled" | "simple" | "advanced",
        disableTranslate?: boolean,
        disableScale?: boolean,
        disableRotate?: boolean,
        disableRealTimeTranslate?: boolean,
        disableRealTimeScale?: boolean,
        disableRealTimeRotate?: boolean,
    };
    parentLcsType?: "gcs" | "targetObject";
}

interface ITransformation {
    type?: TransformationType;
    parameterName?: string;
    parameterUnitDivider?: number;
    value?: number;
    step?: number;
    min?: number;
    max?: number;
    useMinMax?: boolean;
    snapingOrdValues?: number[];
    direction?: number[];
}

type TransformationType = "translateX" | "translateY" | "translateZ" | "scaleX" | "scaleY" | "scaleZ" | "translate";

Description of parameters

transformations

List of available transformations for current object.

type

Specifies type of the transformation that is allowed for object. Can have one of the following values:

  • "translateX": Move in x axis (object LCS)
  • "translateY": Move in y axis (object LCS)
  • "translateZ": Move in z axis (object LCS)
  • "translate": Move in general direction. Direction is specified by the direction parameter that is interpreted in global coordinate system. Direction parameter is required for the translate transformation type.
  • "scaleX": Resize in x axis (object LCS)
  • "scaleY": Resize in y axis (object LCS)
  • "scaleZ": Resize in z axis (object LCS)

parameterName

Name of the parameter (without path) that the transformation is mapped on.

parameterUnitDivider

Number that is used for conversion between natural units of the parameter (specified by parameterName) and the units of scene (SI system). E.g. if the parameter represents a distance in feets (imperial units), the value of parameterUnitDivider should be equal to 0.30478 as 1 feet is approximately equal to 0.30478 meters.

value_in_parameter_units = value_in_scene_units / parameterUnitDivider

The parameterUnitDivider can also be used to map the transformation to parameter that does not represent a distance, e.g. number of silos in x direction. In that case the value of parameterUnitDivider should be equal to the distance in scene units that represent the widtch of 1 silo in x direction in scene units.

value

The current value of the parameter in scene units. It is optional. If not defined it is read from the input dialog. It should be used if the textbox value on input page cannot be easily mapped to the distance in scene, e.g. there is some offset.

step

If step parameter is defined, the value of transformation is rounded to the closest multiple of step value. Step must be defined in scene units. The base value from which the step is applied is the current value of the input parameter before the transformation is applied.

min

The min value for the input parameter in scene units.

max

The max value for the input parameter in scene units.

useMinMax

This parameter is used to indicate that the min and max parameter should be taken into account. The default value is True. To disable min and max clipping, set the useMinMax to False or simply omit the min and max parameters from the definition.

snapingOrdValues

The array of values of the input parameter that should be snapped to. The values must be in scene units. snapingOrdValues is currently implemented only for translate, translateX, translateY and translateZ transforms. It is ignored for scale transforms.

direction

The direction of the transformation. Currently only relevant for general translate transform. Must be unit vector in global (scene) coordinate system.

referencePointArr

Coordinates of the origin of object LCS.

x, y, z

Coordinates of LCS axes.

boundingBox

The bounding box is used to represent the size of the object to calculate scale transforms. It is also used to generate default snapping lines and vertices of the object. And it is used to draw visual representation of box surrounding the object and to calculate hit test for drag&drop capability.

min

Lower bound of object bounding box in LCS.

max

Upper bound of object bounding box in LCS.

snap

Configuration of snapping to other draggable objects.

id

Name of current snap group. Can be arbitrary unique string. Is is used to identify the ability to snap to this object in other object's snap target filter. Must be defined for snapping to work.

targetFilter

List of identifiers of snap groups that are allowed to be snapped to by current object.

If the list is empty, the current object cannot be snapped to anything. However, other objects can still snap to this object if they have snap id of this object in their target list (snap ability can be asymmetric).

customSnapLines

The list of custom snap lines of the current object that overrides the default snap lines generated from the object bounding box. The vertices of snap lines are also used as translate handles in advanced edit mode.

The format supports not only lines defined by two vertices, but also solitary points (defined by single vertex) and line strings (defined by list of three or more vertices where the end point of a line is also the begin point of next line).

visualConfig

Collection of properties that define visual representation of edit box and behavior of edit operations.

editMode

Available values:

  • "disabled": Disables the ability to direct edit the object. Has the same consequences as removing all transformations. It is still possible to snap to this object (if snap is properly defined).
  • "simple": Turns on simple drag&drop capability for the object. Click-and-release is disallowed. Text input is dissallowed. Move is started by dragging edit box. Scale is started by dragging a scale handle. Scale handles are located only in bounding box corners (optimized for editing openings for which the edited object is embedded inside other object). Snap for translate transform is calculated for all corners of bounding box (or end points of customSnapLines if present). This is default value.
  • "advanced": Turns on advanced translate and scale modes. Click-and-release is allowed. Text input is allowed. All transformations are started using corresponding handles (blue for translate, green for scale). Switching between translate and scale mode is performed by clicking on edit box. Scale handles are located in all bounding box corners, edge centers and face centers, if the corresponding transformations are defined for the direction. Translate handles have the same location unless customSnapLines are defined. In that case the end points of snap lines are used as locations for translate handles. Snap is calculated for the center of active edit handle.

disableTranslate

Disallows translate transform even if translate transformations are defined. Works in both "simple" and "advanced" edit modes. Default value is False.

disableScale

Same as disableTranslate but for disallowing scale transforms. Default value is False.

disableRotate

Reserved for future use. Currently ignored.

disableRealTimeScale

Disables real-time redrawing of transformed object during the scale transform. Useful for transforms of parameters that does not have visual representation of intermediate values, e.g. integer parameters (number of silos). Default value is False.

disableRealTimeTranslate

Same as disableRealTimeScale but for translate transform. Default value is False.

disableRealTimeRotate

Reserved for future use. Currently ignored.

parentLcsType

Sets the parent LCS for the coordinate system defined in dragging info. Current options are "gcs" and "targetObject". "gcs" refers to global coordinate system of the scene and is the default value. "targetObject" refers to the LCS of the object in scene for which the dragging info is defined.

Global snap definition

There is an option to define snapping points and lines for the whole scene, unrelated to any selectable object. It can be defined using the standard dragging info object (only relevant properties are referencePointArr, x, y, z for lcs definition and snap for custom snap lines definition). The path to this object is defined as property DraggingInfoPath in CmpMap. The corresponding ModelInfoPath must start with special symbol "!" to indicate that this object does not have its selectable representation in scene. The string after the "!" symbol can be arbitrary unique identifier.

Example of dragging info object in fcs:

globalSnapDefinition = {
   referencePointArr = [0, 0, 0],
   x = [1, 0, 0], 
   y = [0, 1, 0],
   z = [0, 0, 1],
   snap = {
      id = "global-snap-lines",
      customSnapLines = [
         [-10, -10, 0], [10, -10, 0](/HiStructClient/femcad-doc/wiki/-10,--10,-0],-[10,--10,-0),
         [10, -10, 0], [10, 10, 0](/HiStructClient/femcad-doc/wiki/10,--10,-0],-[10,-10,-0),
         [10, 10, 0], [-10, 10, 0](/HiStructClient/femcad-doc/wiki/10,-10,-0],-[-10,-10,-0),
         [-10, 10, 0], [-10, -10, 0](/HiStructClient/femcad-doc/wiki/-10,-10,-0],-[-10,--10,-0),
         [0, 0, 0](/HiStructClient/femcad-doc/wiki/0,-0,-0),
         [100, 0, 0], [200, 0, 0], [200, 100, 0](/HiStructClient/femcad-doc/wiki/100,-0,-0],-[200,-0,-0],-[200,-100,-0),
      ]
   }
}

Example of record in CmpMap:

...
{
    "Notes": "Testing global dragging info that is not part of selectable object",
    "ModelPath": "!global-snap-definition_1",
    "DraggingInfoPath": "site.construct.globalSnapDefinition"
}
...