BRL-CAD
edit.c File Reference
#include "common.h"
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include "bu/getopt.h"
#include "vmath.h"
#include "db.h"
#include "raytrace.h"
#include "ged.h"
#include "./ged_private.h"
Include dependency graph for edit.c:

Go to the source code of this file.

Data Structures

struct  edit_arg
 
union  edit_cmd
 
struct  edit_cmd_tab
 

Macros

#define EDIT_MAX_ARG_OPTIONS   3
 
#define EDIT_COORD_X   0x01
 
#define EDIT_COORD_Y   0x02
 
#define EDIT_COORD_Z   0x04
 
#define EDIT_COORDS_ALL   (EDIT_COORD_X | EDIT_COORD_Y | EDIT_COORD_Z)
 
#define EDIT_COORD_IS_SET_X   0x08
 
#define EDIT_COORD_IS_SET_Y   0x10
 
#define EDIT_COORD_IS_SET_Z   0x20
 
#define EDIT_FROM   0x01 /* aka keypoint */
 
#define EDIT_TO   0x02
 
#define EDIT_TARGET_OBJ   0x04 /* obj to operate on */
 
#define EDIT_REL_DIST   0x08
 
#define EDIT_ABS_POS   0x10
 
#define EDIT_NATURAL_ORIGIN   0x20 /* use n.o. of object */
 
#define EDIT_USE_TARGETS   0x40 /* for batch ops */
 
#define EDIT_OBJ_TYPE_MODS   (EDIT_NATURAL_ORIGIN | EDIT_USE_TARGETS)
 
#define EDIT_TARGET_OBJ_BATCH_TYPES   (EDIT_NATURAL_ORIGIN)
 
#define EDIT_CMD_DISABLE   0x0
 
#define EDIT_CMD_ENABLE   0x1
 
#define EDIT_ROTATE_ARG_HEADS_LEN   7
 
#define EDIT_SCALE_ARG_HEADS_LEN   6
 
#define EDIT_TRANSLATE_ARG_HEADS_LEN   3
 
#define EDIT_CMD_HELP   0 /* idx of "help" in edit_cmds */
 

Typedefs

typedef int(* exec_handler) (struct ged *gedp, const union edit_cmd *const cmd)
 
typedef int(* add_cl_args_handler) (struct ged *gedp, union edit_cmd *const cmd, const int flags)
 
typedef struct edit_arg **(* get_arg_head_handler) (const union edit_cmd *const cmd, int idx)
 

Functions

HIDDEN void edit_arg_init (struct edit_arg *arg)
 
HIDDEN void edit_arg_postfix (struct edit_arg *head, struct edit_arg *node)
 
HIDDEN struct edit_argedit_arg_postfix_new (struct edit_arg *head)
 
HIDDEN void edit_arg_duplicate_in_place (struct edit_arg *const dest, const struct edit_arg *src)
 
HIDDEN void edit_arg_duplicate (struct edit_arg **dest, const struct edit_arg *src)
 
HIDDEN int edit_arg_is_empty (struct edit_arg *arg)
 
HIDDEN void edit_arg_free_inner (struct edit_arg *arg)
 
HIDDEN void edit_arg_free (struct edit_arg *arg)
 
HIDDEN void edit_arg_free_last (struct edit_arg *arg)
 
HIDDEN void edit_arg_free_all (struct edit_arg *arg)
 
HIDDEN int edit_arg_to_apparent_coord (struct ged *gedp, const struct edit_arg *const arg, vect_t *const coord)
 
HIDDEN int edit_arg_to_coord (struct ged *gedp, struct edit_arg *const arg, vect_t *coord)
 
HIDDEN int edit_arg_expand_meta (struct ged *gedp, struct edit_arg *meta_arg, const struct edit_arg *src_objs, const int flags)
 
HIDDEN void edit_cmd_init (union edit_cmd *const subcmd)
 
HIDDEN void edit_cmd_free (union edit_cmd *const cmd)
 
HIDDEN void edit_cmd_sduplicate (union edit_cmd *const dest, const union edit_cmd *const src)
 
HIDDEN int edit_cmd_expand_vectors (struct ged *gedp, union edit_cmd *const subcmd)
 
HIDDEN int edit_cmd_consolidate (struct ged *gedp, union edit_cmd *const subcmd, int skip_common_objects)
 
HIDDEN int edit_rotate (struct ged *gedp, const vect_t *axis_from, const vect_t *axis_to, const vect_t *center, const vect_t *angle_origin, const vect_t *angle_from, const vect_t *angle_to, const struct db_full_path *path)
 
HIDDEN int edit_rotate_wrapper (struct ged *gedp, const union edit_cmd *const cmd)
 
HIDDEN int edit_rotate_add_cl_args (struct ged *gedp, union edit_cmd *const cmd, const int flags)
 
HIDDEN struct edit_arg ** edit_rotate_get_arg_head (const union edit_cmd *const cmd, int idx)
 
int edit_scale (struct ged *gedp, const vect_t *scale_from, const vect_t *scale_to, const vect_t *center, const vect_t *factor_from, const vect_t *factor_to, const struct db_full_path *path)
 
HIDDEN int edit_scale_wrapper (struct ged *gedp, const union edit_cmd *const cmd)
 
HIDDEN int edit_scale_add_cl_args (struct ged *gedp, union edit_cmd *const cmd, const int flags)
 
HIDDEN struct edit_arg ** edit_scale_get_arg_head (const union edit_cmd *const cmd, int idx)
 
HIDDEN int edit_translate (struct ged *gedp, const vect_t *const from, const vect_t *const to, const struct db_full_path *const path)
 
HIDDEN int edit_translate_wrapper (struct ged *gedp, const union edit_cmd *const cmd)
 
HIDDEN int edit_translate_add_cl_args (struct ged *gedp, union edit_cmd *const cmd, const int flags)
 
HIDDEN struct edit_arg ** edit_translate_get_arg_head (const union edit_cmd *const cmd, int idx)
 
HIDDEN int edit (struct ged *gedp, union edit_cmd *const subcmd)
 
HIDDEN int edit_str_to_arg (struct ged *gedp, const char *str, struct edit_arg *arg, const int flags)
 
HIDDEN int edit_strs_to_arg (struct ged *gedp, int *argc, const char **argv[], struct edit_arg *arg, int flags)
 
int ged_edit (struct ged *gedp, int argc, const char *argv[])
 

Detailed Description

Command to edit objects by translating, rotating, and scaling.

Definition in file edit.c.

Macro Definition Documentation

#define EDIT_MAX_ARG_OPTIONS   3

Definition at line 441 of file edit.c.

Referenced by edit_arg_duplicate_in_place(), edit_arg_init(), and ged_edit().

#define EDIT_COORD_X   0x01

Definition at line 462 of file edit.c.

Referenced by edit_cmd_consolidate(), edit_cmd_expand_vectors(), edit_str_to_arg(), and ged_edit().

#define EDIT_COORD_Y   0x02

Definition at line 463 of file edit.c.

Referenced by edit_cmd_consolidate(), edit_cmd_expand_vectors(), edit_str_to_arg(), and ged_edit().

#define EDIT_COORD_Z   0x04

Definition at line 464 of file edit.c.

Referenced by edit_cmd_consolidate(), edit_cmd_expand_vectors(), edit_str_to_arg(), and ged_edit().

#define EDIT_COORD_IS_SET_X   0x08

Definition at line 471 of file edit.c.

Referenced by edit_str_to_arg(), and edit_strs_to_arg().

#define EDIT_COORD_IS_SET_Y   0x10

Definition at line 472 of file edit.c.

Referenced by edit_str_to_arg(), and edit_strs_to_arg().

#define EDIT_COORD_IS_SET_Z   0x20

Definition at line 473 of file edit.c.

Referenced by edit_str_to_arg(), and edit_strs_to_arg().

#define EDIT_FROM   0x01 /* aka keypoint */
#define EDIT_TO   0x02

Definition at line 481 of file edit.c.

Referenced by edit_arg_expand_meta(), edit_translate_add_cl_args(), and ged_edit().

#define EDIT_TARGET_OBJ   0x04 /* obj to operate on */

Definition at line 482 of file edit.c.

Referenced by edit_cmd_consolidate(), edit_translate_add_cl_args(), and ged_edit().

#define EDIT_REL_DIST   0x08

Definition at line 485 of file edit.c.

Referenced by edit_cmd_expand_vectors(), edit_translate_add_cl_args(), and ged_edit().

#define EDIT_ABS_POS   0x10

Definition at line 486 of file edit.c.

Referenced by edit_cmd_expand_vectors(), edit_translate_add_cl_args(), and ged_edit().

#define EDIT_NATURAL_ORIGIN   0x20 /* use n.o. of object */

Definition at line 489 of file edit.c.

Referenced by edit_arg_to_apparent_coord(), and ged_edit().

#define EDIT_USE_TARGETS   0x40 /* for batch ops */

Definition at line 490 of file edit.c.

Referenced by edit(), and edit_str_to_arg().

#define EDIT_OBJ_TYPE_MODS   (EDIT_NATURAL_ORIGIN | EDIT_USE_TARGETS)

Definition at line 493 of file edit.c.

#define EDIT_TARGET_OBJ_BATCH_TYPES   (EDIT_NATURAL_ORIGIN)

Definition at line 496 of file edit.c.

Referenced by edit_arg_expand_meta().

#define EDIT_CMD_DISABLE   0x0

Definition at line 570 of file edit.c.

#define EDIT_CMD_ENABLE   0x1

Definition at line 571 of file edit.c.

#define EDIT_ROTATE_ARG_HEADS_LEN   7
#define EDIT_SCALE_ARG_HEADS_LEN   6

Referenced by edit_scale_get_arg_head().

#define EDIT_TRANSLATE_ARG_HEADS_LEN   3
#define EDIT_CMD_HELP   0 /* idx of "help" in edit_cmds */

Typedef Documentation

typedef int(* exec_handler) (struct ged *gedp, const union edit_cmd *const cmd)

Command specific information, for a table of available commands.

Definition at line 558 of file edit.c.

typedef int(* add_cl_args_handler) (struct ged *gedp, union edit_cmd *const cmd, const int flags)

Definition at line 559 of file edit.c.

typedef struct edit_arg**(* get_arg_head_handler) (const union edit_cmd *const cmd, int idx)

Definition at line 561 of file edit.c.

Function Documentation

HIDDEN void edit_arg_init ( struct edit_arg arg)

Initialize an argument node.

Definition at line 587 of file edit.c.

References edit_arg::cl_options, edit_arg::coords_used, EDIT_COORDS_ALL, EDIT_MAX_ARG_OPTIONS, memset(), edit_arg::next, edit_arg::object, edit_arg::type, and edit_arg::vector.

Referenced by edit_arg_duplicate_in_place(), edit_arg_expand_meta(), edit_arg_postfix_new(), and ged_edit().

Here is the call graph for this function:

HIDDEN void edit_arg_postfix ( struct edit_arg head,
struct edit_arg node 
)

Attach an argument node to the end of the list.

Definition at line 602 of file edit.c.

References edit_arg::next.

Referenced by edit_arg_postfix_new().

HIDDEN struct edit_arg* edit_arg_postfix_new ( struct edit_arg head)

Allocate space and attach a new node to the end of the list. Returns a pointer to the new node. Caller is responsible for freeing.

Definition at line 619 of file edit.c.

References BU_ALLOC, edit_arg_init(), and edit_arg_postfix().

Referenced by ged_edit().

Here is the call graph for this function:

HIDDEN void edit_arg_duplicate_in_place ( struct edit_arg *const  dest,
const struct edit_arg src 
)

Duplicate an argument node on top of an existing node. Prior to calling, caller is responsible for freeing objects contained by destination argument node, if necessary, via edit_arg_free_inner().

Definition at line 636 of file edit.c.

References BU_ALLOC, edit_arg::cl_options, edit_arg::coords_used, db_dup_full_path(), db_full_path_init(), edit_arg_init(), EDIT_MAX_ARG_OPTIONS, if(), edit_arg::next, edit_arg::object, edit_arg::type, and edit_arg::vector.

Referenced by edit_arg_duplicate(), and edit_arg_expand_meta().

Here is the call graph for this function:

HIDDEN void edit_arg_duplicate ( struct edit_arg **  dest,
const struct edit_arg src 
)

Duplicate an argument node into a new argument. Caller is responsible for freeing destination argument, using the appropriate edit_arg_free*() function.

Definition at line 667 of file edit.c.

References BU_ALLOC, and edit_arg_duplicate_in_place().

Referenced by edit(), edit_arg_expand_meta(), and edit_translate_add_cl_args().

Here is the call graph for this function:

HIDDEN int edit_arg_is_empty ( struct edit_arg arg)

Returns GED_OK if arg is empty, otherwise GED_ERROR is returned

Definition at line 678 of file edit.c.

References edit_arg::cl_options, edit_arg::coords_used, EDIT_COORDS_ALL, GED_ERROR, GED_OK, edit_arg::next, edit_arg::object, edit_arg::type, and edit_arg::vector.

Referenced by ged_edit().

HIDDEN void edit_arg_free_inner ( struct edit_arg arg)

Free all objects contained by an argument node.

Definition at line 695 of file edit.c.

References bu_free(), db_free_full_path(), edit_arg::object, and edit_arg::vector.

Referenced by edit_arg_expand_meta(), and edit_arg_free().

Here is the call graph for this function:

HIDDEN void edit_arg_free ( struct edit_arg arg)

Free an argument node, including what it contains.

Definition at line 713 of file edit.c.

References bu_free(), and edit_arg_free_inner().

Referenced by edit_arg_free_all(), edit_arg_free_last(), edit_cmd_consolidate(), and ged_edit().

Here is the call graph for this function:

HIDDEN void edit_arg_free_last ( struct edit_arg arg)

Free the last argument node in the list.

Definition at line 724 of file edit.c.

References edit_arg_free(), and edit_arg::next.

Referenced by ged_edit().

Here is the call graph for this function:

HIDDEN void edit_arg_free_all ( struct edit_arg arg)

Free an argument node and all nodes down its list.

Definition at line 742 of file edit.c.

References edit_arg_free(), and edit_arg::next.

Referenced by edit_cmd_free().

Here is the call graph for this function:

HIDDEN int edit_arg_to_apparent_coord ( struct ged gedp,
const struct edit_arg *const  arg,
vect_t *const  coord 
)

Gets the apparent coordinates of an object.

Combines the effects of all the transformation matrices in the combinations in the given path that affect the position of the combination or shape at the end of the path. The result is the apparent coordinates of the object at the end of the path, if the first combination in the path were drawn. The only flags respected are object argument type modifier flags.

If the path only contains a primitive, the coordinates of the primitive will be the result of the conversion.

Returns GED_ERROR on failure, and GED_OK on success.

Definition at line 766 of file edit.c.

References _ged_get_obj_bounds2(), _ged_get_solid_keypoint(), BU_ASSERT, BU_ASSERT_PTR, bu_vls_printf(), directory::d_flags, directory::d_namep, db_find_named_leaf(), DB_FULL_PATH_GET, DB_FULL_PATH_ROOT_DIR, db_path_to_string(), EDIT_NATURAL_ORIGIN, db_full_path::fp_len, GED_DB_GET_INTERNAL, GED_ERROR, ged_get_obj_bounds(), GED_OK, ged_path_validate(), ged::ged_result_str, _ged_trace_data::gtd_xform, rt_db_internal::idb_ptr, edit_arg::object, rt_db_free_internal(), RT_DIR_COMB, RT_DIR_NULL, RT_DIR_REGION, RT_DIR_SOLID, rt_uniresource, tree::tree_db_leaf::tl_mat, tree::tr_l, rt_comb_internal::tree, TREE_NULL, and edit_arg::type.

Referenced by edit_arg_to_coord(), and edit_cmd_expand_vectors().

Here is the call graph for this function:

HIDDEN int edit_arg_to_coord ( struct ged gedp,
struct edit_arg *const  arg,
vect_t *  coord 
)

Converts an edit_arg object+offset to coordinates. If *coord is NULL, *arg->vector is overwritten with the coordinates and *arg->object is freed, otherwise coordinates are written to *coord and *arg is in no way modified.

The only flags respected are object argument type modifier flags.

Returns GED_ERROR on failure, and GED_OK on success.

Definition at line 861 of file edit.c.

References BU_ALLOC, bu_free(), db_free_full_path(), edit_arg_to_apparent_coord(), GED_ERROR, GED_OK, edit_arg::object, and edit_arg::vector.

Referenced by edit(), edit_arg_expand_meta(), and edit_cmd_consolidate().

Here is the call graph for this function:

HIDDEN int edit_arg_expand_meta ( struct ged gedp,
struct edit_arg meta_arg,
const struct edit_arg src_objs,
const int  flags 
)

"Expands" object arguments for a batch operation.

meta_arg is replaced with a list of copies of src_objects, with certain meta_arg flags applied and/or consolidated with those of the source objects. Objects + offsets are converted to coordinates.

Set GED_QUIET or GED_ERROR bits in 'flags' to suppress or enable output to ged_result_str, respectively.

Returns GED_ERROR on failure, and GED_OK on success.

Definition at line 904 of file edit.c.

References BU_ASSERT, bu_vls_printf(), edit_arg::coords_used, edit_arg_duplicate(), edit_arg_duplicate_in_place(), edit_arg_free_inner(), edit_arg_init(), edit_arg_to_coord(), EDIT_COORDS_ALL, EDIT_FROM, EDIT_TARGET_OBJ_BATCH_TYPES, EDIT_TO, GED_ERROR, GED_OK, ged::ged_result_str, if(), edit_arg::next, and edit_arg::type.

Referenced by edit().

Here is the call graph for this function:

HIDDEN void edit_cmd_init ( union edit_cmd *const  subcmd)

Initialize all command argument-pointer members to NULL.

Definition at line 960 of file edit.c.

References edit_cmd::cmd, edit_cmd::common, edit_cmd_tab::get_arg_head, and edit_cmd::objects.

Referenced by edit(), and ged_edit().

HIDDEN void edit_cmd_free ( union edit_cmd *const  cmd)

Free any dynamically allocated argument nodes that may exist.

Definition at line 977 of file edit.c.

References edit_cmd::cmd, edit_cmd::common, edit_arg_free_all(), edit_cmd_tab::get_arg_head, and edit_cmd::objects.

Referenced by ged_edit().

Here is the call graph for this function:

HIDDEN void edit_cmd_sduplicate ( union edit_cmd *const  dest,
const union edit_cmd *const  src 
)

Perform a shallow copy of a subcommand's argument grouping.

Definition at line 997 of file edit.c.

References BU_ASSERT_PTR, edit_cmd::cmd, edit_cmd::common, edit_cmd_tab::get_arg_head, and edit_cmd::objects.

Referenced by edit().

HIDDEN int edit_cmd_expand_vectors ( struct ged gedp,
union edit_cmd *const  subcmd 
)

Sets any skipped vector elements to a reasonable default, sets EDIT_COORDS_ALL on vector arguments, and converts relative offsets to absolute positions. Expects all arguments except target objects to have vector set. Only looks at the first set of args.

XXX: This intentionally only looks at the first set of args. At some point, it may be desirable to have the subcommand functions (i.e. edit_<subcmd>_wrapper()) call this prior to execution, so that some commands can expand their own vectors in an unusual ways.

Definition at line 1028 of file edit.c.

References BU_ASSERT, edit_cmd::cmd, edit_cmd::common, EDIT_ABS_POS, edit_arg_to_apparent_coord(), EDIT_COORD_X, EDIT_COORD_Y, EDIT_COORD_Z, EDIT_COORDS_ALL, EDIT_FROM, EDIT_REL_DIST, GED_ERROR, GED_OK, edit_cmd_tab::get_arg_head, and edit_cmd::objects.

Referenced by edit().

Here is the call graph for this function:

HIDDEN int edit_cmd_consolidate ( struct ged gedp,
union edit_cmd *const  subcmd,
int  skip_common_objects 
)

Consolidates compatible arguments. If any of the arguments that are being consolidated link to objects, they are converted to coordinates. Only consolidatable arguments flagged with the same argument type (or if the second arg has no type) that are under the same argument head are consolidated.

Common objects are left alone if skip_common_objects != 0.

Returns GED_ERROR on failure, and GED_OK on success.

Definition at line 1102 of file edit.c.

References BU_ASSERT, edit_cmd::cmd, edit_cmd::common, edit_arg::coords_used, edit_arg_free(), edit_arg_to_coord(), EDIT_COORD_X, EDIT_COORD_Y, EDIT_COORD_Z, EDIT_COORDS_ALL, EDIT_TARGET_OBJ, GED_ERROR, GED_OK, edit_cmd_tab::get_arg_head, edit_arg::next, edit_arg::object, edit_cmd::objects, edit_arg::type, and edit_arg::vector.

Referenced by ged_edit().

Here is the call graph for this function:

HIDDEN int edit_rotate ( struct ged gedp,
const vect_t *  axis_from,
const vect_t *  axis_to,
const vect_t *  center,
const vect_t *  angle_origin,
const vect_t *  angle_from,
const vect_t *  angle_to,
const struct db_full_path path 
)

Rotate an object by specifying points.

Definition at line 1195 of file edit.c.

References GED_OK.

Referenced by edit_rotate_wrapper().

HIDDEN int edit_rotate_wrapper ( struct ged gedp,
const union edit_cmd *const  cmd 
)

Maps edit_arg fields to the subcommand function's arguments and calls it.

Definition at line 1217 of file edit.c.

References edit_cmd::center, edit_rotate(), edit_arg::object, edit_cmd::objects, edit_cmd::ref_angle, edit_cmd::ref_axis, edit_cmd::rotate, and edit_arg::vector.

Here is the call graph for this function:

HIDDEN int edit_rotate_add_cl_args ( struct ged gedp,
union edit_cmd *const  cmd,
const int  flags 
)

Definition at line 1235 of file edit.c.

References GED_OK.

HIDDEN struct edit_arg** edit_rotate_get_arg_head ( const union edit_cmd *const  cmd,
int  idx 
)

Given an pointer to an argument head in the edit_cmd union, this function will return the next argument head in the union.

Definition at line 1250 of file edit.c.

References edit_cmd::center, EDIT_ROTATE_ARG_HEADS_LEN, edit_cmd::objects, edit_cmd::ref_angle, edit_cmd::ref_axis, and edit_cmd::rotate.

int edit_scale ( struct ged gedp,
const vect_t *  scale_from,
const vect_t *  scale_to,
const vect_t *  center,
const vect_t *  factor_from,
const vect_t *  factor_to,
const struct db_full_path path 
)

Scale an object by specifying points.

Definition at line 1273 of file edit.c.

References GED_OK.

Referenced by edit_scale_wrapper().

HIDDEN int edit_scale_wrapper ( struct ged gedp,
const union edit_cmd *const  cmd 
)

Maps edit_arg fields to the subcommand function's arguments and calls it.

Definition at line 1294 of file edit.c.

References edit_cmd::center, edit_scale(), edit_arg::object, edit_cmd::objects, edit_cmd::ref_factor, edit_cmd::ref_scale, edit_cmd::scale, and edit_arg::vector.

Here is the call graph for this function:

HIDDEN int edit_scale_add_cl_args ( struct ged gedp,
union edit_cmd *const  cmd,
const int  flags 
)

Definition at line 1311 of file edit.c.

References GED_OK.

HIDDEN struct edit_arg** edit_scale_get_arg_head ( const union edit_cmd *const  cmd,
int  idx 
)

Given an pointer to an argument head in the edit_cmd union, this function will return the next argument head in the union.

Definition at line 1326 of file edit.c.

References edit_cmd::center, EDIT_SCALE_ARG_HEADS_LEN, edit_cmd::objects, edit_cmd::ref_factor, edit_cmd::ref_scale, and edit_cmd::scale.

HIDDEN int edit_translate ( struct ged gedp,
const vect_t *const  from,
const vect_t *const  to,
const struct db_full_path *const  path 
)
HIDDEN int edit_translate_wrapper ( struct ged gedp,
const union edit_cmd *const  cmd 
)

Maps edit_arg fields to the subcommand function's arguments and calls it. Provides an common interface, so that all subcommands can use the same function pointer type. Ignores all edit_arg fields other than vector, and the first object to operate on in the objects edit_arg. Ignores all edit_arg->next arguments.

Definition at line 1436 of file edit.c.

References edit_translate(), edit_arg::object, edit_cmd::objects, edit_cmd::ref_vector, and edit_cmd::translate.

Here is the call graph for this function:

HIDDEN int edit_translate_add_cl_args ( struct ged gedp,
union edit_cmd *const  cmd,
const int  flags 
)

Add arguments to the command that were built from the cmd line. All unique argument pointers in the command should be initialized to NULL before using.

Note: This command happens to only accept the standard command line options, so others are ignored.

Definition at line 1456 of file edit.c.

References edit_cmd::args, BU_ASSERT_PTR, bu_vls_printf(), edit_arg::cl_options, edit_cmd::cmd, edit_cmd::cmd_line, EDIT_ABS_POS, edit_arg_duplicate(), EDIT_FROM, EDIT_REL_DIST, EDIT_TARGET_OBJ, EDIT_TO, GED_ERROR, GED_OK, ged::ged_result_str, edit_cmd_tab::name, edit_arg::next, edit_arg::object, edit_cmd::objects, edit_cmd::ref_vector, edit_cmd::translate, edit_arg::type, and edit_cmd_tab::usage.

Here is the call graph for this function:

HIDDEN struct edit_arg** edit_translate_get_arg_head ( const union edit_cmd *const  cmd,
int  idx 
)

Given an pointer to an argument head in the edit_cmd union, this function will return the next argument head in the union.

This function is used to traverse a commands arguments, without needing to know their structure. edit_cmd.common.objects should be used as the first argument head, to traverse the entire struct.

XXX: Kind of dirty; haven't found a better way yet, though.

Definition at line 1558 of file edit.c.

References EDIT_TRANSLATE_ARG_HEADS_LEN, edit_cmd::objects, edit_cmd::ref_vector, and edit_cmd::translate.

HIDDEN int edit ( struct ged gedp,
union edit_cmd *const  subcmd 
)

A wrapper for the edit commands. It adds the capability to perform batch operations, and accepts objects and distances in addition to coordinates. As a side effect, arguments flagged with EDIT_USE_TARGETS will be replaced (expanded) in performing batch commands.

Returns GED_ERROR on failure, and GED_OK on success.

Note that this function ignores most argument type flags, since it's expected that all args will be in the proper locations in the given command struct. An exception is made for EDIT_TARGET_OBJ_BATCH_TYPES, which is respected since certain flags may propagate in batch operations. Coordinate flags are always respected.

If batch arguments are to be used, they should be either: a) the first and only argument in the given argument head or b) expanded prior to being passed to this function This is because an expansion of a batch character leads to an argument head having any prior nodes, plus the expanded nodes. If there were any prior nodes, the expansion would cause a lopsided set of arguments, which should result in a BU_ASSERT failure.

Definition at line 1655 of file edit.c.

References BU_ASSERT, edit_arg::cl_options, edit_cmd::cmd, edit_cmd::common, edit_arg_duplicate(), edit_arg_expand_meta(), edit_arg_to_coord(), edit_cmd_expand_vectors(), edit_cmd_init(), edit_cmd_sduplicate(), EDIT_USE_TARGETS, edit_cmd_tab::exec, GED_ERROR, GED_OK, edit_cmd_tab::get_arg_head, edit_arg::next, edit_arg::object, edit_cmd::objects, and edit_arg::type.

Referenced by ged_edit().

Here is the call graph for this function:

HIDDEN int edit_str_to_arg ( struct ged gedp,
const char *  str,
struct edit_arg arg,
const int  flags 
)

Converts a string to an existing edit_arg. See subcommand manuals for examples of acceptable argument strings.

Set GED_QUIET or GED_ERROR bits in 'flags' to suppress or enable output to ged_result_str, respectively.

Returns GED_ERROR on failure, and GED_OK on success.

Definition at line 1762 of file edit.c.

References BU_ALLOC, BU_ASSERT, bu_free(), BU_STR_EQUAL, bu_vls_printf(), edit_arg::coords_used, db_free_full_path(), db_lookup(), db_string_to_path(), rt_wdb::dbip, EDIT_COORD_IS_SET_X, EDIT_COORD_IS_SET_Y, EDIT_COORD_IS_SET_Z, EDIT_COORD_X, EDIT_COORD_Y, EDIT_COORD_Z, EDIT_COORDS_ALL, EDIT_USE_TARGETS, GED_ERROR, GED_OK, ged_path_validate(), ged::ged_result_str, ged::ged_wdbp, LOOKUP_QUIET, edit_arg::object, RT_DIR_NULL, strchr(), edit_arg::type, and edit_arg::vector.

Referenced by edit_strs_to_arg().

Here is the call graph for this function:

HIDDEN int edit_strs_to_arg ( struct ged gedp,
int *  argc,
const char **  argv[],
struct edit_arg arg,
int  flags 
)

Converts as much of an array of strings as possible to a single edit_arg. Both argc and argv are modified to be past the matching arguments. See subcommand manuals for examples of acceptable argument strings.

Set GED_QUIET or GED_ERROR bits in 'flags' to suppress or enable output to ged_result_str, respectively. Note that output is always suppressed after the first string is successfully converted.

Returns GED_OK if at least one string is converted, otherwise GED_ERROR is returned.

Definition at line 1912 of file edit.c.

References edit_arg::coords_used, EDIT_COORD_IS_SET_X, EDIT_COORD_IS_SET_Y, EDIT_COORD_IS_SET_Z, EDIT_COORDS_ALL, edit_str_to_arg(), GED_ERROR, GED_OK, and GED_QUIET.

Referenced by ged_edit().

Here is the call graph for this function:

int ged_edit ( struct ged gedp,
int  argc,
const char *  argv[] 
)

A command line interface to the edit commands. Will handle any new commands without modification. Validates as much as possible in a single pass, without going back over the arguments list. Further, more specific, validation is performed by edit().

Definition at line 1965 of file edit.c.

References edit_cmd_tab::add_cl_args, edit_cmd::args, BU_ALLOC, BU_ASSERT, bu_getopt(), bu_optarg, bu_opterr, bu_optind, bu_optopt, BU_STR_EQUAL, bu_vls_printf(), bu_vls_trunc(), edit_arg::cl_options, edit_cmd::cmd, edit_cmd::cmd_line, edit_arg::coords_used, edit(), EDIT_ABS_POS, edit_arg_free(), edit_arg_free_last(), edit_arg_init(), edit_arg_is_empty(), edit_arg_postfix_new(), edit_cmd_consolidate(), edit_cmd_free(), edit_cmd_init(), EDIT_COORD_X, EDIT_COORD_Y, EDIT_COORD_Z, EDIT_COORDS_ALL, EDIT_FROM, EDIT_MAX_ARG_OPTIONS, EDIT_NATURAL_ORIGIN, EDIT_REL_DIST, edit_strs_to_arg(), EDIT_TARGET_OBJ, EDIT_TO, edit_cmd_tab::enabled, GED_CHECK_ARGC_GT_0, GED_CHECK_DATABASE_OPEN, GED_CHECK_READ_ONLY, GED_ERROR, GED_HELP, GED_OK, GED_QUIET, ged::ged_result_str, edit_cmd_tab::help, edit_cmd_tab::name, edit_arg::next, edit_arg::object, edit_arg::type, usage(), and edit_cmd_tab::usage.

Here is the call graph for this function: