Revision: 55308
http://sourceforge.net/p/brlcad/code/55308
Author: bob1961
Date: 2013-05-06 12:19:18 +0000 (Mon, 06 May 2013)
Log Message:
-----------
This includes the addtion of the pset command as well as other mods related to
supporting metaball editing in Archer.
Modified Paths:
--------------
brlcad/trunk/include/ged.h
brlcad/trunk/src/libged/CMakeLists.txt
brlcad/trunk/src/libged/edit_metaball.c
brlcad/trunk/src/libged/ged_private.h
brlcad/trunk/src/libtclcad/tclcad_obj.c
brlcad/trunk/src/tclscripts/archer/Archer.tcl
brlcad/trunk/src/tclscripts/archer/GeometryEditFrame.tcl
brlcad/trunk/src/tclscripts/archer/MetaballEditFrame.tcl
brlcad/trunk/src/tclscripts/lib/Ged.tcl
Added Paths:
-----------
brlcad/trunk/src/libged/pset.c
Modified: brlcad/trunk/include/ged.h
===================================================================
--- brlcad/trunk/include/ged.h 2013-05-03 18:03:17 UTC (rev 55307)
+++ brlcad/trunk/include/ged.h 2013-05-06 12:19:18 UTC (rev 55308)
@@ -1587,6 +1587,11 @@
GED_EXPORT extern int ged_pscale(struct ged *gedp, int argc, const char
*argv[]);
/**
+ * Set an obj's attribute to the specified value.
+ */
+GED_EXPORT extern int ged_pset(struct ged *gedp, int argc, const char *argv[]);
+
+/**
* Translate obj's attributes by tvec.
*/
GED_EXPORT extern int ged_ptranslate(struct ged *gedp, int argc, const char
*argv[]);
Modified: brlcad/trunk/src/libged/CMakeLists.txt
===================================================================
--- brlcad/trunk/src/libged/CMakeLists.txt 2013-05-03 18:03:17 UTC (rev
55307)
+++ brlcad/trunk/src/libged/CMakeLists.txt 2013-05-06 12:19:18 UTC (rev
55308)
@@ -182,6 +182,7 @@
protate.c
ps.c
pscale.c
+ pset.c
ptranslate.c
push.c
put.c
Modified: brlcad/trunk/src/libged/edit_metaball.c
===================================================================
--- brlcad/trunk/src/libged/edit_metaball.c 2013-05-03 18:03:17 UTC (rev
55307)
+++ brlcad/trunk/src/libged/edit_metaball.c 2013-05-06 12:19:18 UTC (rev
55308)
@@ -85,6 +85,39 @@
int
+_ged_set_metaball(struct ged *gedp, struct rt_metaball_internal *mbip, const
char *attribute, fastf_t sf)
+{
+ RT_METABALL_CK_MAGIC(mbip);
+
+ switch (attribute[0]) {
+ case 'm':
+ case 'M':
+ if (sf <= METABALL_METABALL)
+ mbip->method = METABALL_METABALL;
+ else if (sf >= METABALL_BLOB)
+ mbip->method = METABALL_BLOB;
+ else
+ mbip->method = (int)sf;
+
+ break;
+ case 't':
+ case 'T':
+ if (sf < 0)
+ mbip->threshold = -sf;
+ else
+ mbip->threshold = sf;
+
+ break;
+ default:
+ bu_vls_printf(gedp->ged_result_str, "bad metaball attribute - %s",
attribute);
+ return GED_ERROR;
+ }
+
+ return GED_OK;
+}
+
+
+int
_ged_scale_metaball(struct ged *gedp, struct rt_metaball_internal *mbip, const
char *attribute, fastf_t sf, int rflag)
{
int mbp_i;
@@ -120,16 +153,6 @@
GED_METABALL_SCALE(mbpp->sweat, sf);
break;
- case 'm':
- case 'M':
- mbip->method = (int)sf;
-
- break;
- case 't':
- case 'T':
- mbip->threshold = sf;
-
- break;
default:
bu_vls_printf(gedp->ged_result_str, "bad metaball attribute - %s",
attribute);
return GED_ERROR;
Modified: brlcad/trunk/src/libged/ged_private.h
===================================================================
--- brlcad/trunk/src/libged/ged_private.h 2013-05-03 18:03:17 UTC (rev
55307)
+++ brlcad/trunk/src/libged/ged_private.h 2013-05-06 12:19:18 UTC (rev
55308)
@@ -368,6 +368,10 @@
const char *attribute,
fastf_t sf,
int rflag);
+extern int _ged_set_metaball(struct ged *gedp,
+ struct rt_metaball_internal *mbip,
+ const char *attribute,
+ fastf_t sf);
/* defined in scale_part.c */
extern int _ged_scale_part(struct ged *gedp,
Added: brlcad/trunk/src/libged/pset.c
===================================================================
--- brlcad/trunk/src/libged/pset.c (rev 0)
+++ brlcad/trunk/src/libged/pset.c 2013-05-06 12:19:18 UTC (rev 55308)
@@ -0,0 +1,127 @@
+/* P S E T . C
+ * BRL-CAD
+ *
+ * Copyright (c) 2008-2013 United States Government as represented by
+ * the U.S. Army Research Laboratory.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this file; see the file named COPYING for more
+ * information.
+ */
+/** @file libged/pset.c
+ *
+ * The pset command.
+ */
+
+#include "common.h"
+
+#include <string.h>
+#include "bio.h"
+
+#include "cmd.h"
+#include "rtgeom.h"
+#include "raytrace.h"
+
+#include "./ged_private.h"
+
+
+int
+ged_pset(struct ged *gedp, int argc, const char *argv[])
+{
+ int ret;
+ struct rt_db_internal intern;
+
+ /* intentionally double for scan */
+ double val;
+
+ char *last;
+ struct directory *dp;
+ static const char *usage = "obj attribute val";
+
+ GED_CHECK_DATABASE_OPEN(gedp, GED_ERROR);
+ GED_CHECK_READ_ONLY(gedp, GED_ERROR);
+ GED_CHECK_ARGC_GT_0(gedp, argc, GED_ERROR);
+
+ /* initialize result */
+ bu_vls_trunc(gedp->ged_result_str, 0);
+
+ /* must be wanting help */
+ if (argc == 1) {
+ bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage);
+ return GED_HELP;
+ }
+
+ if (argc != 4) {
+ bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage);
+ return GED_ERROR;
+ }
+
+ if (sscanf(argv[3], "%lf", &val) != 1) {
+ bu_vls_printf(gedp->ged_result_str, "%s: bad value - %s", argv[0],
argv[3]);
+ return GED_ERROR;
+ }
+
+ if ((last = strrchr(argv[1], '/')) == NULL)
+ last = (char *)argv[1];
+ else
+ ++last;
+
+ if (last[0] == '\0') {
+ bu_vls_printf(gedp->ged_result_str, "%s: illegal input - %s", argv[0],
argv[1]);
+ return GED_ERROR;
+ }
+
+ if ((dp = db_lookup(gedp->ged_wdbp->dbip, last, LOOKUP_QUIET)) ==
RT_DIR_NULL) {
+ bu_vls_printf(gedp->ged_result_str, "%s: %s not found", argv[0],
argv[1]);
+ return GED_ERROR;
+ }
+
+ GED_DB_GET_INTERNAL(gedp, &intern, dp, (matp_t)NULL, &rt_uniresource,
GED_ERROR);
+ RT_CK_DB_INTERNAL(&intern);
+
+ if (intern.idb_major_type != DB5_MAJORTYPE_BRLCAD) {
+ bu_vls_printf(gedp->ged_result_str, "%s: Object not eligible for
scaling.", argv[0]);
+ rt_db_free_internal(&intern);
+
+ return GED_ERROR;
+ }
+
+ switch (intern.idb_minor_type) {
+ case DB5_MINORTYPE_BRLCAD_METABALL:
+ ret = _ged_set_metaball(gedp, (struct rt_metaball_internal
*)intern.idb_ptr, argv[2], val);
+ break;
+ default:
+ bu_vls_printf(gedp->ged_result_str, "%s: Object not yet
supported.", argv[0]);
+ rt_db_free_internal(&intern);
+
+ return GED_ERROR;
+ }
+
+ if (ret == GED_OK) {
+ GED_DB_PUT_INTERNAL(gedp, dp, &intern, &rt_uniresource, GED_ERROR);
+ } else if (ret == GED_ERROR) {
+ rt_db_free_internal(&intern);
+ }
+
+ return ret;
+}
+
+
+/*
+ * Local Variables:
+ * tab-width: 8
+ * mode: C
+ * indent-tabs-mode: t
+ * c-file-style: "stroustrup"
+ * End:
+ * ex: shiftwidth=4 tabstop=8
+ */
Property changes on: brlcad/trunk/src/libged/pset.c
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: brlcad/trunk/src/libtclcad/tclcad_obj.c
===================================================================
--- brlcad/trunk/src/libtclcad/tclcad_obj.c 2013-05-03 18:03:17 UTC (rev
55307)
+++ brlcad/trunk/src/libtclcad/tclcad_obj.c 2013-05-06 12:19:18 UTC (rev
55308)
@@ -1150,6 +1150,7 @@
{"ps", "[options] file.ps", 16, to_view_func, ged_ps},
{"pscale", (char *)0, TO_UNLIMITED, to_pass_through_func, ged_pscale},
{"pscale_mode", "obj attribute x y", TO_UNLIMITED, to_pscale_mode,
GED_FUNC_PTR_NULL},
+ {"pset", (char *)0, TO_UNLIMITED, to_pass_through_func, ged_pset},
{"ptranslate", (char *)0, TO_UNLIMITED, to_pass_through_func,
ged_ptranslate},
{"ptranslate_mode", "obj attribute x y", TO_UNLIMITED,
to_ptranslate_mode, GED_FUNC_PTR_NULL},
{"push", (char *)0, TO_UNLIMITED, to_pass_through_func, ged_push},
Modified: brlcad/trunk/src/tclscripts/archer/Archer.tcl
===================================================================
--- brlcad/trunk/src/tclscripts/archer/Archer.tcl 2013-05-03 18:03:17 UTC
(rev 55307)
+++ brlcad/trunk/src/tclscripts/archer/Archer.tcl 2013-05-06 12:19:18 UTC
(rev 55308)
@@ -185,6 +185,7 @@
method p {args}
method p_protate {args}
method p_pscale {args}
+ method p_pset {args}
method p_ptranslate {args}
method p_move_arb_edge {args}
method p_move_arb_face {args}
@@ -1647,6 +1648,12 @@
}
+::itcl::body Archer::p_pset {args} {
+ catch {eval gedCmd pset $args} ret
+ return $ret
+}
+
+
::itcl::body Archer::p_ptranslate {args} {
catch {eval gedCmd ptranslate $args} ret
return $ret
Modified: brlcad/trunk/src/tclscripts/archer/GeometryEditFrame.tcl
===================================================================
--- brlcad/trunk/src/tclscripts/archer/GeometryEditFrame.tcl 2013-05-03
18:03:17 UTC (rev 55307)
+++ brlcad/trunk/src/tclscripts/archer/GeometryEditFrame.tcl 2013-05-06
12:19:18 UTC (rev 55308)
@@ -50,6 +50,7 @@
common EDIT_CLASS_ROT 1
common EDIT_CLASS_SCALE 2
common EDIT_CLASS_TRANS 3
+ common EDIT_CLASS_SET 4
common mEditMode 0
common mPrevEditMode 0
Modified: brlcad/trunk/src/tclscripts/archer/MetaballEditFrame.tcl
===================================================================
--- brlcad/trunk/src/tclscripts/archer/MetaballEditFrame.tcl 2013-05-03
18:03:17 UTC (rev 55307)
+++ brlcad/trunk/src/tclscripts/archer/MetaballEditFrame.tcl 2013-05-06
12:19:18 UTC (rev 55308)
@@ -231,10 +231,10 @@
$::ArcherCore::application p_pscale $obj s$mb_i $args
} \
$setMethod {
- $::ArcherCore::application p_pscale $obj m $args
+ $::ArcherCore::application p_pset $obj m $args
} \
$setThreshold {
- $::ArcherCore::application p_pscale $obj t $args
+ $::ArcherCore::application p_pset $obj t $args
}
highlightCurrentPoint
@@ -341,13 +341,13 @@
$::ArcherCore::application initFindMetaballPoint
$itk_option(-geometryObjectPath) 1 [::itcl::code $this
metaballPointDeleteCallback] 1
} \
$setThreshold {
- set mEditCommand pscale
- set mEditClass $EDIT_CLASS_SCALE
+ set mEditCommand pset
+ set mEditClass $EDIT_CLASS_SET
set mEditParam1 t
} \
$setMethod {
- set mEditCommand pscale
- set mEditClass $EDIT_CLASS_SCALE
+ set mEditCommand pset
+ set mEditClass $EDIT_CLASS_SET
set mEditParam1 m
} \
$setFieldStrength {
Modified: brlcad/trunk/src/tclscripts/lib/Ged.tcl
===================================================================
--- brlcad/trunk/src/tclscripts/lib/Ged.tcl 2013-05-03 18:03:17 UTC (rev
55307)
+++ brlcad/trunk/src/tclscripts/lib/Ged.tcl 2013-05-06 12:19:18 UTC (rev
55308)
@@ -527,6 +527,7 @@
method protate_mode {args}
method pscale {args}
method pscale_mode {args}
+ method pset {args}
method ptranslate {args}
method ptranslate_mode {args}
method scale {args}
@@ -3228,6 +3229,10 @@
eval $mGed pscale_mode $itk_component($itk_option(-pane)) $args
}
+::itcl::body cadwidgets::Ged::pset {args} {
+ eval $mGed pset $args
+}
+
::itcl::body cadwidgets::Ged::ptranslate {args} {
eval $mGed ptranslate $args
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET
Get 100% visibility into your production application - at no cost.
Code-level diagnostics for performance bottlenecks with <2% overhead
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap1
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits