diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-01-20 01:29:50 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-01-20 01:29:50 +0000 |
commit | 8362bf63dea22bbf6736609b0f49c152f975eb63 (patch) | |
tree | 0eea3928e39e50fae91d4e68b21b1e6cbae25604 /krita/plugins/tools/tool_perspectivegrid | |
download | koffice-8362bf63dea22bbf6736609b0f49c152f975eb63.tar.gz koffice-8362bf63dea22bbf6736609b0f49c152f975eb63.zip |
Added old abandoned KDE3 version of koffice
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1077364 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'krita/plugins/tools/tool_perspectivegrid')
8 files changed, 869 insertions, 0 deletions
diff --git a/krita/plugins/tools/tool_perspectivegrid/Makefile.am b/krita/plugins/tools/tool_perspectivegrid/Makefile.am new file mode 100644 index 00000000..f6182410 --- /dev/null +++ b/krita/plugins/tools/tool_perspectivegrid/Makefile.am @@ -0,0 +1,34 @@ +kde_services_DATA = kritatoolperspectivegrid.desktop + +# all_includes must remain last! +INCLUDES = -I$(srcdir)/../../../sdk \ + -I$(srcdir)/../../../core \ + -I$(srcdir)/../../../kritacolor/ \ + -I$(srcdir)/../../../ui \ + -I$/../../../ui \ + $(KOFFICE_INCLUDES) \ + $(all_includes) + +kritatoolperspectivegrid_la_SOURCES = \ + tool_perspectivegrid.cc \ + kis_tool_perspectivegrid.cc + +# Install this plugin in the KDE modules directory +kde_module_LTLIBRARIES = kritatoolperspectivegrid.la + +noinst_HEADERS = \ + tool_perspectivegrid.h \ + kis_tool_perspectivegrid.h + +kritatoolperspectivegrid_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) +kritatoolperspectivegrid_la_LIBADD = ../../../libkritacommon.la + +METASOURCES = AUTO + +KDE_OPTIONS = nofinal + +kritapics_DATA = \ + tool_perspectivegrid.png + +kritapicsdir = $(kde_datadir)/krita/pics + diff --git a/krita/plugins/tools/tool_perspectivegrid/kis_tool_perspectivegrid.cc b/krita/plugins/tools/tool_perspectivegrid/kis_tool_perspectivegrid.cc new file mode 100644 index 00000000..944807eb --- /dev/null +++ b/krita/plugins/tools/tool_perspectivegrid/kis_tool_perspectivegrid.cc @@ -0,0 +1,499 @@ +/* + * kis_tool_perspectivegrid.cc - part of Krita + * + * Copyright (c) 2006 Cyrille Berger <cberger@cberger.net> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#include <kis_tool_perspectivegrid.h> + +#include <qapplication.h> +#include <qpainter.h> +#include <qregion.h> +#include <qwidget.h> +#include <qlayout.h> + +#include <kaction.h> +#include <kdebug.h> +#include <kcommand.h> +#include <klocale.h> + +#include <kis_button_press_event.h> +#include <kis_button_release_event.h> +#include <kis_canvas_controller.h> +#include <kis_canvas_painter.h> +#include <kis_canvas_subject.h> +#include <kis_cursor.h> +#include <kis_image.h> +#include <kis_move_event.h> +#include <kis_perspective_grid_manager.h> +#include <kis_selected_transaction.h> +#include <kis_painter.h> +#include <kis_paintop_registry.h> +#include <kis_vec.h> + +#include <kis_canvas.h> + +KisToolPerspectiveGrid::KisToolPerspectiveGrid() + : super(i18n("Perspective Grid")), m_handleSize(13), m_handleHalfSize(6) + +{ + setName("tool_perspectivegrid"); + + m_subject = 0; + m_dragging = false; +} + +KisToolPerspectiveGrid::~KisToolPerspectiveGrid() +{ +} + +void KisToolPerspectiveGrid::activate() +{ + m_subject->perspectiveGridManager()->startEdition(); + if( ! m_subject->currentImg()->perspectiveGrid()->hasSubGrids() ) + { + m_mode = MODE_CREATION; + m_points.clear(); + } else { + m_mode = MODE_EDITING; + drawGrid(); + } + super::activate(); +} + +void KisToolPerspectiveGrid::deactivate() +{ + m_subject->perspectiveGridManager()->stopEdition(); + m_subject->perspectiveGridManager()->setGridVisible( true); + if( m_mode == MODE_CREATION ) + { + drawGridCreation(); + m_points.clear(); + m_dragging = false; + } else { + drawGrid(); + } +} + + +void KisToolPerspectiveGrid::update (KisCanvasSubject *subject) +{ + m_subject = subject; + super::update(m_subject); +} + +bool KisToolPerspectiveGrid::mouseNear(const QPoint& mousep, const QPoint point) +{ + return (QRect( (point.x() - m_handleHalfSize), (point.y() - m_handleHalfSize), m_handleSize, m_handleSize).contains(mousep) ); +} + +void KisToolPerspectiveGrid::buttonPress(KisButtonPressEvent *event) +{ + KisPerspectiveGrid* pGrid = m_subject->currentImg()->perspectiveGrid(); + if(!pGrid->hasSubGrids() && m_mode != MODE_CREATION) + { // it's possible that the perspectiv grid was cleared + m_mode = MODE_CREATION; + m_points.clear(); + } + if( m_mode == MODE_CREATION && event->button() == LeftButton) + { + m_dragging = true; + + if (m_points.isEmpty()) + { + m_dragStart = event->pos(); + m_dragEnd = event->pos(); + m_points.append(m_dragStart); + } else { + m_dragStart = m_dragEnd; + m_dragEnd = event->pos(); + drawGridCreation(); + } + } else if(m_mode == MODE_EDITING && event->button() == LeftButton){ + // Look for the handle which was pressed + if (!m_subject) + return; + KisCanvasController *controller = m_subject->canvasController(); + Q_ASSERT(controller); + QPoint mousep = controller->windowToView( event->pos().roundQPoint() ); + + for( QValueList<KisSubPerspectiveGrid*>::const_iterator it = pGrid->begin(); it != pGrid->end(); ++it) + { + KisSubPerspectiveGrid* grid = *it; + if( mouseNear( mousep, controller->windowToView(grid->topLeft()->roundQPoint() ) ) ) + { + kdDebug() << " PRESS TOPLEFT HANDLE " << endl; + m_mode = MODE_DRAGING_NODE; + m_selectedNode1 = grid->topLeft(); + break; + } + else if( mouseNear( mousep, controller->windowToView(grid->topRight()->roundQPoint() ) ) ) + { + kdDebug() << " PRESS TOPRIGHT HANDLE " << endl; + m_mode = MODE_DRAGING_NODE; + m_selectedNode1 = grid->topRight(); + break; + } + else if( mouseNear( mousep, controller->windowToView(grid->bottomLeft()->roundQPoint() ) ) ) + { + kdDebug() << " PRESS BOTTOMLEFT HANDLE " << endl; + m_mode = MODE_DRAGING_NODE; + m_selectedNode1 = grid->bottomLeft(); + break; + } + else if( mouseNear( mousep, controller->windowToView(grid->bottomRight()->roundQPoint() ) ) ) + { + kdDebug() << " PRESS BOTTOMRIGHT HANDLE " << endl; + m_mode = MODE_DRAGING_NODE; + m_selectedNode1 = grid->bottomRight(); + break; + } + else if( !grid->leftGrid() && mouseNear( mousep, controller->windowToView( ((*grid->topLeft() + *grid->bottomLeft() )*0.5) ).roundQPoint() ) ) + { + kdDebug() << " PRESS LEFT HANDLE " << endl; + m_mode = MODE_DRAGING_TRANSLATING_TWONODES; + drawGrid(); + m_selectedNode1 = new KisPerspectiveGridNode( *grid->topLeft() ); + m_selectedNode2 = new KisPerspectiveGridNode( *grid->bottomLeft() ); + KisSubPerspectiveGrid* newsubgrid = new KisSubPerspectiveGrid( m_selectedNode1, grid->topLeft() , grid->bottomLeft(), m_selectedNode2); + m_dragEnd = event->pos(); + newsubgrid->setRightGrid( grid); + grid->setLeftGrid( newsubgrid); + pGrid->addNewSubGrid( newsubgrid); + drawGrid(); + break; + } + else if( !grid->rightGrid() && mouseNear( mousep, controller->windowToView( ((*grid->topRight() + *grid->bottomRight() )*0.5) ).roundQPoint() ) ) + { + kdDebug() << " PRESS RIGHT HANDLE " << endl; + m_mode = MODE_DRAGING_TRANSLATING_TWONODES; + drawGrid(); + m_selectedNode1 = new KisPerspectiveGridNode( *grid->topRight() ); + m_selectedNode2 = new KisPerspectiveGridNode( *grid->bottomRight() ); + KisSubPerspectiveGrid* newsubgrid = new KisSubPerspectiveGrid( grid->topRight(), m_selectedNode1, m_selectedNode2, grid->bottomRight()); + m_dragEnd = event->pos(); + newsubgrid->setLeftGrid( grid); + grid->setRightGrid( newsubgrid); + pGrid->addNewSubGrid( newsubgrid); + drawGrid(); + break; + } + else if( !grid->topGrid() && mouseNear( mousep, controller->windowToView( ((*grid->topLeft() + *grid->topRight() )*0.5) ).roundQPoint() ) ) + { + kdDebug() << " PRESS TOP HANDLE " << endl; + m_mode = MODE_DRAGING_TRANSLATING_TWONODES; + drawGrid(); + m_selectedNode1 = new KisPerspectiveGridNode( *grid->topLeft() ); + m_selectedNode2 = new KisPerspectiveGridNode( *grid->topRight() ); + KisSubPerspectiveGrid* newsubgrid = new KisSubPerspectiveGrid( m_selectedNode1, m_selectedNode2, grid->topRight(), grid->topLeft() ); + m_dragEnd = event->pos(); + newsubgrid->setBottomGrid( grid); + grid->setTopGrid( newsubgrid); + pGrid->addNewSubGrid( newsubgrid); + drawGrid(); + break; + } + else if( !grid->bottomGrid() && mouseNear( mousep, controller->windowToView( ((*grid->bottomLeft() + *grid->bottomRight() )*0.5) ).roundQPoint() ) ) + { + kdDebug() << " PRESS BOTTOM HANDLE " << endl; + m_mode = MODE_DRAGING_TRANSLATING_TWONODES; + drawGrid(); + m_selectedNode1 = new KisPerspectiveGridNode( *grid->bottomLeft() ); + m_selectedNode2 = new KisPerspectiveGridNode( *grid->bottomRight() ); + KisSubPerspectiveGrid* newsubgrid = new KisSubPerspectiveGrid( grid->bottomLeft(), grid->bottomRight(), m_selectedNode2, m_selectedNode1); + m_dragEnd = event->pos(); + newsubgrid->setTopGrid( grid); + grid->setBottomGrid( newsubgrid); + pGrid->addNewSubGrid( newsubgrid); + drawGrid(); + break; + } + } + } +} + + +void KisToolPerspectiveGrid::move(KisMoveEvent *event) +{ + if( m_mode == MODE_CREATION ) + { + if (m_dragging) { + // erase old lines on canvas + drawGridCreation(); + // get current mouse position + m_dragEnd = event->pos(); + // draw new lines on canvas + drawGridCreation(); + } + } else { + if( m_mode == MODE_DRAGING_NODE) + { + drawGrid(); + m_selectedNode1->setX( event->pos().x() ); + m_selectedNode1->setY( event->pos().y() ); + drawGrid(); + } + if( m_mode == MODE_DRAGING_TRANSLATING_TWONODES) + { + drawGrid(); + KisPoint translate = event->pos() - m_dragEnd; + m_dragEnd = event->pos(); + *m_selectedNode1 += translate;; + *m_selectedNode2 += translate;; + drawGrid(); + } + } +} + +void KisToolPerspectiveGrid::buttonRelease(KisButtonReleaseEvent *event) +{ + if (!m_subject) + return; + + if( m_mode == MODE_CREATION ) + { + if (m_dragging && event->button() == LeftButton) { + m_dragging = false; + m_points.append (m_dragEnd); + if( m_points.size() == 4) + { // wow we have a grid, isn't that cool ? + drawGridCreation(); // Clean + m_subject->currentImg()->perspectiveGrid()->addNewSubGrid( new KisSubPerspectiveGrid( new KisPerspectiveGridNode(m_points[0]), new KisPerspectiveGridNode(m_points[1]), new KisPerspectiveGridNode(m_points[2]), new KisPerspectiveGridNode(m_points[3]) ) ); + drawGrid(); + m_mode = MODE_EDITING; + } + } + } else { + m_mode = MODE_EDITING; + m_selectedNode1 = 0; + m_selectedNode2 = 0; + } + +/* if (m_dragging && event->button() == RightButton) { + + }*/ +} + +void KisToolPerspectiveGrid::paint(KisCanvasPainter& gc) +{ + if( m_mode == MODE_CREATION ) + { + drawGridCreation(gc); + } else { + drawGrid(gc); + } +} + +void KisToolPerspectiveGrid::paint(KisCanvasPainter& gc, const QRect&) +{ + if( m_mode == MODE_CREATION ) + { + drawGridCreation(gc); + } else { + drawGrid(gc); + } +} + +void KisToolPerspectiveGrid::drawGridCreation() +{ + if (m_subject) { + KisCanvasController *controller = m_subject->canvasController(); + KisCanvas *canvas = controller->kiscanvas(); + KisCanvasPainter gc(canvas); + + drawGridCreation(gc); + } +} + + +void KisToolPerspectiveGrid::drawGridCreation(KisCanvasPainter& gc) +{ + if (!m_subject) + return; + + QPen pen(Qt::white); + + gc.setPen(pen); + gc.setRasterOp(Qt::XorROP); + + KisCanvasController *controller = m_subject->canvasController(); + KisPoint start, end; + QPoint startPos; + QPoint endPos; + + if (m_dragging) { + startPos = controller->windowToView(m_dragStart.floorQPoint()); + endPos = controller->windowToView(m_dragEnd.floorQPoint()); + gc.drawLine(startPos, endPos); + } else { + for (KisPointVector::iterator it = m_points.begin(); it != m_points.end(); ++it) { + + if (it == m_points.begin()) + { + start = (*it); + } else { + end = (*it); + + startPos = controller->windowToView(start.floorQPoint()); + endPos = controller->windowToView(end.floorQPoint()); + + gc.drawLine(startPos, endPos); + + start = end; + } + } + } +} + +void KisToolPerspectiveGrid::drawSmallRectangle(KisCanvasPainter& gc, QPoint p) +{ + gc.drawRect( p.x() - m_handleHalfSize - 1, p.y() - m_handleHalfSize - 1, m_handleSize, m_handleSize); +} + +void KisToolPerspectiveGrid::drawGrid(KisCanvasPainter& gc) +{ + + if (!m_subject) + return; + + KisCanvasController *controller = m_subject->canvasController(); + + QPen pen(Qt::white); + QPoint startPos; + QPoint endPos; + + gc.setPen(pen); + gc.setRasterOp(Qt::XorROP); + KisPerspectiveGrid* pGrid = m_subject->currentImg()->perspectiveGrid(); + + for( QValueList<KisSubPerspectiveGrid*>::const_iterator it = pGrid->begin(); it != pGrid->end(); ++it) + { + KisSubPerspectiveGrid* grid = *it; + int index = grid->index(); + bool drawLeft = !(grid->leftGrid() && (index > grid->leftGrid()->index() ) ); + bool drawRight = !(grid->rightGrid() && (index > grid->rightGrid()->index() ) ); + bool drawTop = !(grid->topGrid() && (index > grid->topGrid()->index() ) ); + bool drawBottom = !(grid->bottomGrid() && (index > grid->bottomGrid()->index() ) ); + if(drawTop) { + startPos = controller->windowToView(grid->topLeft()->roundQPoint()); + endPos = controller->windowToView(grid->topRight()->roundQPoint()); + gc.drawLine( startPos, endPos ); + if( !grid->topGrid() ) + { + drawSmallRectangle(gc, (endPos + startPos) / 2); + } + if(drawLeft) { + drawSmallRectangle(gc, startPos); + } + if(drawRight) { + drawSmallRectangle(gc, endPos); + } + } + if(drawRight) { + startPos = controller->windowToView(grid->topRight()->roundQPoint()); + endPos = controller->windowToView(grid->bottomRight()->roundQPoint()); + gc.drawLine( startPos, endPos ); + if( !grid->rightGrid() ) + { + drawSmallRectangle(gc, (endPos + startPos) / 2); + } + } + if(drawBottom) { + startPos = controller->windowToView(grid->bottomRight()->roundQPoint()); + endPos = controller->windowToView(grid->bottomLeft()->roundQPoint()); + gc.drawLine( startPos, endPos ); + if( !grid->bottomGrid() ) + { + drawSmallRectangle(gc, (endPos + startPos) / 2); + } + if(drawLeft) { + drawSmallRectangle(gc, endPos); + } + if(drawRight) { + drawSmallRectangle(gc, startPos); + } + } + if(drawLeft) { + startPos = controller->windowToView(grid->bottomLeft()->roundQPoint()); + endPos = controller->windowToView(grid->topLeft()->roundQPoint()); + gc.drawLine( startPos, endPos ); + if( !grid->leftGrid() ) + { + drawSmallRectangle(gc, (endPos + startPos) / 2); + } + } + KisPoint tbVpf = grid->topBottomVanishingPoint(); + if( fabs(tbVpf.x()) < 30000000. && fabs(tbVpf.y()) < 30000000.) + { + QPoint tbVp = controller->windowToView(tbVpf.roundQPoint()); + gc.drawLine( tbVp.x() - m_handleHalfSize, tbVp.y() - m_handleHalfSize, tbVp.x() + m_handleHalfSize, tbVp.y() + m_handleHalfSize); + gc.drawLine( tbVp.x() - m_handleHalfSize, tbVp.y() + m_handleHalfSize, tbVp.x() + m_handleHalfSize, tbVp.y() - m_handleHalfSize); + } + KisPoint lrVpf = grid->leftRightVanishingPoint(); + if( fabs(lrVpf.x()) < 30000000. && fabs(lrVpf.y()) < 30000000.) + { // Don't display it, if it is too far, or you get funny results + QPoint lrVp = controller->windowToView(lrVpf.roundQPoint()); + gc.drawLine( lrVp.x() - m_handleHalfSize, lrVp.y() - m_handleHalfSize, lrVp.x() + m_handleHalfSize, lrVp.y() + m_handleHalfSize); + gc.drawLine( lrVp.x() - m_handleHalfSize, lrVp.y() + m_handleHalfSize, lrVp.x() + m_handleHalfSize, lrVp.y() - m_handleHalfSize); + } + } +} + +void KisToolPerspectiveGrid::drawGrid() +{ + if (m_subject) { + KisCanvasController *controller = m_subject->canvasController(); + KisCanvas *canvas = controller->kiscanvas(); + KisCanvasPainter gc(canvas); + + drawGrid(gc); + } + +} + + +void KisToolPerspectiveGrid::setup(KActionCollection *collection) +{ + m_action = static_cast<KRadioAction *>(collection->action(name())); + + if (m_action == 0) { + m_action = new KRadioAction(i18n("&Perspective Grid"), + "tool_perspectivegrid" , + 0, + this, + SLOT(activate()), + collection, + name()); + Q_CHECK_PTR(m_action); + m_action->setExclusiveGroup("tools"); + m_action->setToolTip(i18n("Edit the perspective grid")); + m_ownAction = true; + } +} + + +// QWidget* KisToolPerspectiveGrid::createOptionWidget(QWidget* parent) +// { +// return 0; +// } +// +// QWidget* KisToolPerspectiveGrid::optionWidget() +// { +// return 0; +// } + + +#include "kis_tool_perspectivegrid.moc" diff --git a/krita/plugins/tools/tool_perspectivegrid/kis_tool_perspectivegrid.h b/krita/plugins/tools/tool_perspectivegrid/kis_tool_perspectivegrid.h new file mode 100644 index 00000000..b6318c7d --- /dev/null +++ b/krita/plugins/tools/tool_perspectivegrid/kis_tool_perspectivegrid.h @@ -0,0 +1,110 @@ +/* + * kis_tool_perspectivegrid.h - part of Krita + * + * Copyright (c) 2006 Cyrille Berger <cberger@cberger.net> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef _KIS_TOOL_PERSPECTIVE_GRID_H_ +#define _KIS_TOOL_PERSPECTIVE_GRID_H_ + +#include <kis_perspective_grid.h> +#include <kis_point.h> +#include <kis_tool_non_paint.h> +#include <kis_tool_factory.h> + +class KisToolPerspectiveGrid : public KisToolNonPaint { + Q_OBJECT + enum PerspectiveGridEditionMode { + MODE_CREATION, // This is the mode when there is not yet a perspective grid + MODE_EDITING, // This is the mode when the grid has been created, and we are waiting for the user to click on a control box + MODE_DRAGING_NODE, // In this mode one node is translated + MODE_DRAGING_TRANSLATING_TWONODES // This mode is used when creating a new sub perspective grid + }; + typedef KisToolNonPaint super; +public: + KisToolPerspectiveGrid(); + virtual ~KisToolPerspectiveGrid(); + // + // KisCanvasObserver interface + // + + virtual void update (KisCanvasSubject *subject); + + // + // KisToolPaint interface + // + + virtual void setup(KActionCollection *collection); + virtual Q_UINT32 priority() { return 3; } + virtual enumToolType toolType() { return TOOL_VIEW; } + virtual void buttonPress(KisButtonPressEvent *event); + virtual void move(KisMoveEvent *event); + virtual void buttonRelease(KisButtonReleaseEvent *event); + +// QWidget* createOptionWidget(QWidget* parent); +// virtual QWidget* optionWidget(); + +public slots: + virtual void activate(); + void deactivate(); + +protected: + virtual void paint(KisCanvasPainter& gc); + virtual void paint(KisCanvasPainter& gc, const QRect& rc); + void drawGridCreation(KisCanvasPainter& gc); + void drawGridCreation(); + void drawGrid(KisCanvasPainter& gc); + void drawGrid(); + +private: + void drawSmallRectangle(KisCanvasPainter& gc, QPoint p); + bool mouseNear(const QPoint& mousep, const QPoint point); + +protected: + KisPoint m_dragStart; + KisPoint m_dragEnd; + + bool m_dragging; +private: + typedef QValueVector<KisPoint> KisPointVector; + KisCanvasSubject *m_subject; + KisPointVector m_points; + PerspectiveGridEditionMode m_mode; + Q_INT32 m_handleSize, m_handleHalfSize; + KisPerspectiveGridNodeSP m_selectedNode1, m_selectedNode2; + +}; + + +class KisToolPerspectiveGridFactory : public KisToolFactory { + typedef KisToolFactory super; +public: + KisToolPerspectiveGridFactory() : super() {}; + virtual ~KisToolPerspectiveGridFactory(){}; + + virtual KisTool * createTool(KActionCollection * ac) { + KisTool * t = new KisToolPerspectiveGrid(); + Q_CHECK_PTR(t); + t->setup(ac); + return t; + } + virtual KisID id() { return KisID("perspectivegridtool", i18n("Perspective Grid Tool")); } +}; + + +#endif + diff --git a/krita/plugins/tools/tool_perspectivegrid/kritatoolperspectivegrid.desktop b/krita/plugins/tools/tool_perspectivegrid/kritatoolperspectivegrid.desktop new file mode 100644 index 00000000..ec9c0dea --- /dev/null +++ b/krita/plugins/tools/tool_perspectivegrid/kritatoolperspectivegrid.desktop @@ -0,0 +1,35 @@ +[Desktop Entry] +Name=Perspective Grid Tool +Name[bg]=Инструмент мрежа +Name[ca]=Eina de graella de perspectiva +Name[da]=Perspektivgitterværktøj +Name[de]=Perspektive-Raster-Werkzeug +Name[el]=Εργαλείο προοπτικού πλέγματος +Name[eo]=Perspektivkrado-ilo +Name[es]=Herramienta Cuadrícula de perspectiva +Name[et]=Perspektiivvõrgu tööriist +Name[fa]=ابزار توری بُعدنما +Name[fy]=Perspeksjeraster-ark +Name[hu]=Perspektívarács +Name[it]=Strumento di reticolo prospettico +Name[ja]=遠近法グリッドツール +Name[km]=ឧបករណ៍ក្រឡាចត្រង្គយថាទស្សន៍ +Name[nb]=Perspektivnett-verktøy +Name[nds]=Kiekwinkelgadder-Warktüüch +Name[ne]=दृश्यात्मक ग्रीड उपकरण +Name[nl]=Perspectiefraster-gereedschap +Name[pl]=Narzędzie siatki perspektywy +Name[pt]=Ferramenta de Grelha em Perspectiva +Name[pt_BR]=Ferramenta de Grade em Perspectiva +Name[ru]=Перспектива +Name[sk]=Perspektívna mriežka +Name[sl]=Orodja Mreža za perspektivo +Name[sr]=Алат за мрежу у перспективи +Name[sr@Latn]=Alat za mrežu u perspektivi +Name[sv]=Perspektivrutnätsverktyg +Name[uk]=Засіб ґратки перспективи +Name[zh_TW]=透視格工具 +ServiceTypes=Krita/Tool +Type=Service +X-KDE-Library=kritatoolperspectivegrid +X-Krita-Version=2 diff --git a/krita/plugins/tools/tool_perspectivegrid/tool_perspectivegrid.cc b/krita/plugins/tools/tool_perspectivegrid/tool_perspectivegrid.cc new file mode 100644 index 00000000..157a7457 --- /dev/null +++ b/krita/plugins/tools/tool_perspectivegrid/tool_perspectivegrid.cc @@ -0,0 +1,62 @@ +/* + * tool_perspectivegrid.cc -- Part of Krita + * + * Copyright (c) 2006 Cyrille Berger <cberger@cberger.net> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#include <stdlib.h> +#include <vector> + +#include <qpoint.h> + +#include <klocale.h> +#include <kiconloader.h> +#include <kinstance.h> +#include <kmessagebox.h> +#include <kstandarddirs.h> +#include <kdebug.h> +#include <kgenericfactory.h> + +#include <kis_global.h> +#include <kis_types.h> +#include <kis_tool_registry.h> + +#include "tool_perspectivegrid.h" +#include "kis_tool_perspectivegrid.h" + + +typedef KGenericFactory<ToolPerspectiveGrid> ToolPerspectiveGridFactory; +K_EXPORT_COMPONENT_FACTORY( kritatoolperspectivegrid, ToolPerspectiveGridFactory( "krita" ) ) + + +ToolPerspectiveGrid::ToolPerspectiveGrid(QObject *parent, const char *name, const QStringList &) + : KParts::Plugin(parent, name) +{ + setInstance(ToolPerspectiveGridFactory::instance()); + + if ( parent->inherits("KisToolRegistry") ) + { + KisToolRegistry * r = dynamic_cast<KisToolRegistry*>(parent); + r->add(new KisToolPerspectiveGridFactory()); + } + +} + +ToolPerspectiveGrid::~ToolPerspectiveGrid() +{ +} + +#include "tool_perspectivegrid.moc" diff --git a/krita/plugins/tools/tool_perspectivegrid/tool_perspectivegrid.h b/krita/plugins/tools/tool_perspectivegrid/tool_perspectivegrid.h new file mode 100644 index 00000000..e98cbf09 --- /dev/null +++ b/krita/plugins/tools/tool_perspectivegrid/tool_perspectivegrid.h @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2006 Cyrille Berger <cberger@cberger.net> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef TOOL_PERSPECTIVE_GRID_H_ +#define TOOL_PERSPECTIVE_GRID_H_ + +#include <kparts/plugin.h> + +class KisView; + +/** + * A module that provides a tool for editing the perspective grid. + */ +class ToolPerspectiveGrid : public KParts::Plugin +{ + Q_OBJECT +public: + ToolPerspectiveGrid(QObject *parent, const char *name, const QStringList &); + virtual ~ToolPerspectiveGrid(); + +private: + + KisView * m_view; + +}; + +#endif // TOOL_PERSPECTIVE_GRID_H_ diff --git a/krita/plugins/tools/tool_perspectivegrid/tool_perspectivegrid.png b/krita/plugins/tools/tool_perspectivegrid/tool_perspectivegrid.png Binary files differnew file mode 100644 index 00000000..3948131d --- /dev/null +++ b/krita/plugins/tools/tool_perspectivegrid/tool_perspectivegrid.png diff --git a/krita/plugins/tools/tool_perspectivegrid/tool_perspectivegrid.svg b/krita/plugins/tools/tool_perspectivegrid/tool_perspectivegrid.svg new file mode 100644 index 00000000..24405305 --- /dev/null +++ b/krita/plugins/tools/tool_perspectivegrid/tool_perspectivegrid.svg @@ -0,0 +1,87 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://web.resource.org/cc/" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://inkscape.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="22" + height="22" + id="svg2" + sodipodi:version="0.32" + inkscape:version="0.43" + version="1.0" + sodipodi:docbase="/home/cyrille/koffice-1.6/krita/plugins/tools/tool_perspectivegrid" + sodipodi:docname="tool_perspectivegrid.svg" + inkscape:export-filename="/home/cyrille/koffice-1.6/krita/plugins/tools/tool_perspectivegrid/tool_perspectivegrid.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90"> + <defs + id="defs4" /> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="9.8597476" + inkscape:cx="12.855376" + inkscape:cy="7.6671075" + inkscape:document-units="px" + inkscape:current-layer="layer1" + inkscape:window-width="749" + inkscape:window-height="540" + inkscape:window-x="424" + inkscape:window-y="433" /> + <metadata + id="metadata7"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1"> + <path + style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#909090;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 4.8682788,20.580085 C 6.5924609,1.3098151 6.7953058,1.5126601 6.7953058,1.5126601 L 6.7953058,1.5126601 L 6.7953058,1.5126601" + id="path2183" /> + <path + style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#909090;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 11.359317,18.551636 C 10.446515,2.3240399 10.446515,2.3240399 10.446515,2.3240399 L 10.446515,2.3240399 L 10.446515,2.3240399" + id="path2185" /> + <path + style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#909090;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 17.444666,17.131721 C 13.894879,3.1354197 13.894879,3.1354197 13.894879,3.1354197" + id="path2187" /> + <path + style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#909090;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 2.7384068,4.7581793 C 17.647511,6.5837838 17.546088,6.5837838 17.546088,6.5837838" + id="path2191" /> + <path + style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#909090;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 2.0284495,10.742105 C 18.256045,9.7278805 18.86458,9.1193456 18.86458,9.1193456" + id="path2193" + sodipodi:nodetypes="cc" /> + <path + style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#909090;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 1.0142247,17.131721 C 20.08165,12.56771 20.08165,12.364865 20.08165,12.364865" + id="path2195" + sodipodi:nodetypes="cc" /> + <path + style="fill:none;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="M 3.1440967,0.59985768 L 16.531864,3.6425319 L 21.70441,15.813228 L 0.50711235,21.594309 L 3.1440967,0.59985768 z " + id="rect1307" + sodipodi:nodetypes="ccccc" /> + </g> +</svg> |