void PropertyWidget_ParEffect::setDoc(ScribusDoc *doc) { if(doc == (ScribusDoc*) m_doc) return; if (m_doc) { disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); disconnect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); } m_doc = doc; peCharStyleCombo->setDoc(doc); if (m_doc.isNull()) { disconnectSignals(); return; } m_unitRatio = m_doc->unitRatio(); m_unitIndex = m_doc->unitIndex(); fillNumerationsCombo(); connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); connect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); // Handle properties update when switching document handleSelectionChanged(); }
void PropertyWidget_Advanced::setDoc(ScribusDoc *d) { if((d == (ScribusDoc*) m_doc) || (m_ScMW && m_ScMW->scriptIsRunning())) return; if (m_doc) { disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); disconnect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); } m_doc = d; m_item = NULL; if (m_doc.isNull()) { disconnectSignals(); return; } m_unitRatio = m_doc->unitRatio(); m_unitIndex = m_doc->unitIndex(); tracking->setValues( -300, 300, 2, 0); minWordTrackingSpinBox->setValues(1, 100, 2, 100); normWordTrackingSpinBox->setValues(1, 2000, 2, 100); minGlyphExtSpinBox->setValues(90, 110, 2, 100); maxGlyphExtSpinBox->setValues(90, 110, 2, 100); connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); connect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); }
void PropertiesPalette_Text::unsetDoc() { if (m_doc) { disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); disconnect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); } m_haveDoc = false; m_haveItem = false; m_doc = NULL; m_item = NULL; paraStyleCombo->setDoc(0); charStyleCombo->setDoc(0); advancedWidgets->setDoc(0); fontfeaturesWidget->setDoc(0); colorWidgets->setDoc(0); distanceWidgets->setDoc(0); flopBox->setDoc(0); hyphenationWidget->setDoc(NULL); optMargins->setDoc(0); orphanBox->setDoc(0); parEffectWidgets->setDoc(0); pathTextWidgets->setDoc(0); m_haveItem = false; setEnabled(false); }
void PropertiesPalette_Shadow::unsetDoc() { if (m_doc) { disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); disconnect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); } m_haveDoc = false; m_haveItem = false; m_doc = NULL; m_item = NULL; setEnabled(false); }
void PropertiesPalette_Shadow::setDoc(ScribusDoc *d) { if((d == (ScribusDoc*) m_doc) || (m_ScMW && m_ScMW->scriptIsRunning())) return; if (m_doc) { disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); disconnect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); } m_doc = d; m_item = NULL; m_unitRatio = m_doc->unitRatio(); m_unitIndex = m_doc->unitIndex(); int precision = unitGetPrecisionFromIndex(m_unitIndex); double maxXYWHVal = 200 * m_unitRatio; double minXYVal = -200 * m_unitRatio; m_haveDoc = true; m_haveItem = false; softShadowXOffset->setUnitValue(m_unitIndex); softShadowXOffset->setDecimalsValue(precision); softShadowXOffset->setMinMaxValues(minXYVal, maxXYWHVal); softShadowXOffset->setDoubleValue(minXYVal); softShadowYOffset->setUnitValue(m_unitIndex); softShadowYOffset->setDecimalsValue(precision); softShadowYOffset->setMinMaxValues(minXYVal, maxXYWHVal); softShadowYOffset->setDoubleValue(minXYVal); softShadowBlurRadius->setUnitValue(m_unitIndex); softShadowBlurRadius->setDecimalsValue(1); softShadowBlurRadius->setMinMaxValues(0.0, 20.0); softShadowBlurRadius->setDoubleValue(5); softShadowShade->setDecimalsValue(0); softShadowShade->setMinMaxValues(0, 100); softShadowShade->setIntValue(100); softShadowOpacity->setDecimalsValue(0); softShadowOpacity->setMinMaxValues(0, 100); softShadowOpacity->setIntValue(100); updateColorList(); connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); connect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); }
void PropertiesPalette_Group::unsetItem() { m_haveItem = false; m_item = NULL; transPalWidget->setCurrentItem(NULL); handleSelectionChanged(); }
void PropertiesPalette_Line::unsetItem() { m_haveItem = false; m_item = NULL; dashEditor->hide(); handleSelectionChanged(); }
/*! Create and return the table used to visualize digital signals. */ QTableView* UiDigitalGenerator::createTable() { // Deallocation: "Qt Object trees" (See UiMainWindow) QTableView* table = new QTableView(this); QItemSelectionModel* m = table->selectionModel(); if (m != NULL) delete m; table->setModel(mSignals); // Deallocation: "Qt Object trees" (See UiMainWindow) DigitalDelegate* delegate = new DigitalDelegate(this); QAbstractItemDelegate* d = table->itemDelegate(); if (d != NULL) delete d; table->setItemDelegate(delegate); table->resizeColumnsToContents(); table->resizeRowsToContents(); connect(table->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(handleSelectionChanged(QItemSelection,QItemSelection))); return table; }
void ThumbView::load() { emit showBusy(true); loadPrepare(); initThumbs(); updateThumbsCount(); loadVisibleThumbs(); if (GData::includeSubFolders) { QDirIterator iterator(GData::currentViewDir, QDirIterator::Subdirectories); while (iterator.hasNext()) { iterator.next(); if (iterator.fileInfo().isDir() && iterator.fileName() != "." && iterator.fileName() != "..") { thumbsDir->setPath(iterator.filePath()); initThumbs(); updateThumbsCount(); loadVisibleThumbs(); if (abortOp) { goto finish; } } QApplication::processEvents(); } QItemSelection dummy; handleSelectionChanged(dummy); } finish: emit showBusy(false); busy = false; return; }
void PropertiesPalette_Text::unsetItem() { m_haveItem = false; m_item = NULL; colorWidgets->setCurrentItem(m_item); handleSelectionChanged(); }
TutorialTreeSelectionManager::TutorialTreeSelectionManager( QItemSelectionModel* itemSelectionModel, QObject* parent): QObject(parent) { connect(itemSelectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(handleSelectionChanged(QItemSelection,QItemSelection))); }
void PropertiesPalette_XYZ::handleGrouping() { m_ScMW->GroupObj(); doGroup->setEnabled(false); doUnGroup->setEnabled(true); handleSelectionChanged(); //FIXME //TabStack->setItemEnabled(idShapeItem, false); }
Caret::Caret(Score &score) : myLocation(score), myInPlaybackMode(false), mySelectionPubSub(std::make_shared<ScoreLocationPubSub>()) { mySelectionPubSub->subscribe([this](const ScoreLocation &loc) { handleSelectionChanged(loc); }); }
void PropertiesPalette_Group::unsetDoc() { if (m_doc) { disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); disconnect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); } m_haveDoc = false; m_haveItem = false; m_doc = NULL; m_item = NULL; transPalWidget->setDocument(NULL); transPalWidget->setCurrentItem(NULL); setEnabled(false); }
void PropertyWidget_ParEffect::handleChanges(PageItem *item, ParagraphStyle &newStyle) { if (m_doc->appMode == modeEditTable) item = item->asTable()->activeCell().textFrame(); if (item != NULL) { disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); disconnect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); Selection tempSelection(this, false); tempSelection.addItem(item, true); m_doc->itemSelection_ApplyParagraphStyle(newStyle, &tempSelection); m_doc->updateNumbers(); connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); connect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); } }
void PropertiesPalette_Text::setDoc(ScribusDoc *d) { if((d == (ScribusDoc*) m_doc) || (m_ScMW && m_ScMW->scriptIsRunning())) return; if (m_doc) { disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); disconnect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); } m_doc = d; m_item = NULL; m_unitRatio = m_doc->unitRatio(); m_unitIndex = m_doc->unitIndex(); m_haveDoc = true; m_haveItem = false; fontSize->setValues( 0.5, 2048, 2, 1); lineSpacing->setValues( 1, 2048, 2, 1); advancedWidgets->setDoc(m_doc); fontfeaturesWidget->setDoc(m_doc); colorWidgets->setDoc(m_doc); distanceWidgets->setDoc(m_doc); parEffectWidgets->setDoc(m_doc); flopBox->setDoc(m_doc); hyphenationWidget->setDoc(m_doc); optMargins->setDoc(m_doc); orphanBox->setDoc(m_doc); pathTextWidgets->setDoc(m_doc); fonts->RebuildList(m_doc); paraStyleCombo->setDoc(m_doc); charStyleCombo->setDoc(m_doc); connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); connect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); }
void PropertiesPalette_XYZ::setDoc(ScribusDoc *d) { if((d == (ScribusDoc*) m_doc) || (m_ScMW && m_ScMW->scriptIsRunning())) return; if (m_doc) { disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); disconnect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); } m_doc = d; m_item = NULL; m_unitRatio = m_doc->unitRatio(); m_unitIndex = m_doc->unitIndex(); int precision = unitGetPrecisionFromIndex(m_unitIndex); //qt4 FIXME here double maxXYWHVal = 16777215 * m_unitRatio; double minXYVal = -16777215 * m_unitRatio; m_haveDoc = true; m_haveItem = false; QMap<QString, double>* docConstants = m_doc? &m_doc->constants() : NULL; xposSpin->setValues( minXYVal, maxXYWHVal, precision, minXYVal); xposSpin->setConstants(docConstants); yposSpin->setValues( minXYVal, maxXYWHVal, precision, minXYVal); yposSpin->setConstants(docConstants); widthSpin->setValues( m_unitRatio, maxXYWHVal, precision, m_unitRatio); widthSpin->setConstants(docConstants); heightSpin->setValues( m_unitRatio, maxXYWHVal, precision, m_unitRatio); heightSpin->setConstants(docConstants); rotationSpin->setValues( 0, 359.99, 1, 0); updateSpinBoxConstants(); connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); connect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); }
MaemoRemoteProcessesDialog::MaemoRemoteProcessesDialog(const LinuxDeviceConfiguration::ConstPtr &devConfig, QWidget *parent): QDialog(parent), m_ui(new Ui::MaemoRemoteProcessesDialog), m_processList(new MaemoRemoteProcessList(devConfig, this)), m_proxyModel(new QSortFilterProxyModel(this)) { m_ui->setupUi(this); m_ui->tableView->setSelectionBehavior(QAbstractItemView::SelectRows); m_proxyModel->setSourceModel(m_processList); m_proxyModel->setDynamicSortFilter(true); m_proxyModel->setFilterKeyColumn(1); m_ui->tableView->setModel(m_proxyModel); connect(m_ui->processFilterLineEdit, SIGNAL(textChanged(QString)), m_proxyModel, SLOT(setFilterRegExp(QString))); // Manually gathered process information is missing the command line for // some system processes. Dont's show these lines by default. if (devConfig->osType() == LinuxDeviceConfiguration::Maemo5OsType) m_ui->processFilterLineEdit->setText(QLatin1String("[^ ]+")); connect(m_ui->tableView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SLOT(handleSelectionChanged())); connect(m_ui->updateListButton, SIGNAL(clicked()), SLOT(updateProcessList())); connect(m_ui->killProcessButton, SIGNAL(clicked()), SLOT(killProcess())); connect(m_processList, SIGNAL(error(QString)), SLOT(handleRemoteError(QString))); connect(m_processList, SIGNAL(modelReset()), SLOT(handleProcessListUpdated())); connect(m_processList, SIGNAL(processKilled()), SLOT(handleProcessKilled()), Qt::QueuedConnection); connect(m_proxyModel, SIGNAL(layoutChanged()), SLOT(handleProcessListUpdated())); handleSelectionChanged(); updateProcessList(); }
void PropertyWidget_OptMargins::setDoc(ScribusDoc *d) { if((d == (ScribusDoc*) m_doc) || (m_ScMW && m_ScMW->scriptIsRunning())) return; if (m_doc) { disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); disconnect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); } m_doc = d; m_item = NULL; if (m_doc.isNull()) { disconnectSignals(); return; } connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); connect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); }
void PropertiesPalette_Group::setDoc(ScribusDoc *d) { if((d == (ScribusDoc*) m_doc) || (m_ScMW && m_ScMW->scriptIsRunning())) return; if (m_doc) { disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); disconnect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); } disconnect(this->transPalWidget, SIGNAL(NewTrans(double)), 0, 0); disconnect(this->transPalWidget, SIGNAL(NewBlend(int)), 0, 0); disconnect(this->transPalWidget, SIGNAL(NewGradient(int)), 0, 0); disconnect(this->transPalWidget, SIGNAL(NewPattern(QString)), 0, 0); disconnect(this->transPalWidget, SIGNAL(NewPatternProps(double, double, double, double, double, double, double, bool, bool)), 0, 0); m_doc = d; m_item = NULL; m_unitRatio = m_doc->unitRatio(); m_unitIndex = m_doc->unitIndex(); transPalWidget->setDocument(m_doc); transPalWidget->setCurrentItem(NULL); m_haveDoc = true; m_haveItem = false; connect(this->transPalWidget, SIGNAL(NewTrans(double)) , this, SLOT(handleGroupTransparency(double))); connect(this->transPalWidget, SIGNAL(NewBlend(int)) , this, SLOT(handleGroupBlending(int))); connect(this->transPalWidget, SIGNAL(NewGradient(int)) , this, SLOT(handleGroupGradMask(int))); connect(this->transPalWidget, SIGNAL(NewPattern(QString)), this, SLOT(handleGroupPatternMask(QString))); connect(this->transPalWidget, SIGNAL(NewPatternProps(double, double, double, double, double, double, double, bool, bool)), this, SLOT(handleGroupPatternMaskProps(double, double, double, double, double, double, double, bool, bool))); connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); connect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); }
ThumbView::ThumbView(QWidget *parent, MetadataCache *mdCache) : QListView(parent) { this->mdCache = mdCache; GData::thumbsBackgroundColor = GData::appSettings->value("backgroundThumbColor").value<QColor>(); GData::thumbsTextColor = GData::appSettings->value("textThumbColor").value<QColor>(); setThumbColors(); GData::thumbSpacing = GData::appSettings->value("thumbSpacing").toInt(); GData::thumbPagesReadahead = GData::appSettings->value("thumbPagesReadahead").toInt(); GData::thumbsLayout = GData::appSettings->value("thumbLayout").toInt(); thumbSize = GData::appSettings->value("thumbsZoomVal").toInt(); currentRow = 0; setViewMode(QListView::IconMode); setSelectionMode(QAbstractItemView::ExtendedSelection); setResizeMode(QListView::Adjust); setWordWrap(true); setDragEnabled(true); setEditTriggers(QAbstractItemView::NoEditTriggers); setItemDelegate(new QItemDelegate); setUniformItemSizes(false); thumbViewModel = new QStandardItemModel(this); thumbViewModel->setSortRole(SortRole); setModel(thumbViewModel); connect(verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(loadVisibleThumbs(int))); connect(this->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, SLOT(handleSelectionChanged(QItemSelection))); connect(this, SIGNAL(doubleClicked(const QModelIndex &)), parent, SLOT(loadImagefromThumb(const QModelIndex &))); connect(this->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), parent, SLOT(updateViewerImageBySelection(QItemSelection))); thumbsDir = new QDir(); fileFilters = new QStringList; emptyImg.load(":/images/no_image.png"); QTime time = QTime::currentTime(); qsrand((uint)time.msec()); mainWindow = parent; infoView = new InfoView(this); }
SelectPathsWidget::SelectPathsWidget(const QStringList& paths, QWidget* parent /*= 0*/): QWidget(parent) { m_ui = new Ui::SelectPathsWidget(); m_ui->setupUi(this); m_pathsModel = new QStringListModel(this); m_pathsModel->setStringList(m_paths); m_ui->pathsView->setModel(m_pathsModel); m_ui->pathsView->setSelectionMode(QAbstractItemView::ExtendedSelection); connect(m_ui->pathsView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(handleSelectionChanged())); m_ui->addButton->setIcon(QIcon::fromTheme(QStringLiteral("list-add"))); m_ui->removeButton->setIcon(QIcon::fromTheme(QStringLiteral("list-remove"))); connect(m_ui->addButton, SIGNAL(clicked()), this, SLOT(add())); connect(m_ui->removeButton, SIGNAL(clicked()), this, SLOT(remove())); addPaths(paths); }
/**************************************************************************** ** ** Copyright (C) 2016 ** ** This file is generated by the Magus toolkit ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ****************************************************************************/ #include <QComboBox> #include <QStringListModel> #include <QLabel> #include <QHBoxLayout> #include <QGroupBox> #include <QLineEdit> #include "tb_transformationwidget.h" namespace Magus { //****************************************************************************/ TransformationWidget::TransformationWidget(QWidget* parent) : QWidget(parent) { selectionChanged = false; mPrecision = 2; mPosition = QVector3D(0, 0, 0); mRotation = QVector3D(0, 0, 0); mScale = QVector3D(0, 0, 0); mTransformation = POSITION; QHBoxLayout* transformationLayout = new QHBoxLayout; QHBoxLayout* xLayout = new QHBoxLayout; QHBoxLayout* yLayout = new QHBoxLayout; QHBoxLayout* zLayout = new QHBoxLayout; // Combobox QStringList list; list << QString("Position") << QString("Rotation") << QString("Scale"); mModel = new QStringListModel(list); mTransformationCombobox = new QComboBox(parent); mTransformationCombobox->setModel(mModel); mTransformationCombobox->setMaxVisibleItems(3); // X, Y, Z QString s; QLabel* xLabel = new QLabel(QString("<b>X</b>")); xLabel->setMaximumWidth(24); xLabel->setAutoFillBackground(true); xLabel->setStyleSheet("QLabel {background-color : rgb(255, 0, 0); margin-left: 0px; margin-right: 0px; spacing: 0px;}"); QRegExp regularExpression("[+-]?([0-9]+\\.([0-9]+)?|\\.[0-9]+)([eE][+-]?[0-9]+)?"); // floating point QRegExpValidator* validator = new QRegExpValidator(regularExpression); mXedit = new QLineEdit; mXedit->setValidator(validator); s = QVariant(mPosition.x()).toString(); s = s.left(getLeftStringIndex(s)); mXedit->setText(s); mXedit->setStyleSheet("QLineEdit {margin-right: 0px; margin-left: 5px; width: 32px; spacing: 0px;}"); QLabel* yLabel = new QLabel(QString("<b>Y</b>")); yLabel->setMaximumWidth(24); yLabel->setAutoFillBackground(true); yLabel->setStyleSheet("QLabel {background-color : rgb(0, 255, 0); margin-left: 0px; margin-right: 0px;}"); mYedit = new QLineEdit; mYedit->setValidator(validator); s = QVariant(mPosition.y()).toString(); s = s.left(getLeftStringIndex(s)); mYedit->setText(s); mYedit->setStyleSheet("QLineEdit {margin-right: 0px; margin-left: 0px; width: 32px; spacing: 0px;}"); QLabel* zLabel = new QLabel(QString("<b>Z</b>")); zLabel->setMaximumWidth(24); zLabel->setAutoFillBackground(true); zLabel->setStyleSheet("QLabel {background-color : rgb(100, 100, 255); margin-left: 0px; margin-right: 0px;}"); mZedit = new QLineEdit; mZedit->setValidator(validator); s = QVariant(mPosition.z()).toString(); s = s.left(getLeftStringIndex(s)); mZedit->setText(s); mZedit->setStyleSheet("QLineEdit {margin-right: 0px; margin-left: 0px; width: 32px; spacing: 0px;}"); // Layout transformationLayout->addWidget(mTransformationCombobox); xLayout->addWidget(xLabel, 0, Qt::AlignRight); xLayout->addWidget(mXedit, 100, Qt::AlignLeft); yLayout->addWidget(yLabel, 0, Qt::AlignRight); yLayout->addWidget(mYedit, 0, Qt::AlignLeft); zLayout->addWidget(zLabel, 0, Qt::AlignRight); zLayout->addWidget(mZedit, 0, Qt::AlignLeft); transformationLayout->addLayout(xLayout); transformationLayout->addLayout(yLayout); transformationLayout->addLayout(zLayout); setLayout(transformationLayout); connect(mTransformationCombobox, SIGNAL(currentIndexChanged(int)), this, SLOT(handleSelectionChanged(int))); connect(mXedit, SIGNAL(textEdited(const QString &)), this, SLOT(handleXchanged(const QString &))); connect(mYedit, SIGNAL(textEdited(const QString &)), this, SLOT(handleYchanged(const QString &))); connect(mZedit, SIGNAL(textEdited(const QString &)), this, SLOT(handleZchanged(const QString &))); } //****************************************************************************/ TransformationWidget::~TransformationWidget(void) { } //****************************************************************************/ void TransformationWidget::handleSelectionChanged(int index) { if (!mXedit || !mYedit || !mZedit) return; selectionChanged = true; QString s; unsigned int i; switch (index) { case 0: { mTransformation = POSITION; // Must be changed before the edit widgets are set s = QVariant(mPosition.x()).toString(); s = s.left(getLeftStringIndex(s)); mXedit->setText(s); s = QVariant(mPosition.y()).toString(); s = s.left(getLeftStringIndex(s)); mYedit->setText(s); s = QVariant(mPosition.z()).toString(); s = s.left(getLeftStringIndex(s)); mZedit->setText(s); } break; case 1: { mTransformation = ROTATION; // Must be changed before the edit widgets are set s = QVariant(mRotation.x()).toString(); s = s.left(getLeftStringIndex(s)); mXedit->setText(s); s = QVariant(mRotation.y()).toString(); s = s.left(getLeftStringIndex(s)); mYedit->setText(s); s = QVariant(mRotation.z()).toString(); s = s.left(getLeftStringIndex(s)); mZedit->setText(s); } break; case 2: { mTransformation = SCALE; // Must be changed before the edit widgets are set s = QVariant(mScale.x()).toString(); s = s.left(getLeftStringIndex(s)); mXedit->setText(s); s = QVariant(mScale.y()).toString(); s = s.left(getLeftStringIndex(s)); mYedit->setText(s); s = QVariant(mScale.z()).toString(); s = s.left(getLeftStringIndex(s)); mZedit->setText(s); } break; } selectionChanged = false; } //****************************************************************************/ void TransformationWidget::sync(void) { if (selectionChanged) return; if (!mXedit || !mYedit || !mZedit) return; float x = mXedit->text().toFloat(); float y = mYedit->text().toFloat(); float z = mZedit->text().toFloat(); switch (mTransformation) { case POSITION: { mPosition.setX(x); mPosition.setY(y); mPosition.setZ(z); } break; case ROTATION: { mRotation.setX(x); mRotation.setY(y); mRotation.setZ(z); } break; case SCALE: { mScale.setX(x); mScale.setY(y); mScale.setZ(z); } break; } emit valueChanged(); } //****************************************************************************/ void TransformationWidget::handleXchanged(const QString &x) { sync(); } //****************************************************************************/ void TransformationWidget::handleYchanged(const QString &y) { sync(); } //****************************************************************************/ void TransformationWidget::handleZchanged(const QString &z) { sync(); } //****************************************************************************/ const TransformationWidget::Transformation TransformationWidget::getCurrentTransformation(void) const { return mTransformation; } //****************************************************************************/ const QVector3D TransformationWidget::getCurrentXYZ(void) { switch (mTransformation) { case POSITION: { return mPosition; } break; case ROTATION: { return mRotation; } break; case SCALE: { return mScale; } break; } return mPosition; } //****************************************************************************/ const QVector3D TransformationWidget::getPosition(void) const { return mPosition; } //****************************************************************************/ const QVector3D TransformationWidget::getRotation(void) const { return mRotation; } //****************************************************************************/ const QVector3D TransformationWidget::getScale(void) const { return mScale; } //****************************************************************************/ void TransformationWidget::setPosition(const QVector3D& position) { mPosition = position; if (mTransformation == POSITION) handleSelectionChanged(0); } //****************************************************************************/ void TransformationWidget::setRotation(const QVector3D& rotation) { mRotation = rotation; if (mTransformation == ROTATION) handleSelectionChanged(1); } //****************************************************************************/ void TransformationWidget::setScale(const QVector3D& scale) { mScale = scale; if (mTransformation == SCALE) handleSelectionChanged(2); }
void PropertiesPalette_Shadow::unsetItem() { m_haveItem = false; m_item = NULL; handleSelectionChanged(); }
void Plotter::initPlugin(qt_gui_cpp::PluginContext& context) { m_w = new QWidget; m_ui = new Ui::Plotter; m_ui->setupUi(m_w); context.addWidget(m_w); m_plotModel = new PlotModel(this); m_plotModel->rootPlot()->setUsedSettings(&m_settings); m_plotFilter = new PlotFilterModel(this); m_plotFilter->setSourceModel(m_plotModel); new JointStatePlot(getNodeHandle(), m_plotModel->rootPlot()); // The created JointStatePlot gets deleted when the root plot does, or all of its child plots m_ui->plotView->setModel(m_plotFilter); m_ui->plotView->setDragEnabled(true); m_ui->plotView->setItemDelegateForColumn(PlotModel::COL_ENABLED, new CheckBoxDelegate); m_ui->plotView->setItemDelegateForColumn(PlotModel::COL_COLOR, new ColorDelegate); m_ui->plot->addPlot(m_plotModel->rootPlot()); connect(m_ui->pauseButton, SIGNAL(clicked(bool)), SLOT(handlePaused(bool))); connect(m_ui->playButton, SIGNAL(clicked(bool)), SLOT(handlePlay(bool))); connect(m_plotModel, SIGNAL(modelReset()), SLOT(updateTreeGeometry())); connect(m_ui->searchEdit, SIGNAL(textChanged(QString)), m_plotFilter, SLOT(setFilterRegExp(QString))); connect(m_ui->hideCheckBox, SIGNAL(clicked(bool)), m_plotFilter, SLOT(setHideDisabledPlots(bool))); m_sub_plot = getNodeHandle().subscribe("/plot", 100, &Plotter::plotDataReceived, this); qRegisterMetaType<plot_msgs::PlotConstPtr>("plot_msgs::PlotConstPtr"); connect(this, SIGNAL(plotDataReceived(plot_msgs::PlotConstPtr)), SLOT(handlePlotData(plot_msgs::PlotConstPtr)), Qt::QueuedConnection); m_sub_timewarpStatus = getNodeHandle().subscribe("/tw/control_status", 1, &Plotter::timewarpStatusReceived, this); qRegisterMetaType<timewarp::TimeWarpControlConstPtr>("timewarp::TimeWarpControlConstPtr"); connect(this, SIGNAL(timewarpStatusReceived(timewarp::TimeWarpControlConstPtr)), SLOT(handleTimewarpStatus(timewarp::TimeWarpControlConstPtr)), Qt::QueuedConnection); m_pub_timewarpControl = getNodeHandle().advertise<timewarp::TimeWarpControl>("/tw/control", 1); m_ui->plotView->installEventFilter(this); handleSelectionChanged(0.0, 0.0, false); connect(m_ui->plot, SIGNAL(timeChanged()), SLOT(updateTimeWarp())); connect(m_ui->plot, SIGNAL(stopPlaying()), SLOT(handleStopPlaying())); connect(m_ui->plot, SIGNAL(selectionChanged(double,double,bool)), SLOT(handleSelectionChanged(double,double,bool))); QMenu* menu = new QMenu(m_w); // Standard icon names: https://specifications.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html#names m_loadMenuAction = menu->addAction(QIcon::fromTheme("document-open"), "Load data", this, SLOT(load())); m_saveMenuAction = menu->addAction(QIcon::fromTheme("document-save"), "Save data", this, SLOT(save())); m_assignColoursAction = menu->addAction(QIcon::fromTheme("applications-graphics"), "Assign colours", this, SLOT(assignColours())); m_clearMenuAction = menu->addAction(QIcon::fromTheme("edit-delete"), "Clear data", this, SLOT(clear())); m_clearPlotMenuAction = menu->addAction(QIcon::fromTheme("edit-clear"), "Clear plot", this, SLOT(clearPlot())); m_refreshMenuAction = menu->addAction(QIcon::fromTheme("view-refresh"), "Refresh", this, SLOT(refresh())); m_ui->menuButton->setMenu(menu); connect(m_ui->pauseButton, SIGNAL(clicked(bool)), m_loadMenuAction, SLOT(setEnabled(bool))); connect(m_ui->pauseButton, SIGNAL(clicked(bool)), m_saveMenuAction, SLOT(setEnabled(bool))); m_loadMenuAction->setDisabled(true); m_saveMenuAction->setDisabled(true); m_io = new PlotIO(getNodeHandle(), m_plotModel->rootPlot(), this); connect(m_io, SIGNAL(progress(double)), SLOT(ioProgress(double))); m_progressDialog = new QProgressDialog(m_w); m_progressDialog->setLabelText(tr("I/O in progress")); m_progressDialog->setMinimum(0); m_progressDialog->setMaximum(100); m_progressDialog->setAutoClose(false); m_progressDialog->setAutoReset(false); m_progressDialog->setCancelButton(0); }
void MaemoRemoteProcessesDialog::handleProcessListUpdated() { m_ui->updateListButton->setEnabled(true); m_ui->tableView->resizeRowsToContents(); handleSelectionChanged(); }
void MaemoRemoteProcessesDialog::handleRemoteError(const QString &errorMsg) { QMessageBox::critical(this, tr("Remote Error"), errorMsg); m_ui->updateListButton->setEnabled(true); handleSelectionChanged(); }
/**************************************************************************** ** ** Copyright (C) 2016 ** ** This file is generated by the Magus toolkit ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ****************************************************************************/ #include <QComboBox> #include <QStringListModel> #include <QLabel> #include <QHBoxLayout> #include <QGroupBox> #include <QLineEdit> #include "tb_transformationwidget.h" namespace Magus { //****************************************************************************/ TransformationWidget::TransformationWidget(QWidget* parent) : QWidget(parent) { selectionChanged = false; mPrecision = 2; mPosition = QVector3D(0, 0, 0); mRotation = QVector3D(0, 0, 0); mScale = QVector3D(0, 0, 0); mTransformation = POSITION; QHBoxLayout* transformationLayout = new QHBoxLayout; QHBoxLayout* xLayout = new QHBoxLayout; QHBoxLayout* yLayout = new QHBoxLayout; QHBoxLayout* zLayout = new QHBoxLayout; // Combobox QStringList list; list << QString("Position") << QString("Rotation") << QString("Scale"); mModel = new QStringListModel(list); mTransformationCombobox = new QComboBox(parent); mTransformationCombobox->setModel(mModel); mTransformationCombobox->setMaxVisibleItems(3); // X, Y, Z QString s; QLabel* xLabel = new QLabel(QString("<b>X</b>")); xLabel->setMaximumWidth(24); xLabel->setAutoFillBackground(true); xLabel->setStyleSheet("QLabel {background-color : rgb(255, 0, 0); margin-left: 0px; margin-right: 0px; spacing: 0px;}"); QRegExp regularExpression("[+-]?([0-9]+\\.([0-9]+)?|\\.[0-9]+)([eE][+-]?[0-9]+)?"); // floating point QRegExpValidator* validator = new QRegExpValidator(regularExpression); mXedit = new QLineEdit; mXedit->setValidator(validator); s = QVariant(mPosition.x()).toString(); s = s.left(getLeftStringIndex(s)); mXedit->setText(s); mXedit->setStyleSheet("QLineEdit {margin-right: 0px; margin-left: 5px; width: 32px; spacing: 0px;}"); QLabel* yLabel = new QLabel(QString("<b>Y</b>")); yLabel->setMaximumWidth(24); yLabel->setAutoFillBackground(true); yLabel->setStyleSheet("QLabel {background-color : rgb(0, 255, 0); margin-left: 0px; margin-right: 0px;}"); mYedit = new QLineEdit; mYedit->setValidator(validator); s = QVariant(mPosition.y()).toString(); s = s.left(getLeftStringIndex(s)); mYedit->setText(s); mYedit->setStyleSheet("QLineEdit {margin-right: 0px; margin-left: 0px; width: 32px; spacing: 0px;}"); QLabel* zLabel = new QLabel(QString("<b>Z</b>")); zLabel->setMaximumWidth(24); zLabel->setAutoFillBackground(true); zLabel->setStyleSheet("QLabel {background-color : rgb(100, 100, 255); margin-left: 0px; margin-right: 0px;}"); mZedit = new QLineEdit; mZedit->setValidator(validator); s = QVariant(mPosition.z()).toString(); s = s.left(getLeftStringIndex(s)); mZedit->setText(s); mZedit->setStyleSheet("QLineEdit {margin-right: 0px; margin-left: 0px; width: 32px; spacing: 0px;}"); // Layout transformationLayout->addWidget(mTransformationCombobox); xLayout->addWidget(xLabel, 0, Qt::AlignRight); xLayout->addWidget(mXedit, 100, Qt::AlignLeft); yLayout->addWidget(yLabel, 0, Qt::AlignRight); yLayout->addWidget(mYedit, 0, Qt::AlignLeft); zLayout->addWidget(zLabel, 0, Qt::AlignRight); zLayout->addWidget(mZedit, 0, Qt::AlignLeft); transformationLayout->addLayout(xLayout); transformationLayout->addLayout(yLayout); transformationLayout->addLayout(zLayout); setLayout(transformationLayout); connect(mTransformationCombobox, SIGNAL(currentIndexChanged(int)), this, SLOT(handleSelectionChanged(int))); connect(mXedit, SIGNAL(textEdited(const QString &)), this, SLOT(handleXchanged(const QString &))); connect(mYedit, SIGNAL(textEdited(const QString &)), this, SLOT(handleYchanged(const QString &))); connect(mZedit, SIGNAL(textEdited(const QString &)), this, SLOT(handleZchanged(const QString &))); } //****************************************************************************/ TransformationWidget::~TransformationWidget(void) { } //****************************************************************************/ void TransformationWidget::handleSelectionChanged(int index) { if (!mXedit || !mYedit || !mZedit) return; selectionChanged = true; QString s; unsigned int i; switch (index) { case 0: { mTransformation = POSITION; // Must be changed before the edit widgets are set s = QVariant(mPosition.x()).toString(); s = s.left(getLeftStringIndex(s)); mXedit->setText(s); s = QVariant(mPosition.y()).toString(); s = s.left(getLeftStringIndex(s)); mYedit->setText(s); s = QVariant(mPosition.z()).toString(); s = s.left(getLeftStringIndex(s)); mZedit->setText(s); } break; case 1: { mTransformation = ROTATION; // Must be changed before the edit widgets are set s = QVariant(mRotation.x()).toString(); s = s.left(getLeftStringIndex(s)); mXedit->setText(s); s = QVariant(mRotation.y()).toString(); s = s.left(getLeftStringIndex(s)); mYedit->setText(s); s = QVariant(mRotation.z()).toString(); s = s.left(getLeftStringIndex(s)); mZedit->setText(s); } break; case 2: { mTransformation = SCALE; // Must be changed before the edit widgets are set s = QVariant(mScale.x()).toString(); s = s.left(getLeftStringIndex(s)); mXedit->setText(s); s = QVariant(mScale.y()).toString(); s = s.left(getLeftStringIndex(s)); mYedit->setText(s); s = QVariant(mScale.z()).toString(); s = s.left(getLeftStringIndex(s)); mZedit->setText(s); } break; } selectionChanged = false; } //****************************************************************************/ void TransformationWidget::sync(void) { if (selectionChanged) return; if (!mXedit || !mYedit || !mZedit) return; float x = mXedit->text().toFloat(); float y = mYedit->text().toFloat(); float z = mZedit->text().toFloat(); switch (mTransformation) { case POSITION: { mPosition.setX(x); mPosition.setY(y); mPosition.setZ(z); } break; case ROTATION: { mRotation.setX(x); mRotation.setY(y); mRotation.setZ(z); } break; case SCALE: { mScale.setX(x); mScale.setY(y); mScale.setZ(z); } break; } emit valueChanged(); } //****************************************************************************/ void TransformationWidget::handleXchanged(const QString &x) { sync(); } //****************************************************************************/ void TransformationWidget::handleYchanged(const QString &y) { sync(); } //****************************************************************************/ void TransformationWidget::handleZchanged(const QString &z) { sync(); } //****************************************************************************/ const TransformationWidget::Transformation TransformationWidget::getCurrentTransformation(void) const { return mTransformation; } //****************************************************************************/ const QVector3D TransformationWidget::getCurrentXYZ(void) { switch (mTransformation) { case POSITION: { return mPosition; } break; case ROTATION: { return mRotation; } break; case SCALE: { return mScale; } break; } return mPosition; } //****************************************************************************/ const QVector3D TransformationWidget::getPosition(void) const { return mPosition; } //****************************************************************************/ const QVector3D TransformationWidget::getRotation(void) const { return mRotation; } //****************************************************************************/ const QVector3D TransformationWidget::getScale(void) const { return mScale; } //****************************************************************************/ void TransformationWidget::setPosition(const QVector3D& position) { mPosition = position; if (mTransformation == POSITION) handleSelectionChanged(0); } //****************************************************************************/ void TransformationWidget::setRotation(const QVector3D& rotation) { mRotation = rotation; if (mTransformation == ROTATION) handleSelectionChanged(1); }
/**************************************************************************** ** ** Copyright (C) 2016 ** ** This file is generated by the Magus toolkit ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ****************************************************************************/ #include <QComboBox> #include <QStringListModel> #include <QLabel> #include <QHBoxLayout> #include <QGroupBox> #include <QLineEdit> #include "tb_transformationwidget.h" namespace Magus { //****************************************************************************/ TransformationWidget::TransformationWidget(QWidget* parent) : QWidget(parent) { selectionChanged = false; mPrecision = 2; mPosition = QVector3D(0, 0, 0); mRotation = QVector3D(0, 0, 0); mScale = QVector3D(0, 0, 0); mTransformation = POSITION; QHBoxLayout* transformationLayout = new QHBoxLayout; QHBoxLayout* xLayout = new QHBoxLayout; QHBoxLayout* yLayout = new QHBoxLayout; QHBoxLayout* zLayout = new QHBoxLayout; // Combobox QStringList list; list << QString("Position") << QString("Rotation") << QString("Scale"); mModel = new QStringListModel(list); mTransformationCombobox = new QComboBox(parent); mTransformationCombobox->setModel(mModel); mTransformationCombobox->setMaxVisibleItems(3); // X, Y, Z QString s; QLabel* xLabel = new QLabel(QString("<b>X</b>")); xLabel->setMaximumWidth(24); xLabel->setAutoFillBackground(true); xLabel->setStyleSheet("QLabel {background-color : rgb(255, 0, 0); margin-left: 0px; margin-right: 0px; spacing: 0px;}"); QRegExp regularExpression("[+-]?([0-9]+\\.([0-9]+)?|\\.[0-9]+)([eE][+-]?[0-9]+)?"); // floating point QRegExpValidator* validator = new QRegExpValidator(regularExpression); mXedit = new QLineEdit; mXedit->setValidator(validator); s = QVariant(mPosition.x()).toString(); s = s.left(getLeftStringIndex(s)); mXedit->setText(s); mXedit->setStyleSheet("QLineEdit {margin-right: 0px; margin-left: 5px; width: 32px; spacing: 0px;}"); QLabel* yLabel = new QLabel(QString("<b>Y</b>")); yLabel->setMaximumWidth(24); yLabel->setAutoFillBackground(true); yLabel->setStyleSheet("QLabel {background-color : rgb(0, 255, 0); margin-left: 0px; margin-right: 0px;}"); mYedit = new QLineEdit; mYedit->setValidator(validator); s = QVariant(mPosition.y()).toString(); s = s.left(getLeftStringIndex(s)); mYedit->setText(s); mYedit->setStyleSheet("QLineEdit {margin-right: 0px; margin-left: 0px; width: 32px; spacing: 0px;}"); QLabel* zLabel = new QLabel(QString("<b>Z</b>")); zLabel->setMaximumWidth(24); zLabel->setAutoFillBackground(true); zLabel->setStyleSheet("QLabel {background-color : rgb(100, 100, 255); margin-left: 0px; margin-right: 0px;}"); mZedit = new QLineEdit; mZedit->setValidator(validator); s = QVariant(mPosition.z()).toString(); s = s.left(getLeftStringIndex(s)); mZedit->setText(s); mZedit->setStyleSheet("QLineEdit {margin-right: 0px; margin-left: 0px; width: 32px; spacing: 0px;}"); // Layout transformationLayout->addWidget(mTransformationCombobox); xLayout->addWidget(xLabel, 0, Qt::AlignRight); xLayout->addWidget(mXedit, 100, Qt::AlignLeft); yLayout->addWidget(yLabel, 0, Qt::AlignRight); yLayout->addWidget(mYedit, 0, Qt::AlignLeft); zLayout->addWidget(zLabel, 0, Qt::AlignRight); zLayout->addWidget(mZedit, 0, Qt::AlignLeft); transformationLayout->addLayout(xLayout); transformationLayout->addLayout(yLayout); transformationLayout->addLayout(zLayout); setLayout(transformationLayout); connect(mTransformationCombobox, SIGNAL(currentIndexChanged(int)), this, SLOT(handleSelectionChanged(int))); connect(mXedit, SIGNAL(textEdited(const QString &)), this, SLOT(handleXchanged(const QString &))); connect(mYedit, SIGNAL(textEdited(const QString &)), this, SLOT(handleYchanged(const QString &))); connect(mZedit, SIGNAL(textEdited(const QString &)), this, SLOT(handleZchanged(const QString &))); } //****************************************************************************/ TransformationWidget::~TransformationWidget(void) { } //****************************************************************************/ void TransformationWidget::handleSelectionChanged(int index) { if (!mXedit || !mYedit || !mZedit) return; selectionChanged = true; QString s; unsigned int i; switch (index) { case 0: { mTransformation = POSITION; // Must be changed before the edit widgets are set s = QVariant(mPosition.x()).toString(); s = s.left(getLeftStringIndex(s)); mXedit->setText(s); s = QVariant(mPosition.y()).toString(); s = s.left(getLeftStringIndex(s)); mYedit->setText(s); s = QVariant(mPosition.z()).toString(); s = s.left(getLeftStringIndex(s)); mZedit->setText(s); } break; case 1: { mTransformation = ROTATION; // Must be changed before the edit widgets are set s = QVariant(mRotation.x()).toString(); s = s.left(getLeftStringIndex(s)); mXedit->setText(s); s = QVariant(mRotation.y()).toString(); s = s.left(getLeftStringIndex(s)); mYedit->setText(s); s = QVariant(mRotation.z()).toString(); s = s.left(getLeftStringIndex(s)); mZedit->setText(s); } break; case 2: { mTransformation = SCALE; // Must be changed before the edit widgets are set s = QVariant(mScale.x()).toString(); s = s.left(getLeftStringIndex(s)); mXedit->setText(s); s = QVariant(mScale.y()).toString(); s = s.left(getLeftStringIndex(s)); mYedit->setText(s); s = QVariant(mScale.z()).toString(); s = s.left(getLeftStringIndex(s)); mZedit->setText(s); } break; } selectionChanged = false; } //****************************************************************************/ void TransformationWidget::sync(void) { if (selectionChanged) return; if (!mXedit || !mYedit || !mZedit) return; float x = mXedit->text().toFloat(); float y = mYedit->text().toFloat(); float z = mZedit->text().toFloat(); switch (mTransformation) { case POSITION: { mPosition.setX(x); mPosition.setY(y); mPosition.setZ(z); } break; case ROTATION: { mRotation.setX(x); mRotation.setY(y); mRotation.setZ(z); } break; case SCALE: { mScale.setX(x); mScale.setY(y); mScale.setZ(z); } break; } emit valueChanged(); } //****************************************************************************/ void TransformationWidget::handleXchanged(const QString &x) { sync(); } //****************************************************************************/ void TransformationWidget::handleYchanged(const QString &y) { sync(); } //****************************************************************************/ void TransformationWidget::handleZchanged(const QString &z) { sync(); } //****************************************************************************/ const TransformationWidget::Transformation TransformationWidget::getCurrentTransformation(void) const { return mTransformation; } //****************************************************************************/ const QVector3D TransformationWidget::getCurrentXYZ(void) { switch (mTransformation) { case POSITION: { return mPosition; } break; case ROTATION: { return mRotation; } break; case SCALE: { return mScale; } break; } return mPosition; } //****************************************************************************/ const QVector3D TransformationWidget::getPosition(void) const { return mPosition; } //****************************************************************************/ const QVector3D TransformationWidget::getRotation(void) const { return mRotation; } //****************************************************************************/ const QVector3D TransformationWidget::getScale(void) const { return mScale; } //****************************************************************************/ void TransformationWidget::setPosition(const QVector3D& position) { mPosition = position; if (mTransformation == POSITION) handleSelectionChanged(0); }