summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f7c0e9e)
raw | patch | inline | side by side (parent: f7c0e9e)
author | johanengelen <johanengelen@users.sourceforge.net> | |
Mon, 16 Oct 2006 09:40:03 +0000 (09:40 +0000) | ||
committer | johanengelen <johanengelen@users.sourceforge.net> | |
Mon, 16 Oct 2006 09:40:03 +0000 (09:40 +0000) |
diff --git a/src/desktop.cpp b/src/desktop.cpp
index 47dbe1bec648890668f91ef24c244876f1a8305e..d7a081fafd14288e3c465f70176af263a79640b5 100644 (file)
--- a/src/desktop.cpp
+++ b/src/desktop.cpp
* Ralf Stephan <ralf@ark.in-berlin.de>
* John Bintz <jcoswell@coswellproductions.org>
*
+ * Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl>
* Copyright (C) 2006 John Bintz
* Copyright (C) 2004 MenTaLguY
* Copyright (C) 1999-2002 Lauris Kaplinski
nv.snap_manager.grid.setDistance(sp_convert_distance_full(nv.gridtolerance,
*nv.gridtoleranceunit,
px));
+ nv.snap_manager.axonomgrid.setDistance(sp_convert_distance_full(nv.gridtolerance,
+ *nv.gridtoleranceunit,
+ px));
nv.snap_manager.guide.setDistance(sp_convert_distance_full(nv.guidetolerance,
*nv.guidetoleranceunit,
px));
diff --git a/src/grid-snapper.cpp b/src/grid-snapper.cpp
index 5c94b9a97d4772bb0648647125534271b5fe151f..03f6c9d3a22028a75db28aa4b2b78c36cb5dba9b 100644 (file)
--- a/src/grid-snapper.cpp
+++ b/src/grid-snapper.cpp
* Frank Felfe <innerspace@iname.com>
* Carl Hetherington <inkscape@carlh.net>
*
+ * Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl>
* Copyright (C) 1999-2002 Authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
#include "inkscape.h"
#include "desktop.h"
#include "display/canvas-grid.h"
+#include "display/canvas-axonomgrid.h"
/**
* \return x rounded to the nearest multiple of c1 plus c0.
}
-Inkscape::LineSnapper::LineList Inkscape::GridSnapper::_getSnapLines(NR::Point const &p) const
+Inkscape::LineSnapper::LineList
+Inkscape::GridSnapper::_getSnapLines(NR::Point const &p) const
{
LineList s;
// must be rethought and maybe only the current view
// should give back it's SHOWN lines to snap to
// For now, the last SPCGrid in _named_view->gridviews will be used.
- griditem = SP_CGRID(l->data);
+ if ( SP_IS_CGRID(GTK_OBJECT(l->data)) ) {
+ griditem = SP_CGRID(l->data);
+ }
}
g_assert(griditem != NULL);
return s;
}
+
+
+Inkscape::AxonomGridSnapper::AxonomGridSnapper(SPNamedView const *nv, NR::Coord const d) : LineSnapper(nv, d)
+{
+
+}
+
+
+Inkscape::LineSnapper::LineList
+Inkscape::AxonomGridSnapper::_getSnapLines(NR::Point const &p) const
+{
+ LineList s;
+
+ if ( NULL == _named_view ) {
+ return s;
+ }
+
+ SPCAxonomGrid *griditem = NULL;
+ for (GSList *l = _named_view->gridviews; l != NULL; l = l->next) {
+ // FIXME : this is a hack since there is only one view for now
+ // but when we'll handle multiple views, snapping should
+ // must be rethought and maybe only the current view
+ // should give back it's SHOWN lines to snap to
+ // For now, the last SPCAxonomGrid in _named_view->gridviews will be used.
+ if ( SP_IS_CAXONOMGRID(GTK_OBJECT(l->data)) ) {
+ griditem = SP_CAXONOMGRID(l->data);
+ }
+ }
+
+ g_assert(griditem != NULL);
+
+ // add vertical line.
+
+
+ // This is to make sure we snap to only visible grid lines
+ double scaled_spacing = griditem->spacing_ylines; // this is spacing of visible lines if screen pixels
+ // convert screen pixels to px
+ // FIXME: after we switch to snapping dist in screen pixels, this will be unnecessary
+ if (SP_ACTIVE_DESKTOP) {
+ scaled_spacing /= SP_ACTIVE_DESKTOP->current_zoom();
+ }
+
+ NR::Coord const rounded = round_to_nearest_multiple_plus(p[0], scaled_spacing, griditem->origin[0]);
+
+ int a = round(scaled_spacing);
+ int b = round(p[0]);
+ int c = round(rounded);
+
+ g_message("hier %d; %d; %d",a,b,c);
+
+
+ s.push_back(std::make_pair(NR::Dim2(0), rounded));
+
+
+ return s;
+}
+
+
+
/*
Local Variables:
mode:c++
diff --git a/src/grid-snapper.h b/src/grid-snapper.h
index 247823ac7738cb4cb022a86ffc0b08f13a4a4f68..c664c5f9b880a89d6282b1eadce52f68a9710278 100644 (file)
--- a/src/grid-snapper.h
+++ b/src/grid-snapper.h
* Frank Felfe <innerspace@iname.com>
* Carl Hetherington <inkscape@carlh.net>
*
+ * Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl>
* Copyright (C) 1999-2002 Authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
private:
LineList _getSnapLines(NR::Point const &p) const;
-};
+};
+
+
+class AxonomGridSnapper : public LineSnapper
+{
+public:
+ AxonomGridSnapper(SPNamedView const *nv, NR::Coord const d);
+
+private:
+ LineList _getSnapLines(NR::Point const &p) const;
+};
+
+
}
diff --git a/src/snap.cpp b/src/snap.cpp
index 9e41603def439c24d21feca5763dabdc80a54c19..de74d6cc6f30e37626da24461d905c2067b7a07b 100644 (file)
--- a/src/snap.cpp
+++ b/src/snap.cpp
* Frank Felfe <innerspace@iname.com>
* Carl Hetherington <inkscape@carlh.net>
*
+ * Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl>
* Copyright (C) 1999-2002 Authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
* \param v `Owning' SPNamedView.
*/
-SnapManager::SnapManager(SPNamedView const *v) : grid(v, 0), guide(v, 0), object(v, 0)
+SnapManager::SnapManager(SPNamedView const *v) : _named_view(v), grid(v, 0), axonomgrid(v, 0), guide(v, 0), object(v, 0)
{
}
SnapManager::SnapperList SnapManager::getSnappers() const
{
SnapManager::SnapperList s;
- s.push_back(&grid);
+ if (_named_view->gridtype == 0) {
+ s.push_back(&grid);
+ } else {
+ s.push_back(&axonomgrid);
+ }
s.push_back(&guide);
s.push_back(&object);
return s;
diff --git a/src/snap.h b/src/snap.h
index ea833b0ecc64ee6f25beba6b468bda559d533f5f..ff3da3adbcdc4f2f868ee9da7ab15465b664eca5 100644 (file)
--- a/src/snap.h
+++ b/src/snap.h
* Frank Felfe <innerspace@iname.com>
* Carl Hetherington <inkscape@carlh.net>
*
+ * Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl>
* Copyright (C) 2000-2002 Lauris Kaplinski
*
* Released under GNU GPL, read the file 'COPYING' for more information
NR::Point const &o,
NR::Dim2 d) const;
- Inkscape::GridSnapper grid; ///< grid snapper
- Inkscape::GuideSnapper guide; ///< guide snapper
- Inkscape::ObjectSnapper object; ///< snapper to other objects
+ Inkscape::GridSnapper grid; ///< grid snapper
+ Inkscape::AxonomGridSnapper axonomgrid; ///< axonometricgrid snapper
+ Inkscape::GuideSnapper guide; ///< guide snapper
+ Inkscape::ObjectSnapper object; ///< snapper to other objects
typedef std::list<const Inkscape::Snapper*> SnapperList;
SnapperList getSnappers() const;
+protected:
+ SPNamedView const *_named_view;
+
private:
enum Transformation {
diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp
index 27b19fee605367c827c17b2129c1ffc2044afe89..da95a8ab70449d9714719d334d15a3226ad46ee9 100644 (file)
--- a/src/sp-namedview.cpp
+++ b/src/sp-namedview.cpp
@@ -230,6 +230,7 @@ static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *va
sp_namedview_setup_grid(nv);
/* Disable grid snaps if the grid is turned off */
nv->snap_manager.grid.setEnabled(nv->showgrid);
+ nv->snap_manager.axonomgrid.setEnabled(nv->showgrid);
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
case SP_ATTR_GRIDTYPE:
@@ -459,10 +460,12 @@ static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *va
break;
case SP_ATTR_INKSCAPE_GRID_BBOX:
nv->snap_manager.grid.setSnapTo(Inkscape::Snapper::BBOX_POINT, value ? sp_str_to_bool(value) : TRUE);
+ nv->snap_manager.axonomgrid.setSnapTo(Inkscape::Snapper::BBOX_POINT, value ? sp_str_to_bool(value) : TRUE);
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
case SP_ATTR_INKSCAPE_GRID_POINTS:
nv->snap_manager.grid.setSnapTo(Inkscape::Snapper::SNAP_POINT, value ? sp_str_to_bool(value) : FALSE);
+ nv->snap_manager.axonomgrid.setSnapTo(Inkscape::Snapper::SNAP_POINT, value ? sp_str_to_bool(value) : FALSE);
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
case SP_ATTR_INKSCAPE_GUIDE_BBOX: