transformation.cpp revision cf1b00269e6a363acfe397115fb123d1999759fd
/**
* @file
* Transform dialog - implementation.
*/
/* Authors:
* Bryce W. Harrington <bryce@bryceharrington.org>
* buliabyak@gmail.com
* Abhishek Sharma
*
* Copyright (C) 2004, 2005 Authors
* Released under GNU GPL. Read the file 'COPYING' for more information.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#endif
#include "document.h"
#include "document-undo.h"
#include "desktop-handles.h"
#include "transformation.h"
#include "align-and-distribute.h"
#include "inkscape.h"
#include "selection.h"
#include "selection-chemistry.h"
#include "message-stack.h"
#include "verbs.h"
#include "preferences.h"
#include "sp-namedview.h"
#include "sp-item-transform.h"
#include "macros.h"
#include "sp-item.h"
#include "util/glib-list-iterators.h"
#include "ui/icon-names.h"
namespace Inkscape {
namespace UI {
namespace Dialog {
{
}
{
}
/*########################################################################
# C O N S T R U C T O R
########################################################################*/
_scalar_move_horizontal (_("_Horizontal:"), _("Horizontal displacement (relative) or position (absolute)"), UNIT_TYPE_LINEAR,
_scalar_move_vertical (_("_Vertical:"), _("Vertical displacement (relative) or position (absolute)"), UNIT_TYPE_LINEAR,
_scalar_scale_horizontal(_("_Width:"), _("Horizontal size (absolute or percentage of current)"), UNIT_TYPE_DIMENSIONLESS,
_scalar_scale_vertical (_("_Height:"), _("Vertical size (absolute or percentage of current)"), UNIT_TYPE_DIMENSIONLESS,
_scalar_skew_horizontal (_("_Horizontal:"), _("Horizontal skew angle (positive = counterclockwise), or absolute displacement, or percentage displacement"), UNIT_TYPE_LINEAR,
_scalar_skew_vertical (_("_Vertical:"), _("Vertical skew angle (positive = counterclockwise), or absolute displacement, or percentage displacement"), UNIT_TYPE_LINEAR,
_check_move_relative (_("Rela_tive move"), _("Add the specified relative displacement to the current position; otherwise, edit the current absolute position directly")),
_check_scale_proportional (_("_Scale proportionally"), _("Preserve the width/height ratio of the scaled objects")),
_check_apply_separately (_("Apply to each _object separately"), _("Apply the scale/rotate/skew to each selected object separately; otherwise, transform the selection as a whole")),
_check_replace_matrix (_("Edit c_urrent matrix"), _("Edit the current transform= matrix; otherwise, post-multiply transform= by this matrix"))
{
contents->set_spacing(0);
// Notebook for individual transformations
// Apply separately
_check_apply_separately.signal_toggled().connect(sigc::mem_fun(*this, &Transformation::onApplySeparatelyToggled));
// make sure all spinbuttons activate Apply on pressing Enter
if (resetButton) {
resetButton->set_sensitive(true);
}
if (applyButton) {
applyButton->set_sensitive(false);
}
// Connect to the global selection changed & modified signals
INKSCAPE->signal_selection_changed.connect(sigc::hide<0>(sigc::bind(sigc::ptr_fun(&on_selection_changed), this)));
INKSCAPE->signal_selection_modified.connect(sigc::hide<0>(sigc::hide<1>(sigc::bind(sigc::ptr_fun(&on_selection_modified), this))));
//g_signal_connect (G_OBJECT (INKSCAPE), "change_selection", G_CALLBACK (on_selection_changed), this);
//g_signal_connect (G_OBJECT (INKSCAPE), "modify_selection", G_CALLBACK (on_selection_modified), this);
_desktopChangeConn = _deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &Transformation::setDesktop) );
}
{
}
{
}
}
/*########################################################################
# U T I L I T Y
########################################################################*/
{
show();
present();
}
/*########################################################################
# S E T U P L A Y O U T
########################################################################*/
void Transformation::layoutPageMove()
{
// Setting default unit to document unit
}
//_scalar_move_vertical.set_label_image( INKSCAPE_STOCK_ARROWS_HOR );
#if WITH_GTKMM_3_0
#else
#endif
//_scalar_move_vertical.set_label_image( INKSCAPE_STOCK_ARROWS_VER );
#if WITH_GTKMM_3_0
#else
#endif
// Relative moves
#if WITH_GTKMM_3_0
#else
#endif
_check_move_relative.set_active(true);
}
void Transformation::layoutPageScale()
{
#if WITH_GTKMM_3_0
#else
#endif
#if WITH_GTKMM_3_0
#else
#endif
#if WITH_GTKMM_3_0
#else
#endif
_check_scale_proportional.set_active(false);
//TODO: add a widget for selecting the fixed point in scaling, or honour rotation center?
}
void Transformation::layoutPageRotate()
{
_counterclockwise_rotate.set_mode(false);
_clockwise_rotate.set_mode(false);
#if WITH_GTKMM_3_0
#else
#endif
} else {
}
_counterclockwise_rotate.signal_clicked().connect(sigc::mem_fun(*this, &Transformation::onRotateCounterclockwiseClicked));
_clockwise_rotate.signal_clicked().connect(sigc::mem_fun(*this, &Transformation::onRotateClockwiseClicked));
//TODO: honour rotation center?
}
void Transformation::layoutPageSkew()
{
#if WITH_GTKMM_3_0
#else
#endif
#if WITH_GTKMM_3_0
#else
#endif
//TODO: honour rotation center?
}
void Transformation::layoutPageTransform()
{
#if WITH_GTKMM_3_0
#else
#endif
#if WITH_GTKMM_3_0
#else
#endif
#if WITH_GTKMM_3_0
#else
#endif
#if WITH_GTKMM_3_0
#else
#endif
#if WITH_GTKMM_3_0
#else
#endif
#if WITH_GTKMM_3_0
#else
#endif
// Edit existing matrix
#if WITH_GTKMM_3_0
#else
#endif
_check_replace_matrix.set_active(false);
}
/*########################################################################
# U P D A T E
########################################################################*/
{
return;
switch (page) {
case PAGE_MOVE: {
break;
}
case PAGE_SCALE: {
break;
}
case PAGE_ROTATE: {
break;
}
case PAGE_SKEW: {
break;
}
case PAGE_TRANSFORM: {
break;
}
case PAGE_QTY: {
break;
}
}
}
#if WITH_GTKMM_3_0
#else
#endif
{
}
{
if (!_check_move_relative.get_active()) {
if (bbox) {
}
} else {
// do nothing, so you can apply the same relative move to many objects in turn
}
_page_move.set_sensitive(true);
} else {
_page_move.set_sensitive(false);
}
}
{
if (bbox) {
onScaleXValueChanged(); // to update x/y proportionality if switch is on
_page_scale.set_sensitive(true);
} else {
_page_scale.set_sensitive(false);
}
} else {
_page_scale.set_sensitive(false);
}
}
{
_page_rotate.set_sensitive(true);
} else {
_page_rotate.set_sensitive(false);
}
}
{
if (bbox) {
_page_skew.set_sensitive(true);
} else {
_page_skew.set_sensitive(false);
}
} else {
_page_skew.set_sensitive(false);
}
}
{
if (_check_replace_matrix.get_active()) {
Geom::Affine current (SP_ITEM(selection->itemList()->data)->transform); // take from the first item in selection
} else {
// do nothing, so you can apply the same matrix to many objects in turn
}
_page_transform.set_sensitive(true);
} else {
_page_transform.set_sensitive(false);
}
}
/*########################################################################
# A P P L Y
########################################################################*/
void Transformation::_apply()
{
return;
switch (page) {
case PAGE_MOVE: {
break;
}
case PAGE_ROTATE: {
break;
}
case PAGE_SCALE: {
break;
}
case PAGE_SKEW: {
break;
}
case PAGE_TRANSFORM: {
break;
}
}
//Let's play with never turning this off
//setResponseSensitive(Gtk::RESPONSE_APPLY, false);
}
{
// move selection as a whole
if (_check_move_relative.get_active()) {
sp_selection_move_relative(selection, x, y);
} else {
if (bbox) {
}
}
} else {
if (_check_move_relative.get_active()) {
// shift each object relatively to the previous one
if (fabs(x) > 1e-6) {
++it)
{
if (bbox) {
}
}
//sort bbox by anchors
double move = x;
++it )
{
// move each next object by x relative to previous
move += x;
}
}
if (fabs(y) > 1e-6) {
++it)
{
if (bbox) {
}
}
//sort bbox by anchors
double move = y;
++it )
{
// move each next object by x relative to previous
move += y;
}
}
} else {
if (bbox) {
}
}
}
_("Move"));
}
{
double new_height = scaleY;
// the values are increments!
}
if (fabs(new_width) < 1e-6) new_width = 1e-6; // not 0, as this would result in a nasty no-bbox object
Geom::Affine scaler = get_scale_transform_for_variable_stroke (*bbox_pref, *bbox_geom, transform_stroke, preserve, x0, y0, x1, y1);
}
}
} else {
// the values are increments!
double new_height = scaleY;
}
Geom::Affine scaler = get_scale_transform_for_variable_stroke (*bbox_pref, *bbox_geom, transform_stroke, preserve, x0, y0, x1, y1);
}
}
_("Scale"));
}
{
angle *= -1;
}
}
} else {
if (center) {
}
}
_("Rotate"));
}
{
sp_desktop_message_stack(getDesktop())->flash(Inkscape::WARNING_MESSAGE, _("Transform matrix is singular, <b>not used</b>."));
return;
}
sp_desktop_message_stack(getDesktop())->flash(Inkscape::WARNING_MESSAGE, _("Transform matrix is singular, <b>not used</b>."));
return;
}
} else { // absolute displacement
if (bbox) {
sp_desktop_message_stack(getDesktop())->flash(Inkscape::WARNING_MESSAGE, _("Transform matrix is singular, <b>not used</b>."));
return;
}
}
}
}
} else { // transform whole selection
sp_desktop_message_stack(getDesktop())->flash(Inkscape::WARNING_MESSAGE, _("Transform matrix is singular, <b>not used</b>."));
return;
}
sp_desktop_message_stack(getDesktop())->flash(Inkscape::WARNING_MESSAGE, _("Transform matrix is singular, <b>not used</b>."));
return;
}
} else { // absolute displacement
sp_desktop_message_stack(getDesktop())->flash(Inkscape::WARNING_MESSAGE, _("Transform matrix is singular, <b>not used</b>."));
return;
}
}
}
}
_("Skew"));
}
{
double a = _scalar_transform_a.getValue();
double b = _scalar_transform_b.getValue();
double c = _scalar_transform_c.getValue();
double d = _scalar_transform_d.getValue();
double e = _scalar_transform_e.getValue();
double f = _scalar_transform_f.getValue();
if (displayed.isSingular()) {
sp_desktop_message_stack(getDesktop())->flash(Inkscape::WARNING_MESSAGE, _("Transform matrix is singular, <b>not used</b>."));
return;
}
if (_check_replace_matrix.get_active()) {
}
} else {
}
_("Edit transformation matrix"));
}
/*########################################################################
# V A L U E - C H A N G E D C A L L B A C K S
########################################################################*/
void Transformation::onMoveValueChanged()
{
}
void Transformation::onMoveRelativeToggled()
{
return;
//g_message("onMoveRelativeToggled: %f, %f px\n", x, y);
if (bbox) {
if (_check_move_relative.get_active()) {
// From absolute to relative
} else {
// From relative to absolute
}
}
}
void Transformation::onScaleXValueChanged()
{
return;
}
if (_check_scale_proportional.get_active()) {
} else {
}
}
}
void Transformation::onScaleYValueChanged()
{
return;
}
if (_check_scale_proportional.get_active()) {
} else {
}
}
}
void Transformation::onRotateValueChanged()
{
}
{
}
{
}
void Transformation::onSkewValueChanged()
{
}
{
/*
double a = _scalar_transform_a.getValue();
double b = _scalar_transform_b.getValue();
double c = _scalar_transform_c.getValue();
double d = _scalar_transform_d.getValue();
double e = _scalar_transform_e.getValue();
double f = _scalar_transform_f.getValue();
//g_message("onTransformValueChanged: (%f, %f, %f, %f, %f, %f)\n",
// a, b, c, d, e ,f);
*/
}
void Transformation::onReplaceMatrixToggled()
{
return;
double a = _scalar_transform_a.getValue();
double b = _scalar_transform_b.getValue();
double c = _scalar_transform_c.getValue();
double d = _scalar_transform_d.getValue();
double e = _scalar_transform_e.getValue();
double f = _scalar_transform_f.getValue();
Geom::Affine current = SP_ITEM(selection->itemList()->data)->transform; // take from the first item in selection
if (_check_replace_matrix.get_active()) {
} else {
}
}
{
}
void Transformation::onClear()
{
switch (page) {
case PAGE_MOVE: {
} else {
if (bbox) {
}
}
break;
}
case PAGE_ROTATE: {
break;
}
case PAGE_SCALE: {
break;
}
case PAGE_SKEW: {
break;
}
case PAGE_TRANSFORM: {
break;
}
}
}
{
}
} // namespace Dialog
} // namespace UI
} // namespace Inkscape
/*
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 :