1 #include "MosaicTool.h"
9 #include "IException.h"
11 #include "MosaicSceneWidget.h"
12 #include "PvlObject.h"
16 MosaicTool::MosaicTool(MosaicSceneWidget *scene) :
QObject(scene) {
18 p_primaryAction = NULL;
19 p_toolBarAction = NULL;
22 connect(
this, SIGNAL(activated(
bool)),
this, SLOT(
updateTool()));
25 connect(scene, SIGNAL(mouseEnter()),
this, SLOT(mouseEnter()));
26 connect(scene, SIGNAL(mouseLeave()),
this, SLOT(mouseLeave()));
27 connect(scene, SIGNAL(mouseMove(QPointF)),
this, SLOT(mouseMove(QPointF)));
29 connect(scene, SIGNAL(mouseDoubleClick(QPointF)),
30 this, SLOT(mouseDoubleClick(QPointF)));
31 connect(scene, SIGNAL(mouseButtonPress(QPointF, Qt::MouseButton)),
32 this, SLOT(mouseButtonPress(QPointF, Qt::MouseButton)));
33 connect(scene, SIGNAL(mouseButtonRelease(QPointF, Qt::MouseButton)),
34 this, SLOT(mouseButtonRelease(QPointF, Qt::MouseButton)));
35 connect(scene, SIGNAL(mouseWheel(QPointF,
int)),
36 this, SLOT(mouseWheel(QPointF,
int)));
37 connect(scene, SIGNAL(rubberBandComplete(QRectF, Qt::MouseButton)),
38 this, SLOT(rubberBandComplete(QRectF, Qt::MouseButton)));
43 MosaicTool::~MosaicTool() {
46 delete p_toolBarAction;
52 void MosaicTool::addTo(ToolPad *toolPad) {
53 if(!p_primaryAction) {
57 p_primaryAction->setCheckable(
true);
58 p_primaryAction->setChecked(
p_active);
63 connect(p_primaryAction, SIGNAL(toggled(
bool)),
65 toolPad->addAction(p_primaryAction);
70 void MosaicTool::addTo(
QToolBar *toolBar) {
76 p_toolBarAction = toolBar->addWidget(toolBarWidget);
77 connect(p_toolBarAction, SIGNAL(destroyed(
QObject *)),
78 this, SLOT(toolBarDestroyed(
QObject *)));
89 PvlObject MosaicTool::toPvl()
const {
90 if(projectPvlObjectName() ==
"") {
91 PvlObject obj(
"Invalid");
96 "Please re-implement toPvl in your tool",
101 void MosaicTool::fromPvl(
const PvlObject &obj) {
102 if(projectPvlObjectName() !=
"") {
104 "Please re-implement fromPvl in your tool",
110 QString MosaicTool::projectPvlObjectName()
const {
117 QString fullPathToFile = QString(path +
"/" + iconName);
118 return QPixmap(fullPathToFile);
122 void MosaicTool::mouseMove(QPointF) {
126 void MosaicTool::mouseDoubleClick(QPointF) {
130 void MosaicTool::mouseButtonPress(QPointF, Qt::MouseButton s) {
134 void MosaicTool::mouseButtonRelease(QPointF, Qt::MouseButton s) {
139 void MosaicTool::mouseWheel(QPointF,
int) {
149 bool activeStateChanged = (
p_active != on);
160 if(activeStateChanged)
165 void MosaicTool::toolBarDestroyed(
QObject *) {
166 p_toolBarAction = NULL;
175 if(p_toolBarAction) {
176 p_toolBarAction->setVisible(
false);
186 if(p_toolBarAction) {
187 p_toolBarAction->setVisible(
true);