Programming questions

Michael Thaler michael.thaler at ph.tum.de
Sun Jul 10 09:52:25 CEST 2005


Hello,

I still try to port the cubism filter and I have some questions:

I wrote a KisPolygon class, that basically stores points and can rotate and 
translate the points:

class KisPolygon
{
        public:
                KisPolygon();
                void addPoint(double x, double y);
                void translate(double tx, double ty);
                void rotate(double theta);
                Q_INT32 extents(double &minX, double &minY, double &maxX, 
double &maxY);
                void clear();
                Q_INT32 numberOfPoints();
        private:
                typedef QValueVector<KisPoint> KisPointVector;
                KisPointVector* m_data;
};

KisPolygon::KisPolygon()
{
        m_data = new KisPointVector(4);
}

void KisPolygon::addPoint(double x, double y)
{
        KisPoint point(x, y);
        m_data->append(point);
}

void KisPolygon::translate(double tx, double ty)
{
        KisPointVector::iterator it;
        
        for( it = m_data->begin(); it != m_data->end(); ++it )
        {
                (*it).setX( (*it).x() + tx );
                (*it).setY( (*it).y() + ty );
        }
}

and so on. Now I have the following function

void KisCubismFilter::fillPolyColor (KisPaintDeviceSP src, KisPaintDeviceSP 
dst, KisPolygon* poly, Q_UINT8* col, Q_UINT8* dest)

which gets a pointer to my KisPolygon class. When I try to access the first 
point in the KisPolygon class

poly[0].x();

I get the following error

KisCubismFilter::fillPolyColor(KSharedPtr<KisPaintDevice>,
   KSharedPtr<KisPaintDevice>, KisPolygon*, Q_UINT8*, Q_UINT8*)':
kis_cubism_filter.cc:171: error: `x' undeclared (first use this function)
kis_cubism_filter.cc:171: error: (Each undeclared identifier is reported only
   once for each function it appears in.)

poly[0]->x(); does not work either:

Then I get

KisCubismFilter::fillPolyColor(KSharedPtr<KisPaintDevice>,
   KSharedPtr<KisPaintDevice>, KisPolygon*, Q_UINT8*, Q_UINT8*)':
kis_cubism_filter.cc:171: error: base operand of `->' has non-pointer type `
   KisPolygon'

In http://doc.trolltech.org/3.3/qvaluevector.html#details it is explained that 
you can access elements with []. Whoever, they did create the vector on the 
stack, not with new. I think my bad C++ programming skills just catched me:-) 
Can someone help me?

Greetings,
Michael


More information about the kimageshop mailing list