krita
kis_shear_visitor.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef KIS_SHEAR_VISITOR_H_
00020 #define KIS_SHEAR_VISITOR_H_
00021
00022 #include "kis_types.h"
00023 #include "kis_progress_subject.h"
00024 #include "kis_layer_visitor.h"
00025 #include "kis_transform_worker.h"
00026 #include "kis_filter_strategy.h"
00027 #include "kis_undo_adapter.h"
00028 #include "kis_transaction.h"
00029 #include "kis_rotate_visitor.h"
00030
00031 class KisShearVisitor : public KisLayerVisitor {
00032 public:
00033 KisShearVisitor(double xshear, double yshear, KisProgressDisplayInterface *progress)
00034 : m_xshear(xshear), m_yshear(yshear), m_progress(progress), m_strategy(0), m_undo(0) {};
00035
00036 void setStrategy(KisFilterStrategy* strategy) { m_strategy = strategy; }
00037 void setUndoAdapter(KisUndoAdapter* undo) { m_undo = undo; }
00038 public:
00039 virtual bool visit(KisPaintLayer* layer) {
00040 KisPaintDeviceSP dev = layer->paintDevice();
00041 if(!dev)
00042 return true;
00043
00044 KisFilterStrategy* strategy = 0;
00045 if (m_strategy)
00046 strategy = m_strategy;
00047 else
00048 strategy = new KisMitchellFilterStrategy;
00049
00050 KisTransaction* t = 0;
00051
00052 if (m_undo && m_undo->undo())
00053 t = new KisTransaction("", dev.data());
00054
00055
00056
00057
00058
00059 KisRotateVisitor v;
00060 v.visitKisPaintDevice(dev);
00061 v.shear(m_xshear, m_yshear, m_progress);
00062
00063 if (m_undo && m_undo->undo())
00064 m_undo->addCommand(t);
00065
00066 if (!m_strategy)
00067 delete strategy;
00068
00069 layer->setDirty();
00070
00071 return true;
00072 }
00073
00074 virtual bool visit(KisGroupLayer* layer) {
00075 KisLayerSP child = layer->firstChild();
00076
00077 while(child)
00078 {
00079 child->accept(*this);
00080 child = child->nextSibling();
00081 }
00082 return true;
00083 }
00084
00085 virtual bool visit(KisPartLayer*) { return true; }
00086 virtual bool visit(KisAdjustmentLayer *) { return true; }
00087 private:
00088 double m_xshear;
00089 double m_yshear;
00090 KisProgressDisplayInterface* m_progress;
00091 KisFilterStrategy* m_strategy;
00092 KisUndoAdapter* m_undo;
00093 };
00094
00095 #endif // KIS_SHEAR_VISITOR_H_
|