[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    koffice/krita
From:       Sven Langkamp <sven.langkamp () gmail ! com>
Date:       2010-10-30 21:23:30
Message-ID: 20101030212330.175B6AC89B () svn ! kde ! org
[Download RAW message or body]

SVN commit 1191384 by langkamp:

fix scale for masks
BUG:251482


 M  +13 -0     image/kis_selection_component.h  
 M  +40 -5     image/kis_transform_visitor.h  
 M  +37 -2     ui/flake/kis_shape_selection.cpp  
 M  +5 -0      ui/flake/kis_shape_selection.h  


--- trunk/koffice/krita/image/kis_selection_component.h #1191383:1191384
@@ -21,6 +21,7 @@
 #include <krita_export.h>
 
 class QRect;
+class QUndoCommand;
 class KisSelection;
 
 class KRITAIMAGE_EXPORT KisSelectionComponent
@@ -36,6 +37,18 @@
 
     virtual void moveX(qint32 x) { Q_UNUSED(x); }
     virtual void moveY(qint32 y) { Q_UNUSED(y); }
+    
+    virtual QUndoCommand* transform(double  xscale, double  yscale, double  xshear, double  yshear, \
double angle, qint32  translatex, qint32  translatey) +    {
+        Q_UNUSED(xscale);
+        Q_UNUSED(yscale);
+        Q_UNUSED(xshear);
+        Q_UNUSED(yshear);
+        Q_UNUSED(angle);
+        Q_UNUSED(translatex);
+        Q_UNUSED(translatey);
+        return 0;
+    }
 };
 
 #endif
--- trunk/koffice/krita/image/kis_transform_visitor.h #1191383:1191384
@@ -35,6 +35,12 @@
 #include "kis_image.h"
 #include "kis_paint_device.h"
 #include "generator/kis_generator_layer.h"
+#include "kis_pixel_selection.h"
+#include "kis_transparency_mask.h"
+#include "kis_selection_mask.h"
+#include "kis_transformation_mask.h"
+#include "kis_clone_layer.h"
+#include "kis_filter_mask.h"
 
 class KoUpdater;
 class KisFilterStrategy;
@@ -69,6 +75,7 @@
         QUndoCommand* command = layer->transform(m_sx, m_sy, 0.0, 0.0, m_angle, m_tx, m_ty);
         if (command)
             undoAdapter->addCommand(command);
+        visitAll(layer);
         return true;
     }
 
@@ -78,6 +85,7 @@
      */
     bool visit(KisPaintLayer *layer) {
         transformPaintDevice(layer);
+        visitAll(layer);
         return true;
     }
 
@@ -96,30 +104,37 @@
     virtual bool visit(KisAdjustmentLayer* layer) {
         transformPaintDevice(layer);
         layer->resetCache();
+        visitAll(layer);
         return true;
     }
 
     bool visit(KisGeneratorLayer* layer) {
         transformPaintDevice(layer);
+        visitAll(layer);
         return true;
     }
 
     bool visit(KisNode*) {
         return true;
     }
-    bool visit(KisCloneLayer*) {
+    bool visit(KisCloneLayer* layer) {
+        visitAll(layer);
         return true;
     }
-    bool visit(KisFilterMask*) {
+    bool visit(KisFilterMask* mask) {
+        transformMask(mask);
         return true;
     }
-    bool visit(KisTransparencyMask*) {
+    bool visit(KisTransparencyMask* mask) {
+        transformMask(mask);
         return true;
     }
-    bool visit(KisTransformationMask*) {
+    bool visit(KisTransformationMask* mask) {
+        transformMask(mask);
         return true;
     }
-    bool visit(KisSelectionMask*) {
+    bool visit(KisSelectionMask* mask) {
+        transformMask(mask);
         return true;
     }
 
@@ -138,6 +153,26 @@
         node->setDirty();
     }
 
+    void transformMask(KisMask* mask) {
+        KisSelectionSP selection = mask->selection();
+        if(selection->hasPixelSelection()) {
+            KisSelectionTransaction transaction(QString(), m_image, selection);
+
+            KisPaintDeviceSP dev = selection->getOrCreatePixelSelection().data();
+            KisTransformWorker tw(dev, m_sx, m_sy, 0.0, 0.0, 0.0, 0.0, m_angle, m_tx, m_ty, m_progress, \
m_filter, true); +            tw.run();
+
+            transaction.commit(m_image->undoAdapter());
+        }
+        if (selection->hasShapeSelection()) {
+            QUndoCommand* command = selection->shapeSelection()->transform(m_sx, m_sy, 0.0, 0.0, \
m_angle, m_tx, m_ty); +            if (command)
+                m_image->undoAdapter()->addCommand(command);
+        }
+        
+        selection->updateProjection();
+    }
+
 private:
     qreal m_sx, m_sy;
     qint32 m_tx, m_ty;
--- trunk/koffice/krita/ui/flake/kis_shape_selection.cpp #1191383:1191384
@@ -1,5 +1,5 @@
 /*
- *  Copyright (c) 2007 Sven Langkamp <sven.langkamp@gmail.com>
+ *  Copyright (c) 2010 Sven Langkamp <sven.langkamp@gmail.com>
  *
  *  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
@@ -21,6 +21,7 @@
 
 #include <QPainter>
 #include <QTimer>
+#include <QUndoCommand>
 
 #include <ktemporaryfile.h>
 
@@ -44,8 +45,8 @@
 #include <KoShapeController.h>
 #include <KoShapeSavingContext.h>
 #include <KoStoreDevice.h>
+#include <KoShapeTransformCommand.h>
 
-
 #include "kis_painter.h"
 #include "kis_paint_device.h"
 #include "kis_shape_selection_model.h"
@@ -53,6 +54,7 @@
 #include "kis_selection.h"
 #include "kis_shape_selection_canvas.h"
 #include "kis_shape_layer_paste.h"
+#include "kis_image_view_converter.h"
 
 #include <kis_debug.h>
 
@@ -64,6 +66,7 @@
     setShapeId("KisShapeSelection");
     setSelectable(false);
     m_dirty = false;
+    m_converter = new KisImageViewConverter(image);
     m_canvas = new KisShapeSelectionCanvas();
     m_canvas->shapeManager()->addShape(this);
 
@@ -73,6 +76,7 @@
 {
     m_model->setShapeSelection(0);
     delete m_canvas;
+    delete m_converter;
 }
 
 KisShapeSelection::KisShapeSelection(const KisShapeSelection& rhs, KisSelection* selection)
@@ -399,5 +403,36 @@
     }
 }
 
+// TODO same code as in shape layer, refactor!
+QUndoCommand* KisShapeSelection::transform(double  xscale, double  yscale, double  xshear, double  \
yshear, double angle, qint32  translatex, qint32  translatey) {  
+    Q_UNUSED(xshear);
+    Q_UNUSED(yshear);
+    QPointF transF =  m_converter->viewToDocument(QPoint(translatex, translatey));
+    QList<KoShape*> shapes = m_canvas->shapeManager()->shapes();
+    if(shapes.isEmpty())
+        return 0;
+
+    QTransform matrix;
+    matrix.translate(transF.x(), transF.y());
+    matrix.scale(xscale,yscale);
+    matrix.rotate(angle*180/M_PI);
+
+    QList<QTransform> oldTransformations;
+    QList<QTransform> newTransformations;
+
+    // this code won't work if there are shapes, that inherit the transformation from the parent \
container. +    // the chart and tree shapes are examples for that, but they aren't used in krita and \
there are no other shapes like that. +    foreach(const KoShape* shape, shapes) {
+        QTransform oldTransform = shape->transformation();
+        oldTransformations.append(oldTransform);
+
+
+        newTransformations.append(oldTransform*matrix);
+    }
+
+    return new KoShapeTransformCommand(shapes, oldTransformations, newTransformations);
+}
+
+
 #include "kis_shape_selection.moc"
--- trunk/koffice/krita/ui/flake/kis_shape_selection.h #1191383:1191384
@@ -30,6 +30,8 @@
 class KoStore;
 class KisShapeSelectionCanvas;
 class KisShapeSelectionModel;
+class KisImageViewConverter;
+class QUndoCommand;
 
 /**
  * The marker class.
@@ -75,7 +77,9 @@
     void moveX(qint32 x);
     void moveY(qint32 y);
 
+    QUndoCommand* transform(double  xscale, double  yscale, double  xshear, double  yshear, double \
angle, qint32  translatex, qint32  translatey);  
+
 protected:
 
     virtual void paintComponent(QPainter& painter, const KoViewConverter& converter);
@@ -87,6 +91,7 @@
     KisImageWSP m_image;
     QPainterPath m_outline;
     bool m_dirty;
+    KisImageViewConverter* m_converter;
     KisShapeSelectionCanvas* m_canvas;
     KisShapeSelectionModel* m_model;
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic