box3d-toolbar.cpp revision e50f071ebc01110b5701d9c197983305311e145f
/**
* @file
* 3d box aux toolbar
*/
/* Authors:
* MenTaLguY <mental@rydia.net>
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
* Frank Felfe <innerspace@iname.com>
* John Cliff <simarilius@yahoo.com>
* David Turner <novalis@gnu.org>
* Josh Andler <scislac@scislac.com>
* Jon A. Cruz <jon@joncruz.org>
* Maximilian Albert <maximilian.albert@gmail.com>
* Tavmjong Bah <tavmjong@free.fr>
* Abhishek Sharma
* Kris De Gussem <Kris.DeGussem@gmail.com>
*
* Copyright (C) 2004 David Turner
* Copyright (C) 2003 MenTaLguY
* Copyright (C) 1999-2011 authors
* Copyright (C) 2001-2002 Ximian, Inc.
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "ui/widget/spinbutton.h"
#include "toolbox.h"
#include "box3d-toolbar.h"
#include "../desktop.h"
#include "../desktop-handles.h"
#include "document-undo.h"
#include "../verbs.h"
#include "../inkscape.h"
#include "../selection-chemistry.h"
#include "../selection.h"
#include "../ege-adjustment-action.h"
#include "../ege-output-action.h"
#include "../ege-select-one-action.h"
#include "../ink-action.h"
#include "../ink-comboboxentry-action.h"
#include "../widgets/spinbutton-events.h"
#include "../widgets/spw-utilities.h"
#include "../widgets/widget-sizes.h"
#include "../xml/node-event-vector.h"
#include "ui/uxmanager.h"
#include "../ui/icon-names.h"
#include "../pen-context.h"
#include "../box3d-context.h"
#include "../box3d.h"
using Inkscape::DocumentUndo;
//########################
//## 3D Box ##
//########################
// normalize angle so that it lies in the interval [0,360]
static double box3d_normalize_angle (double a) {
if (angle < 0) {
angle += 360.0;
}
return angle;
}
{
// TODO: Take all selected perspectives into account but don't touch the state button if not all of them
// have the same state (otherwise a call to box3d_vp_z_state_changed() is triggered and the states
// are reset).
if (is_infinite) {
if (angle != Geom::infinity()) { // FIXME: We should catch this error earlier (don't show the spinbutton at all)
}
} else {
}
}
{
if (!persp_repr) {
g_print ("No perspective given to box3d_resync_toolbar().\n");
return;
}
GtkAdjustment *adj = 0;
GtkToggleAction *tact = 0;
if (!persp) {
// Hmm, is it an error if this happens?
return;
}
{
}
{
}
{
}
}
gchar const * /*name*/,
gchar const * /*old_value*/,
gchar const * /*new_value*/,
bool /*is_interactive*/,
{
// quit if run by the attr_changed or selection changed listener
return;
}
// set freeze so that it can be caught in box3d_angle_z_value_changed() (to avoid calling
// SPDocumentUndo::maybeDone() when the document is undo insensitive)
// TODO: Only update the appropriate part of the toolbar
// if (!strcmp(name, "inkscape:vp_z")) {
// }
}
{
NULL, /* child_added */
NULL, /* child_removed */
NULL, /* content_changed */
NULL /* order_changed */
};
/**
* \param selection Should not be NULL.
*/
// FIXME: This should rather be put into persp3d-reference.cpp or something similar so that it reacts upon each
// Change of the perspective, and not of the current selection (but how to refer to the toolbar then?)
{
// Here the following should be done: If all selected boxes have finite VPs in a certain direction,
// disable the angle entry fields for this direction (otherwise entering a value in them should only
// update the perspectives with infinite VPs and leave the other ones untouched).
// FIXME: Also deal with multiple selected boxes
if (persp_repr) {
}
}
}
{
// quit if run by the attr_changed or selection changed listener
return;
}
// in turn, prevent listener from responding
if (sel_persps.empty()) {
// this can happen when the document is created; we silently ignore it
return;
}
persp->updateRepr();
// TODO: use the correct axis here, too
DocumentUndo::maybeDone(document, "perspangle", SP_VERB_CONTEXT_3DBOX, _("3D Box: Change perspective (angle of infinite axis)"));
}
{
}
{
}
{
}
static void box3d_vp_state_changed( GtkToggleAction *act, GtkAction * /*box3d_angle*/, Proj::Axis axis )
{
// TODO: Take all selected perspectives into account
if (sel_persps.empty()) {
// this can happen when the document is created; we silently ignore it
return;
}
}
{
}
{
}
{
}
{
EgeAdjustmentAction* eact = 0;
/* Angle X */
{
_("Angle in X direction"), _("Angle X:"),
// Translators: PL is short for 'perspective line'
_("Angle of PLs in X direction"),
"/tools/shapes/3dbox/box3d_angle_x", 30,
-360.0, 360.0, 1.0, 10.0,
}
} else {
}
/* VP X state */
{
// Translators: VP is short for 'vanishing point'
_("State of VP in X direction"),
_("Toggle VP in X direction between 'finite' and 'infinite' (=parallel)"),
INKSCAPE_ICON("perspective-parallel"),
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(box3d_vp_x_state_changed), box3d_angle_x );
gtk_action_set_sensitive( GTK_ACTION(box3d_angle_x), !prefs->getBool("/tools/shapes/3dbox/vp_x_state", true) );
gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/shapes/3dbox/vp_x_state", true) );
}
/* Angle Y */
{
_("Angle in Y direction"), _("Angle Y:"),
// Translators: PL is short for 'perspective line'
_("Angle of PLs in Y direction"),
"/tools/shapes/3dbox/box3d_angle_y", 30,
-360.0, 360.0, 1.0, 10.0,
}
} else {
}
/* VP Y state */
{
// Translators: VP is short for 'vanishing point'
_("State of VP in Y direction"),
_("Toggle VP in Y direction between 'finite' and 'infinite' (=parallel)"),
INKSCAPE_ICON("perspective-parallel"),
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(box3d_vp_y_state_changed), box3d_angle_y );
gtk_action_set_sensitive( GTK_ACTION(box3d_angle_y), !prefs->getBool("/tools/shapes/3dbox/vp_y_state", true) );
gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/shapes/3dbox/vp_y_state", true) );
}
/* Angle Z */
{
_("Angle in Z direction"), _("Angle Z:"),
// Translators: PL is short for 'perspective line'
_("Angle of PLs in Z direction"),
"/tools/shapes/3dbox/box3d_angle_z", 30,
-360.0, 360.0, 1.0, 10.0,
}
} else {
}
/* VP Z state */
{
// Translators: VP is short for 'vanishing point'
_("State of VP in Z direction"),
_("Toggle VP in Z direction between 'finite' and 'infinite' (=parallel)"),
INKSCAPE_ICON("perspective-parallel"),
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(box3d_vp_z_state_changed), box3d_angle_z );
gtk_action_set_sensitive( GTK_ACTION(box3d_angle_z), !prefs->getBool("/tools/shapes/3dbox/vp_z_state", true) );
gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/shapes/3dbox/vp_z_state", true) );
}
sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(box3d_toolbox_selection_changed), G_OBJECT(holder)))
);
}
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :