File failed to load: https://isis.astrogeology.usgs.gov/9.0.0/Object/assets/jax/output/NativeMML/config.js
Isis 3 Programmer Reference
MosaicTool.cpp
1#include "MosaicTool.h"
2
3#include <iostream>
4
5#include <QDebug>
6#include <QLabel>
7
8#include "FileName.h"
9#include "IException.h"
10#include "IString.h"
11#include "MosaicSceneWidget.h"
12#include "PvlObject.h"
13#include "ToolPad.h"
14
15namespace Isis {
16 MosaicTool::MosaicTool(MosaicSceneWidget *scene) : QObject(scene) {
17 p_active = false;
18 p_primaryAction = NULL;
19 p_toolBarAction = NULL;
20 p_widget = scene;
21
22 connect(this, SIGNAL(activated(bool)), this, SLOT(updateTool()));
23
24 if (scene) {
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)));
28
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)));
39 }
40 }
41
42
43 MosaicTool::~MosaicTool() {
44 // This will call toolBarDestroyed which will NULL the pointer
45 if(p_toolBarAction)
46 delete p_toolBarAction;
47
48 // The actions not derived from widgets will auto-destroy
49 }
50
51
52 void MosaicTool::addTo(ToolPad *toolPad) {
53 if(!p_primaryAction) {
54 p_primaryAction = getPrimaryAction();
55
56 if(p_primaryAction) {
57 p_primaryAction->setCheckable(true);
58 p_primaryAction->setChecked(p_active);
59 }
60 }
61
62 if(p_primaryAction) {
63 connect(p_primaryAction, SIGNAL(toggled(bool)),
64 this, SLOT(activate(bool)));
65 toolPad->addAction(p_primaryAction);
66 }
67 }
68
69
70 void MosaicTool::addTo(QToolBar *toolBar) {
71 QWidget *toolBarWidget = NULL;
72 if(!p_toolBarAction)
73 toolBarWidget = getToolBarWidget();
74
75 if(toolBarWidget) {
76 p_toolBarAction = toolBar->addWidget(toolBarWidget);
77 connect(p_toolBarAction, SIGNAL(destroyed(QObject *)),
78 this, SLOT(toolBarDestroyed(QObject *)));
79 disableToolBar();
80 }
81 }
82
83
84 QList<QAction *> MosaicTool::getViewActions() {
85 return QList<QAction *>();
86 }
87
88
89 PvlObject MosaicTool::toPvl() const {
90 if(projectPvlObjectName() == "") {
91 PvlObject obj("Invalid");
92 return obj;
93 }
94
95 throw IException(IException::Programmer,
96 "Please re-implement toPvl in your tool",
97 _FILEINFO_);
98 }
99
100
101 void MosaicTool::fromPvl(const PvlObject &obj) {
102 if(projectPvlObjectName() != "") {
103 throw IException(IException::Programmer,
104 "Please re-implement fromPvl in your tool",
105 _FILEINFO_);
106 }
107 }
108
109
110 QString MosaicTool::projectPvlObjectName() const {
111 return "";
112 }
113
114
115 QPixmap MosaicTool::getIcon(QString iconName) const {
116 QString path = FileName("$ISISROOT/appdata/images/icons").expanded();
117 QString fullPathToFile = QString(path + "/" + iconName);
118 return QPixmap(fullPathToFile);
119 }
120
121
122 void MosaicTool::mouseMove(QPointF) {
123 }
124
125
126 void MosaicTool::mouseDoubleClick(QPointF) {
127 }
128
129
130 void MosaicTool::mouseButtonPress(QPointF, Qt::MouseButton s) {
131 }
132
133
134 void MosaicTool::mouseButtonRelease(QPointF, Qt::MouseButton s) {
135 //qDebug()<<"MosaicTool::mouseButtonRelease";
136 }
137
138
139 void MosaicTool::mouseWheel(QPointF, int) {
140 }
141
142
148 void MosaicTool::activate(bool on) {
149 bool activeStateChanged = (p_active != on);
150
151 if(p_active && !on) {
153 }
154 else if(!p_active && on) {
156 }
157
158 p_active = on;
159
160 if(activeStateChanged)
161 emit activated(p_active);
162 }
163
164
165 void MosaicTool::toolBarDestroyed(QObject *) {
166 p_toolBarAction = NULL;
167 }
168
169
175 if(p_toolBarAction) {
176 p_toolBarAction->setVisible(false);
177 }
178 }
179
180
186 if(p_toolBarAction) {
187 p_toolBarAction->setVisible(true);
188 }
189 }
190
191
193 return new QWidget();
194 }
195}
File name manipulation and expansion.
Definition FileName.h:100
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
Definition FileName.cpp:196
This widget encompasses the entire mosaic scene.
QPixmap getIcon(QString iconName) const
returns the path to the icon directory.
bool p_active
Is the tool active?
Definition MosaicTool.h:120
void enableToolBar()
Enables entire tool bar.
void disableToolBar()
Disables entire tool bar.
virtual QWidget * getToolBarWidget()
This method returns a widget that will be put in a tool bar when the tool is activated.
void activate(bool)
Activates the tool.
This is free and unencumbered software released into the public domain.
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16