OSDN Git Service

[denncoCreator] refactoring
authortkawata <tkawata@users.sourceforge.jp>
Fri, 19 Oct 2012 17:06:23 +0000 (02:06 +0900)
committertkawata <tkawata@users.sourceforge.jp>
Fri, 19 Oct 2012 17:06:23 +0000 (02:06 +0900)
22 files changed:
Source/command/dceditcommands.cpp
Source/dcaxonterminal.cpp
Source/dcaxonterminal.h
Source/dccell.cpp
Source/dccell.h
Source/dccontainer.cpp
Source/dccontainer.h
Source/dccontainersaver.cpp
Source/dccreator.cpp
Source/dcreceptor.cpp
Source/dcreceptor.h
Source/engine/layer1/TKAxonTerminal.h
Source/engine/layer1/TKCell.h
Source/engine/layer1/TKReceptor.h
Source/utils/dccomponentutil.cpp
Source/visualizer/component/dcvcaxonterminal.cpp
Source/visualizer/component/dcvceditmodecursor.cpp
Source/visualizer/component/dcvcreceptor.cpp
Source/visualizer/dcglvisualizerwidget.cpp
Source/visualizer/eventhandler/dcvterminalfromreceptormodehandler.cpp
Source/visualizer/toolwindow/dctoolwindowcellcodeeditor.cpp
Source/visualizer/toolwindow/dctoolwindowcelleditor.cpp

index 9516a07..b069194 100644 (file)
@@ -85,7 +85,7 @@ DCCommitAddAxonTerminalCommand::DCCommitAddAxonTerminalCommand(const void *reque
 DCCommitAddAxonTerminalCommand::DCCommitAddAxonTerminalCommand(const void *requester, DCCreator *creator, DCCell *axonCell, DCReceptor *receptor)
     : DCCommand(requester, creator), d_axonCell(axonCell), d_receptor(receptor), d_receptorName(""), d_isAdded(false)
 {
-    d_receptorCell = dynamic_cast<DCCell*>(d_receptor->getOwnerCell());
+    d_receptorCell = d_receptor->getOwnerCell();
 }
 
 void DCCommitAddAxonTerminalCommand::redo()
@@ -120,7 +120,7 @@ void DCCommitAddAxonTerminalCommand::undo()
         DCReceptor *receptor = d_receptorCell->getReceptor(d_receptorName);
         if (axon && receptor)
         {
-            DCAxonTerminal *terminal = dynamic_cast<DCAxonTerminal*>(receptor->getTarget());
+            DCAxonTerminal *terminal = receptor->getTarget();
             d_receptorCell->removeReceptor(d_receptorName);
             axon->removeAxonTerminal(terminal);
         }
@@ -129,7 +129,7 @@ void DCCommitAddAxonTerminalCommand::undo()
     {
         DCAxon *axon = dynamic_cast <DCAxon*>(d_axonCell->getAxon());
         QString receptorName = QString::fromStdString(d_receptorCell->getReceptorName(d_receptor));
-        DCAxonTerminal *terminal = dynamic_cast<DCAxonTerminal*>(d_receptor->getTarget());
+        DCAxonTerminal *terminal = d_receptor->getTarget();
 
         d_receptorCell->removeReceptor(receptorName);
         axon->removeAxonTerminal(terminal);
@@ -156,11 +156,11 @@ void DCRemoveAxonTerminalCommand::redo()
     if (d_axonTerminal)
     {
         //delete from axon terminal
-        DCReceptor *receptor = dynamic_cast<DCReceptor*>(d_axonTerminal->getTarget());
+        DCReceptor *receptor = d_axonTerminal->getTarget();
         DCAxon *axon = dynamic_cast <DCAxon*>(d_axonTerminal->getOwner());
         if (receptor && axon)
         {
-            DCCell *targetCell = dynamic_cast<DCCell*>(receptor->getOwnerCell());
+            DCCell *targetCell = receptor->getOwnerCell();
             QString receptorName = QString::fromStdString(targetCell->getReceptorName(receptor));
             d_isDeleted = targetCell->removeReceptor(receptorName);
             if (d_isDeleted)
@@ -171,7 +171,7 @@ void DCRemoveAxonTerminalCommand::redo()
     {
         //delete from receptor name
         DCReceptor *receptor = d_cell->getReceptor(d_receptorName);
-        DCAxonTerminal *terminal = dynamic_cast<DCAxonTerminal*>(receptor->getTarget());
+        DCAxonTerminal *terminal = receptor->getTarget();
         DCAxon *axon = dynamic_cast<DCAxon*>(terminal->getOwner());
         d_isDeleted = d_cell->removeReceptor(d_receptorName);
         if (d_isDeleted)
index b930b8c..a0b9d14 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "dcvcomponent.h"
 #include "dcaxon.h"
+#include "dcreceptor.h"
 
 DCAxonTerminal::DCAxonTerminal(DCAxon *theOwner) : TKAxonTerminal(theOwner), mVComponent(NULL),
     mIsViewReceptorPointUpdated(false), mIsViewAxonPointUpdated(false)
@@ -36,6 +37,11 @@ DCAxonTerminal::~DCAxonTerminal()
     }
 }
 
+DCReceptor* DCAxonTerminal::getTarget() const
+{
+    return dynamic_cast<DCReceptor*>(mTarget);
+}
+
 void DCAxonTerminal::setViewMatrixForAxonPoint(const float matrix[])
 {
     for (int i = 0; i < 16; i++)
index ca86b9d..9b1740b 100644 (file)
@@ -26,6 +26,7 @@
 class DCAxon;
 class DCVCAxonTerminal;
 class DCVComponent;
+class DCReceptor;
 
 class DCAxonTerminal : public TKAxonTerminal
 {
@@ -42,6 +43,7 @@ class DCAxonTerminal : public TKAxonTerminal
 public:
     virtual ~DCAxonTerminal();
 
+    DCReceptor*     getTarget() const;
     DCVComponent*   getVComponent() const { return mVComponent; }
     bool            getIsViewAxonPointUpdated() const { return mIsViewAxonPointUpdated; }
     bool            getIsViewReceptorPointUpdated() const { return mIsViewReceptorPointUpdated; }
index 1cb2b4e..1b7a8d4 100644 (file)
@@ -285,7 +285,7 @@ bool DCCell::removeAllConnections()
     while(it != mReceptors.end())
     {
         DCReceptor *receptor = dynamic_cast<DCReceptor*>(it->second);
-        DCAxonTerminal *terminal = dynamic_cast<DCAxonTerminal*>(receptor->getTarget());
+        DCAxonTerminal *terminal = receptor->getTarget();
         if (terminal)
         {
             DCAxon *receptorTargetCellAxon = dynamic_cast<DCAxon*>(terminal->getOwner());
@@ -303,8 +303,8 @@ bool DCCell::removeAllConnections()
     for (int i = 0; i < axon->getNumberOfTerminals(); i++)
     {
         DCAxonTerminal *terminal = axon->getTerminalAt(i);
-        DCReceptor *axonTargetReceptor = dynamic_cast<DCReceptor*>(terminal->getTarget());
-        DCCell *axonTargetCell = dynamic_cast<DCCell*>(axonTargetReceptor->getOwnerCell());
+        DCReceptor *axonTargetReceptor = terminal->getTarget();
+        DCCell *axonTargetCell = axonTargetReceptor->getOwnerCell();
         if (axonTargetCell)
         {
             axonTargetCell->removeReceptor(axonTargetReceptor);
index d21894a..2e1e7d1 100644 (file)
@@ -75,6 +75,7 @@ public:
     virtual bool        doDestroy() {return false;}
     virtual bool        setCellCode(TKCellCode *code, const void *data);
 
+    std::string         getLocation() const { return mLocation; }
     DCVPageComponent *  getVComponent() const { return d_vComponent; }
     DCVCPage*           getPageBelonging() const;
     DCCellCode*         getCellCode() const { return d_cellCode; }
index 278cb59..b5b077e 100644 (file)
@@ -166,7 +166,7 @@ TKCell* DCContainer::addCell(std::string theLocation, std::string theName, std::
 {
     QMutexLocker(d_scene->getSceneLock());
 
-    TKCell *cell = TKContainer::addCell(theLocation, theName, type, customScript);
+    DCCell *cell = dynamic_cast<DCCell*>(TKContainer::addCell(theLocation, theName, type, customScript));
 
     saveCustomScriptToWorkFile(cell, customScript);
 
@@ -177,7 +177,7 @@ TKCell*  DCContainer::addCell(std::string theLocation, std::string theName, TKCe
 {
     QMutexLocker(d_scene->getSceneLock());
 
-    TKCell *cell = TKContainer::addCell(theLocation, theName, cellCode, customScript);
+    DCCell *cell = dynamic_cast<DCCell*>(TKContainer::addCell(theLocation, theName, cellCode, customScript));
 
     saveCustomScriptToWorkFile(cell, customScript);
 
@@ -188,7 +188,7 @@ TKCellCode* DCContainer::addCellCode(std::string theName, std::string theAPIType
 {
     QMutexLocker(d_scene->getSceneLock());
 
-    TKCellCode *cellCode = TKContainer::addCellCode(theName, theAPIType, code);
+    DCCellCode *cellCode = dynamic_cast<DCCellCode*>(TKContainer::addCellCode(theName, theAPIType, code));
 
     saveClassScriptToWorkFile(cellCode, code);
 
@@ -340,7 +340,7 @@ bool DCContainer::removeCell(DCCell *cell)
     return false;
 }
 
-bool DCContainer::saveCustomScriptToWorkFile(TKCell *cell, std::string customScript)
+bool DCContainer::saveCustomScriptToWorkFile(DCCell *cell, std::string customScript)
 {
     QDir workdir(d_workDirCellRoot + "/" + QString::fromStdString(cell->getLocation()));
     if (!workdir.exists())
@@ -355,7 +355,7 @@ bool DCContainer::saveCustomScriptToWorkFile(TKCell *cell, std::string customScr
     return true;
 }
 
-bool DCContainer::saveClassScriptToWorkFile(TKCellCode *cellCode, std::string code)
+bool DCContainer::saveClassScriptToWorkFile(DCCellCode *cellCode, std::string code)
 {
     QString qNamePath = QString::fromStdString(cellCode->getFQNName());
     QString path = DCUtil::getContainerBasedPathFromFQNPath(qNamePath);
index c298994..86658db 100644 (file)
@@ -145,8 +145,8 @@ public:
     void                    beganBuildContainer();
     void                    endedBuildContainer();
 
-    bool                    saveCustomScriptToWorkFile(TKCell *cell, std::string customScript);
-    bool                    saveClassScriptToWorkFile(TKCellCode *cellCode, std::string code);
+    bool                    saveCustomScriptToWorkFile(DCCell *cell, std::string customScript);
+    bool                    saveClassScriptToWorkFile(DCCellCode *cellCode, std::string code);
 
     QString                 sysFilePathToContainerBasedPath(const QString& sysFilePath);
     QString                 containerBasedPathToSysFilePath(const QString& containerBasedPath);
index 01f00f3..ccc641e 100644 (file)
@@ -101,10 +101,10 @@ bool DCContainerSaver::saveForPage(const QString& containerRootPath, DCVCPage *p
         for (int j = 0; j < axon->getNumberOfTerminals(); j++)
         {
             DCAxonTerminal *terminal = axon->getTerminalAt(j);
-            DCReceptor *receptor = dynamic_cast<DCReceptor*>(terminal->getTarget());
+            DCReceptor *receptor = terminal->getTarget();
             if (receptor)
             {
-                DCCell *targetCell = dynamic_cast<DCCell*>(receptor->getOwnerCell());
+                DCCell *targetCell = receptor->getOwnerCell();
                 if (targetCell)
                 {
                     QString connectionPath = QString::fromStdString(targetCell->getLocation());
index 993676c..e8c8ec9 100644 (file)
@@ -387,11 +387,11 @@ void DCCreator::doCommandCancelAddAxonTerminal(const void *requester)
 
 void DCCreator::doCommandRemoveAxonTerminal(const void *requester, DCCell *axonCell, DCAxonTerminal *axonTerminal)
 {
-    DCReceptor *receptor = dynamic_cast<DCReceptor*>(axonTerminal->getTarget());
+    DCReceptor *receptor = axonTerminal->getTarget();
     if (!receptor)
         return;
 
-    DCCell *targetCell = dynamic_cast<DCCell*>(receptor->getOwnerCell());
+    DCCell *targetCell = receptor->getOwnerCell();
     if (!targetCell)
         return;
 
index 51ac70e..bbd7982 100644 (file)
@@ -22,6 +22,7 @@
 #include "dccell.h"
 #include "dcvceditmodecursor.h"
 #include "dcvceditmodeterminal.h"
+#include "dcaxonterminal.h"
 
 DCReceptor::DCReceptor(DCCell *owner) : TKReceptor(owner), d_vComponent(NULL), d_isTerminalVisible(true), d_editCursor(NULL)
 {
@@ -36,6 +37,16 @@ DCReceptor::~DCReceptor()
     }
 }
 
+DCAxonTerminal* DCReceptor::getTarget() const
+{
+    return dynamic_cast<DCAxonTerminal*>(mTerminal);
+}
+
+DCCell* DCReceptor::getOwnerCell() const
+{
+    return dynamic_cast<DCCell*>(mOwner);
+}
+
 DCVComponent* DCReceptor::getVComponent() const
 {
     return d_vComponent;
@@ -47,7 +58,7 @@ void DCReceptor::getViewReceptorOffsetPoint(float dx, float dy, float dz,float *
     *y = 0;
     *z = 0;
 
-    DCCell *cell = dynamic_cast<DCCell*>(getOwnerCell());
+    DCCell *cell = getOwnerCell();
     if (cell)
     {
         float cx,cz;
index 843f0e9..f2199d2 100644 (file)
@@ -25,6 +25,7 @@ class DCCell;
 class DCVCReceptor;
 class DCVComponent;
 class DCVCEditModeCursor;
+class DCAxonTerminal;
 
 class DCReceptor : public TKReceptor
 {
@@ -39,6 +40,8 @@ class DCReceptor : public TKReceptor
 public:
     virtual ~DCReceptor();
 
+    DCAxonTerminal*     getTarget() const;
+    DCCell*             getOwnerCell() const;
     DCVComponent*       getVComponent() const;
     void                getViewReceptorOffsetPoint(float dx, float dy, float dz,float *x, float *y, float *z) const;
     bool                getIsTerminalVisible() const { return d_isTerminalVisible; }
index 3afca1e..caded5e 100644 (file)
@@ -29,15 +29,14 @@ public:
        TKAxonTerminal(TKAxon *theOwner) : mOwner(theOwner), mTarget(0) {}
     virtual ~TKAxonTerminal() {}
 
-    void        setTarget(TKReceptor *theReceptor) {mTarget = theReceptor;}
-    void        release(TKReceptor *receptor);
+    void    setTarget(TKReceptor *theReceptor) {mTarget = theReceptor;}
+    void    release(TKReceptor *receptor);
     
-    bool        isConnected() { return mTarget != 0; }
-    TKAxon*     getOwner() { return mOwner; }
-    TKReceptor* getTarget() { return mTarget; }
-    float       getValue();
+    bool    isConnected() { return mTarget != 0; }
+    TKAxon* getOwner() { return mOwner; }
+    float   getValue();
        
-private:
+protected:
        TKAxon      *mOwner;
        TKReceptor  *mTarget;
 
index 225bcf3..62e8eb9 100644 (file)
@@ -40,8 +40,6 @@ public:
     void init();
 
     std::string             getName() const { return mName; }
-    std::string             getLocation() const { return mLocation; }
-
     float                   getAxonValue() const;
     void                    setAxonValue(float value);
 
index c9d61f9..58ad661 100644 (file)
@@ -29,13 +29,10 @@ public:
        TKReceptor(TKCell *theOwner) : mOwner(theOwner), mTerminal(0) {}
     virtual ~TKReceptor() {}
 
-    void            setTarget(TKAxonTerminal *theTerminal);
-    TKAxonTerminal* getTarget() const { return mTerminal; }
-    TKCell*         getOwnerCell() const { return mOwner; }
-
-    float           getValue();
+    void        setTarget(TKAxonTerminal *theTerminal);
+    float       getValue();
                
-private:
+protected:
        TKCell *mOwner;
        TKAxonTerminal *mTerminal;
 };
index 0fcdf15..94602e5 100644 (file)
@@ -92,7 +92,7 @@ bool DCComponentUtil::isConnectedToSelectedCell(DCVComponent *vcell)
     const TKReceptorMap *receptors = cell->getReceptors();
     for ( TKReceptorMap::const_iterator it = receptors->begin(); it != receptors->end(); ++it )
     {
-        TKReceptor *receptor = it->second;
+        DCReceptor *receptor = dynamic_cast<DCReceptor*>(it->second);
         if ( receptor && receptor->getTarget() && ((DCCell*)receptor->getTarget()->getOwner()->getOwner())->getVComponent()->getIsSelected())
         {
             r = true;
index 7aaaea5..1c80c9d 100644 (file)
@@ -63,7 +63,7 @@ void DCVCAxonTerminal::renderOwnShape(bool isAnimationInterval, bool renderAsWir
         float receptorY = receptorPointMatrix[13];
         float receptorZ = receptorPointMatrix[14];
 
-        DCReceptor *receptor = dynamic_cast<DCReceptor*>(d_owner->getTarget());
+        DCReceptor *receptor = d_owner->getTarget();
         if (receptor)
         {
             float ox,oy,oz;
@@ -117,7 +117,7 @@ void DCVCAxonTerminal::translate()
 DCVComponent::DCVVisibility DCVCAxonTerminal::getIsVisible() const
 {
     DCAxon *axon = (DCAxon*)d_owner->getOwner();
-    DCReceptor *receptor = (DCReceptor*)d_owner->getTarget();
+    DCReceptor *receptor = d_owner->getTarget();
     return ((axon && axon->getIsTerminalVisible()) || (receptor && receptor->getIsTerminalVisible())) ?
                 DCV_VISIBLE_FULL : DCV_VISIBLE_NONE;
 }
@@ -139,7 +139,7 @@ DCVComponent* DCVCAxonTerminal::getAxonComponent() const
 
 DCVComponent* DCVCAxonTerminal::getReceptorComponent() const
 {
-    DCReceptor *receptor = (DCReceptor*)d_owner->getTarget();
+    DCReceptor *receptor = d_owner->getTarget();
     if (receptor)
     {
         return receptor->getVComponent();
index 7a62604..d2e01dd 100644 (file)
@@ -85,7 +85,7 @@ void DCVCEditModeCursor::setOwnerFromReceptor(DCReceptor *owner)
     }
 
     d_ownerReceptor = owner;
-    d_ownerCell = dynamic_cast<DCCell*>(owner->getOwnerCell());
+    d_ownerCell = owner->getOwnerCell();
     if (d_ownerReceptor && d_ownerCell)
     {
         d_cursorType = DCV_CURSOR_FROM_RECEPTAOR;
index 878cd55..a286442 100644 (file)
@@ -41,7 +41,7 @@ void DCVCReceptor::prepareChildrenForDraw(bool isAnimationInterval)
     DCVComponent *vterminal = getTerminalComponent();
     if (vterminal)
     {
-        ((DCAxonTerminal*)d_owner->getTarget())->setViewMatrixForReceptorPoint(matrix);
+        d_owner->getTarget()->setViewMatrixForReceptorPoint(matrix);
         vterminal->prepareForDraw(isAnimationInterval);
     }
     if (d_owner->hasEditCursor())
@@ -100,7 +100,7 @@ void DCVCReceptor::renderOwnShape(bool isAnimationInterval, bool renderAsWirefra
 
 DCVComponent* DCVCReceptor::getTerminalComponent() const
 {
-    DCAxonTerminal *terminal = (DCAxonTerminal*)d_owner->getTarget();
+    DCAxonTerminal *terminal = d_owner->getTarget();
     if (terminal)
     {
         return terminal->getVComponent();
@@ -123,7 +123,7 @@ const float* DCVCReceptor::getPointMatrix() const
 
 DCCell* DCVCReceptor::getOwnerCell() const
 {
-    return dynamic_cast<DCCell*>(d_owner->getOwnerCell());
+    return d_owner->getOwnerCell();
 }
 
 DCVCPage* DCVCReceptor::getPageBelonging() const
index 133d7aa..20a7465 100644 (file)
@@ -1256,8 +1256,8 @@ void DCUIGraphicsScene::updateTerminalFromReceptorToolWindow()
     if (d_terminalFromReceptorToolWindow)
     {
         DCReceptor *receptor = d_scene->getEditReceptor();
-        if (receptor)
-            d_terminalFromReceptorToolWindow->updateData(dynamic_cast<DCCell*>(receptor->getOwnerCell()),
+         if (receptor)
+           d_terminalFromReceptorToolWindow->updateData(receptor->getOwnerCell(),
                                                          receptor,
                                                          d_scene->getTerminalEditCursorLocationString(),
                                                          d_scene->getTerminalEditCursorDropTarget() ? d_scene->getTerminalEditCursorDropTarget()->getOwnerCell() : NULL);
index 63c0e11..a9759c3 100644 (file)
@@ -177,7 +177,7 @@ void DCVTerminalFromReceptorModeHandler::mouseMoveEvent(QGraphicsSceneMouseEvent
             d_draggedObject.ref()->setSelectable(false);
             DCVComponent *obj = getView()->getObjectAt(mousePos.x(), mousePos.y());
             d_draggedObject.ref()->setSelectable(true);
-            DCCell *cell = dynamic_cast<DCCell*>(d_editReceptor->getOwnerCell());
+            DCCell *cell = d_editReceptor->getOwnerCell();
 
             if (d_cursor->getDropTarget() && d_cursor->getDropTarget() != obj)
             {
index c5e88a7..9d7868c 100644 (file)
@@ -271,10 +271,10 @@ void DCToolWindowCellCodeEditor::updateInformation()
             DCAxonTerminal *tarminal = axon->getTerminalAt(i);
             if (tarminal)
             {
-                targetReceptor = dynamic_cast<DCReceptor*>(tarminal->getTarget());
+                targetReceptor = tarminal->getTarget();
                 if (targetReceptor)
                 {
-                    targetCell = dynamic_cast<DCCell*>(targetReceptor->getOwnerCell());
+                    targetCell = targetReceptor->getOwnerCell();
                 }
             }
             QString axonTerminalName;
index 130a188..e095a96 100644 (file)
@@ -175,10 +175,10 @@ public:
             int num = axon->getNumberOfTerminals();
             for (int i = 0; i < num; i++)
             {
-                DCReceptor *receptor = dynamic_cast<DCReceptor*>(axon->getTerminalAt(i)->getTarget());
+                DCReceptor *receptor = axon->getTerminalAt(i)->getTarget();
                 if (receptor)
                 {
-                    DCCell *targetCell = dynamic_cast<DCCell*>(receptor->getOwnerCell());
+                    DCCell *targetCell = receptor->getOwnerCell();
                     if (targetCell)
                     {
                         QString targetReceptorName = QString::fromStdString(targetCell->getReceptorName(receptor));
@@ -395,11 +395,11 @@ void DCToolWindowCellEditor::updateView()
             d_receptorItemModel->insertString(receptorName,rroot);
             d_receptorItemModel->setData(rroot.child(i,2), QVariant::fromValue(DCResources::deleteItemIcon()));
 
-            TKReceptor *receptor = (*it).second;
-            TKAxonTerminal *terminal = receptor->getTarget();
+            DCReceptor *receptor = dynamic_cast<DCReceptor*>((*it).second);
+            DCAxonTerminal *terminal = receptor->getTarget();
             if (terminal)
             {
-                TKCell *targetCell = terminal->getOwner()->getOwner();
+                DCCell *targetCell = dynamic_cast<DCCell*>(terminal->getOwner()->getOwner());
                 if (targetCell)
                 {
                     QString targetPath = DCUtil::getFQNPath(targetCell->getLocation(), targetCell->getName());
@@ -432,10 +432,10 @@ void DCToolWindowCellEditor::updateView()
             DCAxonTerminal *tarminal = axon->getTerminalAt(i);
             if (tarminal)
             {
-                targetReceptor = dynamic_cast<DCReceptor*>(tarminal->getTarget());
+                targetReceptor = tarminal->getTarget();
                 if (targetReceptor)
                 {
-                    targetCell = dynamic_cast<DCCell*>(targetReceptor->getOwnerCell());
+                    targetCell = targetReceptor->getOwnerCell();
                 }
             }