19 #include <QApplication> 31 #include <ui_PlotConfigWidget.h> 47 ui_->pushButtonAddCurve->setIcon(
49 append(
"/resource/16x16/add.png"))));
50 ui_->pushButtonEditCurve->setIcon(
52 append(
"/resource/16x16/edit.png"))));
53 ui_->pushButtonRemoveCurves->setIcon(
55 append(
"/resource/16x16/remove.png"))));
57 ui_->pushButtonEditCurve->setEnabled(
false);
58 ui_->pushButtonRemoveCurves->setEnabled(
false);
60 ui_->pushButtonCopyCurves->setIcon(
62 append(
"/resource/16x16/copy.png"))));
63 ui_->pushButtonPasteCurves->setIcon(
65 append(
"/resource/16x16/paste.png"))));
67 ui_->pushButtonCopyCurves->setEnabled(
false);
68 ui_->pushButtonPasteCurves->setEnabled(
false);
70 ui_->curveListWidget->installEventFilter(
this);
75 connect(
config_, SIGNAL(titleChanged(
const QString&)),
77 connect(
config_, SIGNAL(plotRateChanged(
double)),
80 connect(
ui_->lineEditTitle, SIGNAL(editingFinished()),
this,
83 connect(
ui_->pushButtonAddCurve, SIGNAL(clicked()),
this,
85 connect(
ui_->pushButtonEditCurve, SIGNAL(clicked()),
this,
87 connect(
ui_->pushButtonRemoveCurves, SIGNAL(clicked()),
this,
90 connect(
ui_->pushButtonCopyCurves, SIGNAL(clicked()),
this,
92 connect(
ui_->pushButtonPasteCurves, SIGNAL(clicked()),
this,
95 connect(
ui_->curveListWidget, SIGNAL(itemSelectionChanged()),
97 connect(
ui_->curveListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)),
100 connect(
ui_->doubleSpinBoxPlotRate, SIGNAL(valueChanged(
double)),
103 connect(QApplication::clipboard(), SIGNAL(dataChanged()),
121 ui_->curveListWidget->clear();
138 QList<QListWidgetItem*> items =
ui_->curveListWidget->selectedItems();
140 if (!items.isEmpty()) {
142 QDataStream stream(&data, QIODevice::WriteOnly);
144 stream << (quint64)items.count();
146 for (QList<QListWidgetItem*>::const_iterator it = items.begin();
147 it != items.end(); ++it) {
149 ui_->curveListWidget->itemWidget(*it));
154 QMimeData* mimeData =
new QMimeData();
157 QApplication::clipboard()->setMimeData(mimeData);
162 const QMimeData* mimeData = QApplication::clipboard()->mimeData();
166 QDataStream stream(&data, QIODevice::ReadOnly);
171 for (
size_t index = 0; index < numCurves; ++index) {
173 stream >> *curveConfig;
176 curveConfig->
setTitle(
"Copy of "+curveConfig->getTitle());
178 ui_->curveListWidget->addCurve(curveConfig);
184 if (
object ==
ui_->curveListWidget) {
185 if (event->type() == QEvent::KeyPress) {
186 QKeyEvent* keyEvent =
static_cast<QKeyEvent*
>(event);
188 if (keyEvent->modifiers() == Qt::ControlModifier) {
189 if (keyEvent->key() == Qt::Key_C)
191 else if (keyEvent->key() == Qt::Key_V)
205 ui_->lineEditTitle->setText(title);
209 ui_->doubleSpinBoxPlotRate->setValue(rate);
220 "Add Curve to Plot" :
225 if (dialog.exec() == QDialog::Accepted) {
229 ui_->curveListWidget->addCurve(curveConfig);
234 QListWidgetItem* item =
ui_->curveListWidget->currentItem();
238 ui_->curveListWidget->itemWidget(item));
243 dialog.setWindowTitle(curveConfig->
getTitle().isEmpty() ?
245 "Edit \""+curveConfig->
getTitle()+
"\"");
248 if (dialog.exec() == QDialog::Accepted)
254 QList<QListWidgetItem*> items =
ui_->curveListWidget->selectedItems();
256 for (QList<QListWidgetItem*>::iterator it = items.begin();
257 it != items.end(); ++it) {
259 ui_->curveListWidget->itemWidget(*it));
277 QList<QListWidgetItem*> items =
ui_->curveListWidget->selectedItems();
279 ui_->pushButtonEditCurve->setEnabled(items.count() == 1);
280 ui_->pushButtonRemoveCurves->setEnabled(!items.isEmpty());
282 ui_->pushButtonCopyCurves->setEnabled(!items.isEmpty());
295 const QMimeData* mimeData = QApplication::clipboard()->mimeData();
297 ui_->pushButtonPasteCurves->setEnabled(mimeData && mimeData->hasFormat(
static const QString MimeType
PlotAxesConfig * getAxesConfig() const
QVector< CurveConfig * > findCurves(const QString &title) const
PlotLegendConfig * getLegendConfig() const
void setAutoColorIndex(unsigned char index)
const QString & getTitle() const
double getPlotRate() const
void setPlotRate(double rate)
ROSLIB_DECL std::string getPath(const std::string &package_name)
CurveConfig * getCurveConfig(size_t index) const
CurveConfigWidget * getWidget() const
size_t getNumCurves() const
const QString & getTitle() const
void setTitle(const QString &title)
void removeCurve(CurveConfig *curveConfig)
ROSCPP_DECL std::string append(const std::string &left, const std::string &right)
void setTitle(const QString &title)
CurveColorConfig * getColorConfig() const