Any idea what is wrong here?

Michael Thaler michael.thaler at physik.tu-muenchen.de
Wed Oct 19 21:31:04 CEST 2005


Hello,

I still try to rework the crop tool and got another error. Maybe someone can 
help me with this.

I split KisToolCrop in two classes, KisToolCrop and KisCropSelection. The 
header-files are:

#ifndef KIS_CROP_SELECTION_H_
#define KIS_CROP_SELECTION_H_

#include <qregion.h>
#include <qrect.h>

class KisCanvasSubject;

class KisCropSelection
{
    public:
        KisCropSelection();
        virtual ~KisCropSelection();
        void resize(QPoint topLeft, QPoint bottomRight);
        Q_INT32 mouseOnHandle (const QPoint currentViewPoint);
        QRegion handles();
        inline Q_INT32 left() { return m_cropSelection.left(); }
        inline Q_INT32 top() { return m_cropSelection.top(); }
        inline Q_INT32 right() { return m_cropSelection.right(); }
        inline Q_INT32 bottom() { return m_cropSelection.bottom(); }
        inline Q_INT32 width() { return m_cropSelection.width(); }
        inline Q_INT32 height() { return m_cropSelection.height(); }
    private:
        enum handleType
        {
            None = 0,
            Left = 1,
            TopLeft = 2,
            Top = 3,
            TopRight = 4,
            Right = 5,
            BottomRight = 6,
            Bottom = 7,
            BottomLeft = 8,
            InsideSelection = 9
        };
        QRect m_cropSelection;
        QRect m_leftHandle;
        QRect m_topLeftHandle;
        QRect m_topHandle;
        QRect m_topRightHandle;
        QRect m_rightHandle;
        QRect m_bottomRightHandle;
        QRect m_bottomHandle;
        QRect m_bottomLeftHandle;
};

#endif // KIS_CROP_SELECTION_CROP_H_

and

#ifndef KIS_TOOL_CROP_H_
#define KIS_TOOL_CROP_H_

#include <qpoint.h>
#include <qregion.h>
#include <kis_tool_non_paint.h>
#include <kis_tool_factory.h>

#include "kis_crop_selection.h"

class QRect;
class QCursor;
class WdgToolCrop;

/**
 * Crop tool
 *
 * TODO: - crop from selection -- i.e, set crop outline to the exact bounds of 
the selection.
 *       - (when moving to Qt 4: replace rectangle with  darker, dimmer 
overlay layer
 *         like we have for selections right now)
 */
class KisToolCrop : public KisToolNonPaint {

    typedef KisToolNonPaint super;
    Q_OBJECT

public:
    KisToolCrop();
    virtual ~KisToolCrop();

    virtual void update(KisCanvasSubject *subject);

    virtual QWidget* createOptionWidget(QWidget* parent);
    virtual QWidget* optionWidget();

    virtual void setup(KActionCollection *collection);
    virtual enumToolType toolType() { return TOOL_TRANSFORM; }
    virtual Q_UINT32 priority() { return 1; }
    virtual void paint(QPainter& gc);
    virtual void paint(QPainter& gc, const QRect& rc);
    virtual void buttonPress(KisButtonPressEvent *e);
    virtual void move(KisMoveEvent *e);
    virtual void buttonRelease(KisButtonReleaseEvent *e);
    virtual void doubleClick(KisDoubleClickEvent *);

public slots:
    virtual void activate();
private:
    enum handleType
    {
        None = 0,
        Left = 1,
        TopLeft = 2,
        Top = 3,
        TopRight = 4,
        Right = 5,
        BottomRight = 6,
        Bottom = 7,
        BottomLeft = 8,
        InsideSelection = 9
    };
    void clearRect();
    void cropLayer(KisLayerSP layer, QRect rc);
    void paintCropSelection();
    void paintCropSelection(QPainter& gc, const QRect& rc);
    void setCursorType (Q_INT32 handle);
    void validateSelection(void);
    void setOptionWidgetStartX(Q_INT32 x);
    void setOptionWidgetStartY(Q_INT32 y);
    void setOptionWidgetEndX(Q_INT32 x);
    void setOptionWidgetEndY(Q_INT32 y);
        
private slots:

    void crop();
    void setStartX(int x);
    void setStartY(int y);
    void setEndX(int x);
    void setEndY(int y);

private:
    KisCanvasSubject *m_subject;
    QPoint m_startPos;
    QPoint m_endPos;
    bool m_selecting;
    QPoint m_dragStart;
    QPoint m_dragStop;

    WdgToolCrop* m_optWidget;

    Q_INT32 m_handleSize;
    QRegion m_handlesRegion;
    bool m_haveCropSelection;
    Q_INT32 m_dx, m_dy;
    Q_INT32 m_mouseOnHandleType;
    KisCropSelection m_cropSelection;
};

class KisToolCropFactory : public KisToolFactory {
    typedef KisToolFactory super;
public:
    KisToolCropFactory() : super() {};
    virtual ~KisToolCropFactory(){};

    virtual KisTool * createTool(KActionCollection * ac) {
        KisTool * t = new KisToolCrop();
        Q_CHECK_PTR(t);
        t -> setup(ac);
        return t;
    }
    virtual KisID id() { return KisID("crop", i18n("Crop tool")); }
};



#endif // KIS_TOOL_CROP_H_

When I try to compile it, I get:

.libs/kis_tool_crop.o: In function `KisToolCrop':
/usr/local/src/kde/koffice/krita/plugins/tool_crop/kis_tool_crop.cc:55: 
undefined reference to `KisCropSelection::KisCropSelection()'
/usr/local/src/kde/koffice/krita/plugins/tool_crop/kis_tool_crop.cc:55: 
undefined reference to `KisCropSelection::KisCropSelection()'
.libs/kis_tool_crop.o: In function `~KisToolCrop':
/usr/local/src/kde/koffice/krita/plugins/tool_crop/kis_tool_crop.cc:70: 
undefined reference to `KisCropSelection::~KisCropSelection()'
/usr/local/src/kde/koffice/krita/plugins/tool_crop/kis_tool_crop.cc:70: 
undefined reference to `KisCropSelection::~KisCropSelection()'
/usr/local/src/kde/koffice/krita/plugins/tool_crop/kis_tool_crop.cc:70: 
undefined reference to `KisCropSelection::~KisCropSelection()'
.libs/kis_tool_crop.o: In function `KisToolCrop::paintCropSelection(QPainter&, 
QRect const&)':
/usr/local/src/kde/koffice/krita/plugins/tool_crop/kis_tool_crop.cc:343: 
undefined reference to `KisCropSelection::handles()'
.libs/kis_tool_crop.o: In function `KisToolCrop::setEndY(int)':
/usr/local/src/kde/koffice/krita/plugins/tool_crop/kis_tool_crop.cc:519: 
undefined reference to `KisCropSelection::resize(QPoint, QPoint)'
.libs/kis_tool_crop.o: In function `KisToolCrop::setEndX(int)':
/usr/local/src/kde/koffice/krita/plugins/tool_crop/kis_tool_crop.cc:494: 
undefined reference to `KisCropSelection::resize(QPoint, QPoint)'
.libs/kis_tool_crop.o: In function `KisToolCrop::setStartY(int)':
/usr/local/src/kde/koffice/krita/plugins/tool_crop/kis_tool_crop.cc:469: 
undefined reference to `KisCropSelection::resize(QPoint, QPoint)'
.libs/kis_tool_crop.o: In function `KisToolCrop::setStartX(int)':
/usr/local/src/kde/koffice/krita/plugins/tool_crop/kis_tool_crop.cc:444: 
undefined reference to `KisCropSelection::resize(QPoint, QPoint)'
.libs/kis_tool_crop.o: In function 
`KisToolCrop::buttonRelease(KisButtonReleaseEvent*)':
/usr/local/src/kde/koffice/krita/plugins/tool_crop/kis_tool_crop.cc:272: 
undefined reference to `KisCropSelection::resize(QPoint, QPoint)'
.libs/kis_tool_crop.o:/usr/local/src/kde/koffice/krita/plugins/tool_crop/kis_tool_crop.cc:182: 
more undefined references to `KisCropSelection::resize(QPoint, QPoint)' 
follow
.libs/kis_tool_crop.o: In function `.L503':
/usr/local/src/kde/koffice/krita/plugins/tool_crop/kis_tool_crop.cc:257: 
undefined reference to `KisCropSelection::mouseOnHandle(QPoint)'
.libs/kis_tool_crop.o: In function 
`KisToolCrop::buttonPress(KisButtonPressEvent*)':
/usr/local/src/kde/koffice/krita/plugins/tool_crop/kis_tool_crop.cc:146: 
undefined reference to `KisCropSelection::resize(QPoint, QPoint)'
/usr/local/src/kde/koffice/krita/plugins/tool_crop/kis_tool_crop.cc:152: 
undefined reference to `KisCropSelection::mouseOnHandle(QPoint)'
collect2: ld returned 1 exit status
make: *** [kritatoolcrop.la] Error 1

Does somebody understand what I am doing wrong here? I guess I am really too 
tired and I should stop working on Krita...

Greetings,
Michael


More information about the kimageshop mailing list