OSDN Git Service

[denncoCreator] Implement plugin cell edit feature. The work is in progress.
authortkawata <tkawata@users.sourceforge.jp>
Wed, 30 Jan 2013 14:36:02 +0000 (23:36 +0900)
committertkawata <tkawata@users.sourceforge.jp>
Wed, 30 Jan 2013 14:36:02 +0000 (23:36 +0900)
13 files changed:
Source/dccontainer.cpp
Source/dccontainer.h
Source/denncoCreator.pro
Source/dialog/dcaddcelldialog.cpp
Source/dialog/dcaddcelldialog.h
Source/engine/layer1/TKContainer.cpp
Source/engine/layer1/TKContainer.h
Source/engine/layer1/dnplugininfo.cpp [new file with mode: 0644]
Source/engine/layer1/dnplugininfo.h [new file with mode: 0644]
Source/visualizer/component/dcvccell.cpp
Source/visualizer/component/shape/dccuberenderer.cpp
Source/visualizer/component/shape/dccuberenderer.h
Source/visualizer/dcscene.cpp

index dd506f2..5feb69e 100644 (file)
@@ -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<DCVComponent*> 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<DCCell*>(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<DCCell*>(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<DCCellCode*>(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<QString> DCContainer::getAvailablePluginLibraries() const
+{
+    QList<QString> list;
+    return list;
+}
+
+QList<QString> DCContainer::getPreDefinedPluginVariablesForPlugin(const QString& libraryName) const
+{
+    QList<QString> 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;
+}
index 4e5f6b3..dd00c9e 100644 (file)
@@ -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<QString>          getAvailablePluginLibraries() const;
+    QList<QString>          getPreDefinedPluginVariablesForPlugin(const QString& libraryName) const;
+    QString                 createPluginCellName(const QString& name, const QString& type, const QString& libraryName);
 };
 
 #endif // DCCONTAINER_H
index d52088e..2d7b363 100644 (file)
@@ -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
 
index 82c1c38..e482786 100644 (file)
@@ -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<QString,DCVCPage*> *pages = scene->getPages();
     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;
     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<const DCCommand*>(executedCommand);
@@ -187,3 +264,4 @@ void DCAddCellDialog::commandExecuted(const QUndoCommand *executedCommand)
         done(true);
     }
 }
+
index de0ebc0..e3731ac 100644 (file)
@@ -23,6 +23,7 @@
 #include <QTableView>
 #include <QComboBox>
 #include <QLabel>
+#include <QGroupBox>
 #include <QUndoCommand>
 
 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);
 
 };
index 8cf1e6d..121b274 100644 (file)
@@ -22,6 +22,7 @@
 #include "TKCellCode.h"
 #include "DNStorage.h"
 #include "DNUtils.h"
+#include "dnplugininfo.h"
 
 #include <string>
 
@@ -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
index 36b704c..4a1eb89 100644 (file)
@@ -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 (file)
index 0000000..83deb1a
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
+
+//
+//  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 (file)
index 0000000..570ea3e
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
+
+//
+//  Created by tkawata on 1/29/2013.
+//
+
+#ifndef DNPLUGININFO_H
+#define DNPLUGININFO_H
+
+#include <string>
+
+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
index 523d566..1afeaf9 100644 (file)
@@ -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<DCContainer*> (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;
         }
index 58229b7..363994e 100644 (file)
@@ -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);
 
index 0688aec..bd4d3cc 100644 (file)
@@ -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;
 
 };
 
index 6f6908b..5a9973a 100644 (file)
@@ -88,7 +88,7 @@ bool DCScene::getIsModified() const
 
 DCVCPage* DCScene::getPage(const std::string &location) const
 {
-    DNLocker(getSceneLock());
+    QMutexLocker locker(getSceneLock());
 
     QMap<QString, DCVCPage*>::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<QString, DCVCPage*>::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<QString, DCVCPage*>::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<QString,DCVCPage*>::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<QString, DCVCPage*> 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<QString, DCVCPage*> 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<QString, DCVCPage*> 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<QString, DCVCPage*> 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<QString, DCVCPage*> 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<DCVComponent*> 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<QString, DCVCPage*> i(d_pages);
      while (i.hasNext())
@@ -384,7 +384,7 @@ QList<DCVCPage*> DCScene::getSelectedPages() const
 {
     QList<DCVCPage*> list;
 
-    DNLocker(getSceneLock());
+    QMutexLocker locker(getSceneLock());
     QMapIterator<QString, DCVCPage*> i(d_pages);
      while (i.hasNext())
      {
@@ -397,7 +397,7 @@ QList<DCVCPage*> DCScene::getSelectedPages() const
 
 QList<DCVComponent*> DCScene::getSelectedCellObjects() const
 {
-    DNLocker(getSceneLock());
+    QMutexLocker lockr(getSceneLock());
     return d_owner->getSelectedCellObjects();
 }