Main
::Main(QGraphicsScene
& c,
QWidget* parent,
const char* name, Qt
::WindowFlags f
) : Q3MainWindow(parent,name,f),
canvas(c)
{
editor = new FigureEditor(canvas,this);
rotate1->setGeometry(2, 0, 55, 20);
connect(rotate1, SIGNAL(clicked()), this, SLOT(rotateClockwise()));
rotate2->setGeometry(2, 18, 55, 20);
connect(rotate2, SIGNAL(clicked()), this, SLOT(rotateCounterClockwise()));
zoom_in->setGeometry(2, 36, 55, 20);
connect(zoom_in, SIGNAL(clicked()), this, SLOT(zoomIn()));
zoom_out->setGeometry(2, 54, 55, 20);
connect(zoom_out, SIGNAL(clicked()), this, SLOT(zoomOut()));
moveup->setGeometry(2, 72, 55, 20);
connect(moveup, SIGNAL(clicked()), this, SLOT(moveU()));
movedown->setGeometry(2, 90, 55, 20);
connect(movedown, SIGNAL(clicked()), this, SLOT(moveD()));
moveleft->setGeometry(2, 108, 55, 20);
connect(moveleft, SIGNAL(clicked()), this, SLOT(moveL()));
moveright->setGeometry(2, 126, 55, 20);
connect(moveright, SIGNAL(clicked()), this, SLOT(moveR()));
xval=0;
yval=0;
setCentralWidget(editor);
printer = 0;
init();
}
void Main::rotateClockwise()
{
editor->rotate( 5 );
}
void Main::rotateCounterClockwise()
{
editor->rotate( -5 );
}
void Main::zoomIn()
{
editor->scale( 1.1, 1.1 );
}
void Main::zoomOut()
{
editor->scale( 0.9, 0.9 );
}
void Main::mirror()
{
editor->scale( -1, 1 );
}
void Main::moveL()
{
editor->translate( -16, 0 );
}
void Main::moveR()
{
editor->translate( +16, 0 );
}
void Main::moveU()
{
yval++;
editor->translate( 0, -660 );
}
void Main::moveD()
{
xval++;
editor->translate( 0, +660 );
}
Main::Main(QGraphicsScene& c, QWidget* parent, const char* name, Qt::WindowFlags f) :
Q3MainWindow(parent,name,f),
canvas(c)
{
editor = new FigureEditor(canvas,this);
QMenuBar* menu = menuBar();
QPushButton *rotate1 = new QPushButton(tr("Rotate->"), this);
rotate1->setGeometry(2, 0, 55, 20);
connect(rotate1, SIGNAL(clicked()), this, SLOT(rotateClockwise()));
QPushButton *rotate2 = new QPushButton(tr("Rotate<-"), this);
rotate2->setGeometry(2, 18, 55, 20);
connect(rotate2, SIGNAL(clicked()), this, SLOT(rotateCounterClockwise()));
QPushButton *zoom_in = new QPushButton(tr("zoom_in"), this);
zoom_in->setGeometry(2, 36, 55, 20);
connect(zoom_in, SIGNAL(clicked()), this, SLOT(zoomIn()));
QPushButton *zoom_out = new QPushButton(tr("zoom_out"), this);
zoom_out->setGeometry(2, 54, 55, 20);
connect(zoom_out, SIGNAL(clicked()), this, SLOT(zoomOut()));
QPushButton *moveup = new QPushButton(tr("moveUp"), this);
moveup->setGeometry(2, 72, 55, 20);
connect(moveup, SIGNAL(clicked()), this, SLOT(moveU()));
QPushButton *movedown = new QPushButton(tr("movedown"), this);
movedown->setGeometry(2, 90, 55, 20);
connect(movedown, SIGNAL(clicked()), this, SLOT(moveD()));
QPushButton *moveleft = new QPushButton(tr("moveleft"), this);
moveleft->setGeometry(2, 108, 55, 20);
connect(moveleft, SIGNAL(clicked()), this, SLOT(moveL()));
QPushButton *moveright = new QPushButton(tr("moveright"), this);
moveright->setGeometry(2, 126, 55, 20);
connect(moveright, SIGNAL(clicked()), this, SLOT(moveR()));
xval=0;
yval=0;
setCentralWidget(editor);
printer = 0;
init();
}
void Main::rotateClockwise()
{
editor->rotate( 5 );
}
void Main::rotateCounterClockwise()
{
editor->rotate( -5 );
}
void Main::zoomIn()
{
editor->scale( 1.1, 1.1 );
}
void Main::zoomOut()
{
editor->scale( 0.9, 0.9 );
}
void Main::mirror()
{
editor->scale( -1, 1 );
}
void Main::moveL()
{
editor->translate( -16, 0 );
}
void Main::moveR()
{
editor->translate( +16, 0 );
}
void Main::moveU()
{
yval++;
editor->translate( 0, -660 );
}
void Main::moveD()
{
xval++;
editor->translate( 0, +660 );
}
To copy to clipboard, switch view to plain text mode
Here the image is getting rotated clockwise & anticlockwise but not moving up,down,left & right.sorry for not using code tags instead of 2 warnings.I followed the link given by you but i could'nt understand how to use code tags.
Bookmarks