From 5937d320270b546d7001963998293c1e15cf9ea2 Mon Sep 17 00:00:00 2001 From: tkawata Date: Wed, 30 Jan 2013 23:36:02 +0900 Subject: [PATCH] [denncoCreator] Implement plugin cell edit feature. The work is in progress. --- Source/dccontainer.cpp | 65 ++++++++++++- Source/dccontainer.h | 9 ++ Source/denncoCreator.pro | 6 +- Source/dialog/dcaddcelldialog.cpp | 106 ++++++++++++++++++--- Source/dialog/dcaddcelldialog.h | 5 + Source/engine/layer1/TKContainer.cpp | 25 ++++- Source/engine/layer1/TKContainer.h | 1 + Source/engine/layer1/dnplugininfo.cpp | 48 ++++++++++ Source/engine/layer1/dnplugininfo.h | 37 +++++++ Source/visualizer/component/dcvccell.cpp | 17 +++- .../visualizer/component/shape/dccuberenderer.cpp | 59 +++++++++--- Source/visualizer/component/shape/dccuberenderer.h | 3 +- Source/visualizer/dcscene.cpp | 30 +++--- 13 files changed, 362 insertions(+), 49 deletions(-) create mode 100644 Source/engine/layer1/dnplugininfo.cpp create mode 100644 Source/engine/layer1/dnplugininfo.h diff --git a/Source/dccontainer.cpp b/Source/dccontainer.cpp index dd506f2..5feb69e 100644 --- a/Source/dccontainer.cpp +++ b/Source/dccontainer.cpp @@ -100,6 +100,14 @@ bool DCContainer::isScriptableCell(DCCell *cell) const { noScript = false; } + else if (type == CELLTYPE_PLUGIN_IN) + { + noScript = false; + } + else if (type == CELLTYPE_PLUGIN_OUT) + { + noScript = false; + } else { Q_ASSERT(0); @@ -176,7 +184,7 @@ QList DCContainer::getSelectedCellObjects() const TKCell* DCContainer::addCell(std::string theLocation, std::string theName, std::string type, std::string customScript) { - QMutexLocker(d_scene->getSceneLock()); + QMutexLocker lock(d_scene->getSceneLock()); DCCell *cell = dynamic_cast(TKContainer::addCell(theLocation, theName, type, customScript)); @@ -187,7 +195,7 @@ TKCell* DCContainer::addCell(std::string theLocation, std::string theName, std:: TKCell* DCContainer::addCell(std::string theLocation, std::string theName, TKCellCode *cellCode, std::string customScript) { - QMutexLocker(d_scene->getSceneLock()); + QMutexLocker lock(d_scene->getSceneLock()); DCCell *cell = dynamic_cast(TKContainer::addCell(theLocation, theName, cellCode, customScript)); @@ -198,7 +206,7 @@ TKCell* DCContainer::addCell(std::string theLocation, std::string theName, TKCe TKCellCode* DCContainer::addCellCode(std::string theName, std::string theAPIType, std::string code) { - QMutexLocker(d_scene->getSceneLock()); + QMutexLocker lock(d_scene->getSceneLock()); DCCellCode *cellCode = dynamic_cast(TKContainer::addCellCode(theName, theAPIType, code)); @@ -225,6 +233,12 @@ TKCell* DCContainer::cellFactory(std::string location, std::string name, std::st return cell; } +TKCell* DCContainer::pluginCellFactory(std::string location, std::string fullName, std::string type, std::string pluginName, std::string pluginValue, bool canInterfaceIn, bool canInterfaceOut) +{ + return cellFactory(location, fullName, type, canInterfaceIn, canInterfaceOut ); +} + + TKAxon* DCContainer::axonFactory(TKCell *theOwner) { return DCComponentUtil::createAxon((DCCell*)theOwner); @@ -687,3 +701,48 @@ QString DCContainer::getWorkFilePathForCellCode(const DCCellCode *cellCode) cons QDir workdir(d_workDirCellCodeRoot + path); return workdir.absoluteFilePath(name + ".js"); } + +bool DCContainer::getIsPluginType(const QString &type) const +{ + std::string t = type.toStdString(); + + if (t == TKContainer::CELLTYPE_PLUGIN_IN) + { + return true; + } + else if (t == TKContainer::CELLTYPE_PLUGIN_OUT) + { + return true; + } + + return false; +} + +QList DCContainer::getAvailablePluginLibraries() const +{ + QList list; + return list; +} + +QList DCContainer::getPreDefinedPluginVariablesForPlugin(const QString& libraryName) const +{ + QList list; + return list; +} + +QString DCContainer::createPluginCellName(const QString &name, const QString& type, const QString &libraryName) +{ + QString cellName = name; + + if (type == QString::fromStdString(TKContainer::CELLTYPE_PLUGIN_IN)) + { + cellName += "@@"; + cellName += libraryName; + } + else if (type == QString::fromStdString(TKContainer::CELLTYPE_PLUGIN_OUT)) + { + cellName += "@"; + cellName += libraryName; + } + return cellName; +} diff --git a/Source/dccontainer.h b/Source/dccontainer.h index 4e5f6b3..dd00c9e 100644 --- a/Source/dccontainer.h +++ b/Source/dccontainer.h @@ -69,6 +69,7 @@ public: virtual TKCellCode* addCellCode(std::string theName, std::string theAPIType, std::string code); virtual TKCell* cellFactory(std::string location, std::string name, std::string type, bool canInterfaceIn, bool canInterfaceOut); + virtual TKCell* pluginCellFactory(std::string location, std::string fullName, std::string type, std::string pluginName, std::string pluginValue, bool canInterfaceIn, bool canInterfaceOut); virtual TKAxon* axonFactory(TKCell *theOwner); virtual TKReceptor* receptorFactory(TKCell *theOwner); virtual TKAxonTerminal* axonTerminalFactory(TKAxon *theOwner); @@ -184,6 +185,14 @@ public: */ bool getIsReceptorAvailable(const QString& type) const; + /*************************************************************************** + * plugin rules + **************************************************************************/ + + bool getIsPluginType(const QString& type) const; + QList getAvailablePluginLibraries() const; + QList getPreDefinedPluginVariablesForPlugin(const QString& libraryName) const; + QString createPluginCellName(const QString& name, const QString& type, const QString& libraryName); }; #endif // DCCONTAINER_H diff --git a/Source/denncoCreator.pro b/Source/denncoCreator.pro index d52088e..2d7b363 100644 --- a/Source/denncoCreator.pro +++ b/Source/denncoCreator.pro @@ -103,7 +103,8 @@ HEADERS = mainwindow.h \ codeeditor/dceditscriptfolder.h \ codeeditor/dccodeeditorscriptmanager.h \ dialog/dccodeeditorexternaleditorsettingdialog.h \ - cellcodescripttreeview/dccellcodescripttreeviewwidget.h + cellcodescripttreeview/dccellcodescripttreeviewwidget.h \ + engine/layer1/dnplugininfo.h SOURCES = main.cpp \ mainwindow.cpp \ @@ -200,7 +201,8 @@ SOURCES = main.cpp \ codeeditor/dceditscriptfolder.cpp \ codeeditor/dccodeeditorscriptmanager.cpp \ dialog/dccodeeditorexternaleditorsettingdialog.cpp \ - cellcodescripttreeview/dccellcodescripttreeviewwidget.cpp + cellcodescripttreeview/dccellcodescripttreeviewwidget.cpp \ + engine/layer1/dnplugininfo.cpp RESOURCES = denncoCreator.qrc diff --git a/Source/dialog/dcaddcelldialog.cpp b/Source/dialog/dcaddcelldialog.cpp index 82c1c38..e482786 100644 --- a/Source/dialog/dcaddcelldialog.cpp +++ b/Source/dialog/dcaddcelldialog.cpp @@ -46,6 +46,8 @@ d_comboBox = new QComboBox; d_comboBox->addItems(QStringList(d_container->getAvailableCellTypes())); + d_pluginLibraryNameComboBox = new QComboBox; + d_pluginLibraryNameComboBox->setEditable(true); DCScene *scene = container->getScene(); const QMap *pages = scene->getPages(); @@ -75,11 +77,19 @@ d_cancelButton->setAutoDefault(true); d_cancelButton->setDefault(true); + d_pluginInputBox = new QGroupBox(); + QHBoxLayout *pluginInfoLayout = new QHBoxLayout; + pluginInfoLayout->addWidget(new QLabel(tr("Plugin"))); + pluginInfoLayout->addWidget(d_pluginLibraryNameComboBox); + d_pluginInputBox->setLayout(pluginInfoLayout); + d_pluginInputBox->setVisible(false); + QGridLayout *glayout = new QGridLayout; glayout->addWidget(new QLabel(tr("name")),0,0); glayout->addWidget(d_textField,0,1); glayout->addWidget(new QLabel(tr("type")),1,0); - glayout->addWidget(d_comboBox); + glayout->addWidget(d_comboBox, 1, 1); + glayout->addWidget(d_pluginInputBox, 2,0,1,2); ((QVBoxLayout*)layout())->addLayout(glayout); layout()->addWidget(d_table); d_statusText = new QLabel; @@ -94,6 +104,8 @@ connect(d_cancelButton, SIGNAL(clicked()), this, SLOT(cancelButtonClicked())); connect(d_table,SIGNAL(selectionChangedSignal(QItemSelection,QItemSelection)), this, SLOT(listSelectionChanged(QItemSelection,QItemSelection))); connect(d_creator, SIGNAL(commandExecuted(const QUndoCommand*)), this, SLOT(commandExecuted(const QUndoCommand*))); + connect(d_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(selectedTypeChanged(int))); + connect(d_pluginLibraryNameComboBox, SIGNAL(editTextChanged(QString)), this, SLOT(pluginNameChanged(QString))); if (selection >= 0) { @@ -111,35 +123,67 @@ DCAddCellDialog::~DCAddCellDialog() bool DCAddCellDialog::checkInput() { + bool valid = true; + d_message->setText(""); d_statusText->setText(""); if (d_selectedPagePath.length() == 0) { d_message->setText(tr("Select a page to place the cell")); + valid = false; } else if (d_textField->text().length() > 0) { - std::string path = getFQNString(d_selectedPagePath.toLocal8Bit().data(), d_textField->text().toLocal8Bit().data()); - TKCell *cell = d_container->getCell(path); - if (cell) + QString name; + if (d_container->getIsPluginType(d_comboBox->currentText())) { - d_message->setText(tr("The cell name exists")); + if (d_pluginLibraryNameComboBox->currentText().length() == 0) + { + d_message->setText(tr("Input plugin name")); + valid = false; + } + else + { + name = d_container->createPluginCellName(d_textField->text(), d_comboBox->currentText(),d_pluginLibraryNameComboBox->currentText()); + } } else { - d_statusText->setText(QString::fromStdString(path)); - d_okButton->setEnabled(true); - d_okButton->setDefault(true); - return true; + name = d_textField->text(); + } + + if (valid) + { + std::string path = getFQNString(d_selectedPagePath.toLocal8Bit().data(), name.toLocal8Bit().data()); + TKCell *cell = d_container->getCell(path); + if (cell) + { + d_message->setText(tr("The cell name exists")); + valid = false; + } + else + { + d_statusText->setText(QString::fromStdString(path)); + } } } else { d_message->setText(tr("Input cell name")); + valid = false; } - d_okButton->setEnabled(false); - d_cancelButton->setDefault(true); - return false; + + if (valid) + { + d_okButton->setEnabled(true); + d_okButton->setDefault(true); + } + else + { + d_okButton->setEnabled(false); + d_cancelButton->setDefault(true); + } + return valid; } void DCAddCellDialog::textInputChanged(const QString &text) @@ -153,9 +197,19 @@ void DCAddCellDialog::okButtonClicked() { if (checkInput()) { - d_creator->doCommandAddCell(this, d_container, d_selectedPagePath, d_textField->text(), d_comboBox->currentText(), d_pageX, d_pageY); - } + QString name; + if (d_container->getIsPluginType(d_comboBox->currentText())) + { + Q_ASSERT(d_pluginLibraryNameComboBox->currentText().length() > 0); + name = d_container->createPluginCellName(d_textField->text(), d_comboBox->currentText(),d_pluginLibraryNameComboBox->currentText()); + } + else + { + name = d_textField->text(); + } + d_creator->doCommandAddCell(this, d_container, d_selectedPagePath, name, d_comboBox->currentText(), d_pageX, d_pageY); + } } void DCAddCellDialog::cancelButtonClicked() @@ -179,6 +233,29 @@ void DCAddCellDialog::listSelectionChanged(const QItemSelection &selected, const checkInput(); } +void DCAddCellDialog::selectedTypeChanged(int index) +{ + (void)index; + + if (d_container->getIsPluginType(d_comboBox->currentText())) + { + d_pluginInputBox->setVisible(true); + d_pluginLibraryNameComboBox->clear(); + d_pluginLibraryNameComboBox->addItems(d_container->getAvailablePluginLibraries()); + } + else + { + d_pluginInputBox->setVisible(false); + } + checkInput(); +} + +void DCAddCellDialog::pluginNameChanged(const QString &text) +{ + (void)text; + checkInput(); +} + void DCAddCellDialog::commandExecuted(const QUndoCommand *executedCommand) { const DCCommand *command = dynamic_cast(executedCommand); @@ -187,3 +264,4 @@ void DCAddCellDialog::commandExecuted(const QUndoCommand *executedCommand) done(true); } } + diff --git a/Source/dialog/dcaddcelldialog.h b/Source/dialog/dcaddcelldialog.h index de0ebc0..e3731ac 100644 --- a/Source/dialog/dcaddcelldialog.h +++ b/Source/dialog/dcaddcelldialog.h @@ -23,6 +23,7 @@ #include #include #include +#include #include class DCContainer; @@ -46,6 +47,8 @@ private: QLineEdit *d_textField; QLabel *d_statusText; QLabel *d_message; + QGroupBox *d_pluginInputBox; + QComboBox *d_pluginLibraryNameComboBox; float d_pageX; float d_pageY; @@ -63,6 +66,8 @@ private slots: void okButtonClicked(); void cancelButtonClicked(); void listSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected); + void selectedTypeChanged(int index); + void pluginNameChanged(const QString& text); void commandExecuted(const QUndoCommand* executedCommand); }; diff --git a/Source/engine/layer1/TKContainer.cpp b/Source/engine/layer1/TKContainer.cpp index 8cf1e6d..121b274 100644 --- a/Source/engine/layer1/TKContainer.cpp +++ b/Source/engine/layer1/TKContainer.cpp @@ -22,6 +22,7 @@ #include "TKCellCode.h" #include "DNStorage.h" #include "DNUtils.h" +#include "dnplugininfo.h" #include @@ -164,12 +165,32 @@ TKCell* TKContainer::addCell(std::string theLocation, std::string theName, std:: } else if (type == CELLTYPE_PLUGIN_IN) { - cell = cellFactory(theLocation, theName, type, true, false); + DNPluginInfo info = DNPluginInfo::create(theName); + if (info.isValid) + { + cell = pluginCellFactory(theLocation, theName, type, info.pluginName, info.pluginValueName, true, false); + } + else + { + std::string message = std::string("Failed to initialize cell '").append(theLocation).append("#").append(theName); + message.append("'\nThis is a plugin input cell. The name of the cell should be described by following form:\n'pluginValueName'@'pluginName'"); + dnNotifyError("Initialization failed", message); + } noScript = true; } else if (type == CELLTYPE_PLUGIN_OUT) { - cell = cellFactory(theLocation, theName, type, false, true); + DNPluginInfo info = DNPluginInfo::create(theName); + if (info.isValid) + { + cell = pluginCellFactory(theLocation, theName, type, info.pluginName, info.pluginValueName, false, true); + } + else + { + std::string message = std::string("Failed to initialize cell '").append(theLocation).append("#").append(theName); + message.append("'\nThis is a plugin output cell. The name of the cell should be described by following form:\n'pluginValueName'@'pluginName'"); + dnNotifyError("Initialization failed", message); + } noScript = true; } else diff --git a/Source/engine/layer1/TKContainer.h b/Source/engine/layer1/TKContainer.h index 36b704c..4a1eb89 100644 --- a/Source/engine/layer1/TKContainer.h +++ b/Source/engine/layer1/TKContainer.h @@ -80,6 +80,7 @@ public: inline virtual float getValue(std::string key) const = 0; virtual TKCell* cellFactory(std::string location, std::string name, std::string type, bool canInterfaceIn, bool canInterfaceOut) = 0; + virtual TKCell* pluginCellFactory(std::string location, std::string fullName, std::string type, std::string pluginName, std::string pluginValue, bool canInterfaceIn, bool canInterfaceOut) = 0; virtual TKAxon* axonFactory(TKCell *theOwner) = 0; virtual TKReceptor* receptorFactory(TKCell *theOwner) = 0; virtual TKAxonTerminal* axonTerminalFactory(TKAxon *theOwner) = 0; diff --git a/Source/engine/layer1/dnplugininfo.cpp b/Source/engine/layer1/dnplugininfo.cpp new file mode 100644 index 0000000..83deb1a --- /dev/null +++ b/Source/engine/layer1/dnplugininfo.cpp @@ -0,0 +1,48 @@ +// Copyright (c) 2013 Dennco Project +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// +// Created by tkawata on 1/29/2013. +// + +#include "dnplugininfo.h" +#include "DNUtils.h" + +DNPluginInfo::DNPluginInfo() +{ + isValid = false; +} + +DNPluginInfo::DNPluginInfo(const DNPluginInfo &other) +{ + isValid = other.isValid; + pluginName = other.pluginName; + pluginValueName = other.pluginValueName; +} + +//static +DNPluginInfo DNPluginInfo::create(const std::string &name) +{ + DNPluginInfo result; + unsigned int idx = name.find("@"); + if (idx != std::string::npos && idx > 0 && idx + 1 < name.length()) + { + result.isValid = true; + result.pluginValueName = name.substr(0,idx); + result.pluginName = name.substr(name.find_last_of("@")+1); + } + + return result; +} diff --git a/Source/engine/layer1/dnplugininfo.h b/Source/engine/layer1/dnplugininfo.h new file mode 100644 index 0000000..570ea3e --- /dev/null +++ b/Source/engine/layer1/dnplugininfo.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 Dennco Project +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// +// Created by tkawata on 1/29/2013. +// + +#ifndef DNPLUGININFO_H +#define DNPLUGININFO_H + +#include + +struct DNPluginInfo +{ + DNPluginInfo(); + DNPluginInfo(const DNPluginInfo &other); + + std::string pluginName; + std::string pluginValueName; + bool isValid; + + static DNPluginInfo create(const std::string& name); +}; + +#endif // DNPLUGININFO_H diff --git a/Source/visualizer/component/dcvccell.cpp b/Source/visualizer/component/dcvccell.cpp index 523d566..1afeaf9 100644 --- a/Source/visualizer/component/dcvccell.cpp +++ b/Source/visualizer/component/dcvccell.cpp @@ -24,6 +24,7 @@ #include "dcreceptor.h" #include "dccontainer.h" #include "dcscene.h" +#include "dnplugininfo.h" #include "dccuberenderer.h" #include "dcselectionrenderer.h" @@ -244,7 +245,21 @@ void DCVCCell::renderOwnShape(bool isAnimationInterval, bool renderAsWireframe) } QString label2 = QString::fromStdString(d_owner->getName()); - d_shape->setTextLabel(label1, label2); + QString label3 = ""; + DCContainer *container = dynamic_cast (d_owner->getContainer()); + if (container) + { + if (container->getIsPluginType(d_owner->getType())) + { + DNPluginInfo info = DNPluginInfo::create(d_owner->getName()); + if (info.isValid) + { + label2 = QString::fromStdString(info.pluginValueName); + label3 = " (" + QString::fromStdString(info.pluginName) +") "; + } + } + } + d_shape->setTextLabel(label1, label2, label3); d_shouldUpdateShape = false; } diff --git a/Source/visualizer/component/shape/dccuberenderer.cpp b/Source/visualizer/component/shape/dccuberenderer.cpp index 58229b7..363994e 100644 --- a/Source/visualizer/component/shape/dccuberenderer.cpp +++ b/Source/visualizer/component/shape/dccuberenderer.cpp @@ -210,15 +210,16 @@ void DCCubeRenderer::setFaceColor(GLfloat r, GLfloat g, GLfloat b) m_shapeUpdated = true; } -void DCCubeRenderer::setTextLabel(const QString &text1, const QString &text2) +void DCCubeRenderer::setTextLabel(const QString &text1, const QString &text2, const QString &text3) { QString newText1 = " " + text1 + " "; QString newText2 = " " + text2 + " "; - if (newText1 != m_text1 || newText2 != m_text2) + if (newText1 != m_text1 || newText2 != m_text2 || text3 != m_text3) { m_text1 = newText1; m_text2 = newText2; + m_text3 = text3; m_shapeUpdated = true; } } @@ -274,30 +275,49 @@ void DCCubeRenderer::buildTextures() painter.setBrush(QBrush(QColor(m_faceColor[0]*255, m_faceColor[1]*255, m_faceColor[2]*255))); painter.drawRoundedRect(0,0, texSize, texSize, r,r); + float text1Rate = m_text3.length() > 0 ? 0.3 : 0.4; + float text2Rate = m_text3.length() > 0 ? 0.4 : 0.6; + QFont font; font.setPointSize(22); font.setItalic(true); painter.setPen(Qt::black); painter.setFont(font); - QRectF rect = painter.boundingRect(0,0,image.width(), image.height()*0.4, Qt::AlignCenter | Qt::TextDontClip, m_text1); + QRectF rect = painter.boundingRect(0,0,image.width(), image.height()*text1Rate, Qt::AlignCenter | Qt::TextDontClip, m_text1); if (rect.width() > image.rect().width()) { font.setPointSizeF(22*(image.rect().width()/rect.width())); painter.setFont(font); } - painter.drawText(0,0,image.width(),image.height()*0.4, Qt::AlignCenter | Qt::TextDontClip, m_text1); + painter.drawText(0,0,image.width(),image.height()*text1Rate, Qt::AlignCenter | Qt::TextDontClip, m_text1); + font.setPointSize(48); font.setItalic(false); painter.setPen(Qt::black); painter.setFont(font); - rect = painter.boundingRect(0,0,image.width(), image.height()*0.6, Qt::AlignCenter | Qt::TextDontClip, m_text2); + rect = painter.boundingRect(0,0,image.width(), image.height()*text2Rate, Qt::AlignCenter | Qt::TextDontClip, m_text2); if (rect.width() > image.rect().width()) { font.setPointSizeF(48*(image.rect().width()/rect.width())); painter.setFont(font); } - painter.drawText(0, image.height()*0.4, image.width(), image.height()*0.6, Qt::AlignCenter | Qt::TextDontClip, m_text2); + painter.drawText(0, image.height()*text1Rate, image.width(), image.height()*text2Rate, Qt::AlignCenter | Qt::TextDontClip, m_text2); + + if (m_text3.length() > 0) + { + font.setPointSize(22); + font.setItalic(false); + painter.setPen(Qt::black); + painter.setFont(font); + rect = painter.boundingRect(0,0,image.width(), image.height()*0.2, Qt::AlignCenter | Qt::TextDontClip, m_text3); + if (rect.width() > image.rect().width()) + { + font.setPointSizeF(22*(image.rect().width()/rect.width())); + painter.setFont(font); + } + painter.drawText(0, image.height()*0.7, image.width(), image.height()*0.2, Qt::AlignCenter | Qt::TextDontClip, m_text3); + } GLuint texture = m_widget->bindTexture(image, GL_TEXTURE_2D,GL_RGBA,QGLContext::LinearFilteringBindOption|QGLContext::InvertedYBindOption); @@ -334,32 +354,49 @@ void DCCubeRenderer::buildTextures() painter.setBrush(QBrush(QColor(m_faceColor[0]*255, m_faceColor[1]*255, m_faceColor[2]*255))); painter.drawRoundedRect(0,0, texSize_w, texSize_h, r_w, r_h); + float text1Rate = m_text3.length() > 0 ? 0.3 : 0.4; + float text2Rate = m_text3.length() > 0 ? 0.4 : 0.6; + QFont font; font.setPointSize(22); font.setItalic(true); painter.setPen(Qt::black); painter.setFont(font); - QRectF rect = painter.boundingRect(0,0,image.width(), image.height()*0.4, Qt::AlignCenter | Qt::TextDontClip, m_text1); + QRectF rect = painter.boundingRect(0,0,image.width(), image.height()*text1Rate, Qt::AlignCenter | Qt::TextDontClip, m_text1); if (rect.width() > image.rect().width()) { font.setPointSizeF(22*(image.rect().width()/rect.width())); painter.setFont(font); } - painter.drawText(0,0,image.width(), image.height()*0.4, Qt::AlignCenter | Qt::TextDontClip, m_text1); + painter.drawText(0,0,image.width(),image.height()*text1Rate, Qt::AlignCenter | Qt::TextDontClip, m_text1); + font.setPointSize(48); font.setItalic(false); painter.setPen(Qt::black); painter.setFont(font); - rect = painter.boundingRect(0,0,image.width(), image.height()*0.6, Qt::AlignCenter | Qt::TextDontClip, m_text2); + rect = painter.boundingRect(0,0,image.width(), image.height()*text2Rate, Qt::AlignCenter | Qt::TextDontClip, m_text2); if (rect.width() > image.rect().width()) { font.setPointSizeF(48*(image.rect().width()/rect.width())); painter.setFont(font); } - painter.drawText(0,image.height()*0.4,image.width(), image.height()*0.6, Qt::AlignCenter | Qt::TextDontClip, m_text2); + painter.drawText(0, image.height()*text1Rate, image.width(), image.height()*text2Rate, Qt::AlignCenter | Qt::TextDontClip, m_text2); - painter.end(); + if (m_text3.length() > 0) + { + font.setPointSize(22); + font.setItalic(false); + painter.setPen(Qt::black); + painter.setFont(font); + rect = painter.boundingRect(0,0,image.width(), image.height()*0.2, Qt::AlignCenter | Qt::TextDontClip, m_text3); + if (rect.width() > image.rect().width()) + { + font.setPointSizeF(22*(image.rect().width()/rect.width())); + painter.setFont(font); + } + painter.drawText(0, image.height()*0.7, image.width(), image.height()*0.2, Qt::AlignCenter | Qt::TextDontClip, m_text3); + } GLuint texture = m_widget->bindTexture(image, GL_TEXTURE_2D,GL_RGBA,QGLContext::LinearFilteringBindOption|QGLContext::InvertedYBindOption); diff --git a/Source/visualizer/component/shape/dccuberenderer.h b/Source/visualizer/component/shape/dccuberenderer.h index 0688aec..bd4d3cc 100644 --- a/Source/visualizer/component/shape/dccuberenderer.h +++ b/Source/visualizer/component/shape/dccuberenderer.h @@ -44,7 +44,7 @@ public: void draw(); void setEdgeColor(GLfloat r, GLfloat g, GLfloat b); void setFaceColor(GLfloat r, GLfloat g, GLfloat b); - void setTextLabel(const QString &text1, const QString &text2); + void setTextLabel(const QString &text1, const QString &text2, const QString &text3 = ""); void setSize(float size); void setHeight(float height); @@ -75,6 +75,7 @@ private: QString m_text1; QString m_text2; + QString m_text3; }; diff --git a/Source/visualizer/dcscene.cpp b/Source/visualizer/dcscene.cpp index 6f6908b..5a9973a 100644 --- a/Source/visualizer/dcscene.cpp +++ b/Source/visualizer/dcscene.cpp @@ -88,7 +88,7 @@ bool DCScene::getIsModified() const DCVCPage* DCScene::getPage(const std::string &location) const { - DNLocker(getSceneLock()); + QMutexLocker locker(getSceneLock()); QMap::const_iterator i = d_pages.find(QString::fromStdString(location)); if (i != d_pages.end()) @@ -105,7 +105,7 @@ bool DCScene::getIsPageExist(const std::string &location) const bool DCScene::getIsPageExist(const QString &location) const { - DNLocker(getSceneLock()); + QMutexLocker locker(getSceneLock()); QMap::const_iterator i = d_pages.find(location); return i != d_pages.end(); @@ -124,7 +124,7 @@ QString DCScene::getSceneSettingFilePathForPage(const QString &containerRootPath DCVCPage* DCScene::addPage(const std::string &location) { - DNLocker(getSceneLock()); + QMutexLocker locker(getSceneLock()); QString qlocation = QString::fromStdString(location); QMap::const_iterator i = d_pages.find(qlocation); if (i != d_pages.end()) @@ -139,7 +139,7 @@ DCVCPage* DCScene::addPage(const std::string &location) bool DCScene::removePage(DCVCPage *page) { - DNLocker(getSceneLock()); + QMutexLocker locker(getSceneLock()); bool removed = false; QMap::Iterator it = d_pages.begin(); while(it != d_pages.end()) @@ -186,7 +186,7 @@ void DCScene::setPageModeCenter(const void *requester, float cx, float cy) bool DCScene::selectPage(const void *requester, const DCVCPage *page, bool multipleSelection) { - DNLocker(getSceneLock()); + QMutexLocker locker(getSceneLock()); bool pageFound = false; QMapIterator i(d_pages); @@ -213,7 +213,7 @@ bool DCScene::selectPage(const void *requester, const DCVCPage *page, bool multi bool DCScene::unselectPage(const void *requester, const DCVCPage *page) { - DNLocker(getSceneLock()); + QMutexLocker locker(getSceneLock()); bool pageFound = false; QMapIterator i(d_pages); @@ -236,7 +236,7 @@ bool DCScene::unselectPage(const void *requester, const DCVCPage *page) bool DCScene::selectPage(const void *requester, const QString &locationPath, bool multipleSelection) { - DNLocker(getSceneLock()); + QMutexLocker locker(getSceneLock()); bool pageFound = false; QMapIterator i(d_pages); @@ -263,7 +263,7 @@ bool DCScene::selectPage(const void *requester, const QString &locationPath, boo bool DCScene::unselectPage(const void *requester, const QString &locationPath) { - DNLocker(getSceneLock()); + QMutexLocker locker(getSceneLock()); bool pageFound = false; QMapIterator i(d_pages); @@ -286,7 +286,7 @@ bool DCScene::unselectPage(const void *requester, const QString &locationPath) bool DCScene::unselectPageAll(const void *requester) { - DNLocker(getSceneLock()); + QMutexLocker locker(getSceneLock()); QMapIterator i(d_pages); while (i.hasNext()) @@ -301,7 +301,7 @@ bool DCScene::unselectPageAll(const void *requester) void DCScene::selectCellObject(const void *requester, DCVComponent *object, bool multipleSelection) { - DNLocker(getSceneLock()); + QMutexLocker locker(getSceneLock()); bool objectSelected = false; bool otherObjectSelected = false; @@ -337,7 +337,7 @@ void DCScene::selectCellObject(const void *requester, DCVComponent *object, bool void DCScene::unselectCellObject(const void *requester, DCVComponent *object) { - DNLocker(getSceneLock()); + QMutexLocker locker(getSceneLock()); if (!object->getIsSelected()) { @@ -352,7 +352,7 @@ void DCScene::unselectCellObject(const void *requester, DCVComponent *object) void DCScene::unselectCellObjectAll(const void *requester) { - DNLocker(getSceneLock()); + QMutexLocker locker(getSceneLock()); QList list = d_owner->getSelectedCellObjects(); if (list.size() == 0) @@ -368,7 +368,7 @@ void DCScene::unselectCellObjectAll(const void *requester) int DCScene::getNumberOfSelectedPages() const { - DNLocker(getSceneLock()); + QMutexLocker locker(getSceneLock()); int cnt = 0; QMapIterator i(d_pages); while (i.hasNext()) @@ -384,7 +384,7 @@ QList DCScene::getSelectedPages() const { QList list; - DNLocker(getSceneLock()); + QMutexLocker locker(getSceneLock()); QMapIterator i(d_pages); while (i.hasNext()) { @@ -397,7 +397,7 @@ QList DCScene::getSelectedPages() const QList DCScene::getSelectedCellObjects() const { - DNLocker(getSceneLock()); + QMutexLocker lockr(getSceneLock()); return d_owner->getSelectedCellObjects(); } -- 2.11.0