|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/fxschematicscene.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzQt includes
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/fxschematicnode.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/gutil.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/dvdialog.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/fxselection.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/schematicgroupeditor.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/swatchviewer.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/tselectionhandle.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzLib includes
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txsheet.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/toonzscene.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tcolumnfxset.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/fxdag.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshlevelcolumn.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tcolumnfx.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshpalettecolumn.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshzeraryfxcolumn.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/fxcommand.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txsheethandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tfxhandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tscenehandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tcolumnhandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tframehandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tobjecthandle.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzBase includes
|
|
Toshihiro Shimizu |
890ddd |
#include "tmacrofx.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "fxdata.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tpassivecachemanager.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tfxattributes.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzCore includes
|
|
Toshihiro Shimizu |
890ddd |
#include "tconst.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Qt includes
|
|
Toshihiro Shimizu |
890ddd |
#include <qmenu></qmenu>
|
|
Toshihiro Shimizu |
890ddd |
#include <qapplication></qapplication>
|
|
Toshihiro Shimizu |
890ddd |
#include <qgraphicsscenecontextmenuevent></qgraphicsscenecontextmenuevent>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
namespace
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class MatchesFx
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TFxP m_fx;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
MatchesFx(const TFxP &fx) : m_fx(fx) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool operator()(const TFxP &fx)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TZeraryColumnFx *zfx = dynamic_cast<tzerarycolumnfx *="">(fx.getPointer());</tzerarycolumnfx>
|
|
Toshihiro Shimizu |
890ddd |
return (m_fx.getPointer() == fx.getPointer()) || (zfx && m_fx.getPointer() == zfx->getZeraryFx());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void keepSubgroup(QMap<int, *="" qlist<schematicnode="">> &editedGroup)</int,>
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
QMap<int, *="" qlist<schematicnode="">>::iterator it;</int,>
|
|
Toshihiro Shimizu |
890ddd |
for (it = editedGroup.begin(); it != editedGroup.end(); it++) {
|
|
Toshihiro Shimizu |
890ddd |
QList<schematicnode *=""> groupedNodes = it.value();</schematicnode>
|
|
Toshihiro Shimizu |
890ddd |
int i;
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < groupedNodes.size(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
FxSchematicNode *node = dynamic_cast<fxschematicnode *="">(groupedNodes[i]);</fxschematicnode>
|
|
Toshihiro Shimizu |
890ddd |
if (!node)
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
TFx *fx = node->getFx();
|
|
Toshihiro Shimizu |
890ddd |
assert(fx);
|
|
Toshihiro Shimizu |
890ddd |
QMap<int, *="" qlist<schematicnode="">>::iterator it2;</int,>
|
|
Toshihiro Shimizu |
890ddd |
for (it2 = editedGroup.begin(); it2 != editedGroup.end(); it2++) {
|
|
Toshihiro Shimizu |
890ddd |
if (fx->getAttributes()->isContainedInGroup(it2.key()) &&
|
|
Toshihiro Shimizu |
890ddd |
!editedGroup[it2.key()].contains(node))
|
|
Toshihiro Shimizu |
890ddd |
editedGroup[it2.key()].append(node);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//! Find the input and the output fx contained in \b visitedFxs.
|
|
Toshihiro Shimizu |
890ddd |
//! \b visitedFxs must be a connected fx selection. In \b outputFx is put the root of the connected fx selection.
|
|
Toshihiro Shimizu |
890ddd |
//! In \b inputFx is put a leaf of the connected fx selection.
|
|
Toshihiro Shimizu |
890ddd |
void findBoundariesFxs(TFx *&inputFx, TFx *&outputFx, QMap<tfx *,="" bool=""> &visitedFxs, TFx *currentFx = 0)</tfx>
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (visitedFxs.isEmpty())
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
if (!currentFx)
|
|
Toshihiro Shimizu |
890ddd |
currentFx = visitedFxs.begin().key();
|
|
Toshihiro Shimizu |
890ddd |
int inputPortCount = currentFx->getInputPortCount();
|
|
Toshihiro Shimizu |
890ddd |
int outputConnectionCount = currentFx->getOutputConnectionCount();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (inputPortCount > 0 && !visitedFxs[currentFx]) {
|
|
Toshihiro Shimizu |
890ddd |
visitedFxs[currentFx] = true;
|
|
Toshihiro Shimizu |
890ddd |
TFxPort *fxPort = currentFx->getInputPort(0);
|
|
Toshihiro Shimizu |
890ddd |
TFx *fx = fxPort->getFx();
|
|
Toshihiro Shimizu |
890ddd |
if (fx && visitedFxs.count(fx) == 1) {
|
|
Toshihiro Shimizu |
890ddd |
if (!visitedFxs[fx])
|
|
Toshihiro Shimizu |
890ddd |
findBoundariesFxs(inputFx, outputFx, visitedFxs, fx);
|
|
Toshihiro Shimizu |
890ddd |
} else
|
|
Toshihiro Shimizu |
890ddd |
inputFx = currentFx;
|
|
Toshihiro Shimizu |
890ddd |
} else
|
|
Toshihiro Shimizu |
890ddd |
inputFx = currentFx;
|
|
Toshihiro Shimizu |
890ddd |
if (!outputFx) {
|
|
Toshihiro Shimizu |
890ddd |
if (outputConnectionCount > 0) {
|
|
Toshihiro Shimizu |
890ddd |
TFx *fx = currentFx->getOutputConnection(0)->getOwnerFx();
|
|
Toshihiro Shimizu |
890ddd |
if (fx && visitedFxs.count(fx) == 1) {
|
|
Toshihiro Shimizu |
890ddd |
if (!visitedFxs[fx])
|
|
Toshihiro Shimizu |
890ddd |
findBoundariesFxs(inputFx, outputFx, visitedFxs, fx);
|
|
Toshihiro Shimizu |
890ddd |
} else
|
|
Toshihiro Shimizu |
890ddd |
outputFx = currentFx;
|
|
Toshihiro Shimizu |
890ddd |
} else
|
|
Toshihiro Shimizu |
890ddd |
outputFx = currentFx;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool canDisconnectSelection(FxSelection *selection)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
QList<tfxp> selectedFx = selection->getFxs();</tfxp>
|
|
Toshihiro Shimizu |
890ddd |
int i;
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < selectedFx.size(); i++) // .....
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TFx *fx = selectedFx[i].getPointer();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TLevelColumnFx *lcFx = dynamic_cast<tlevelcolumnfx *="">(fx);</tlevelcolumnfx>
|
|
Toshihiro Shimizu |
890ddd |
TPaletteColumnFx *pfx = dynamic_cast<tpalettecolumnfx *="">(fx);</tpalettecolumnfx>
|
|
Toshihiro Shimizu |
890ddd |
TXsheetFx *xfx = dynamic_cast<txsheetfx *="">(fx);</txsheetfx>
|
|
Toshihiro Shimizu |
890ddd |
TOutputFx *ofx = dynamic_cast<toutputfx *="">(fx);</toutputfx>
|
|
Toshihiro Shimizu |
890ddd |
TZeraryColumnFx *zfx = dynamic_cast<tzerarycolumnfx *="">(fx);</tzerarycolumnfx>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return (!lcFx && !pfx && !xfx && !ofx && (!zfx || zfx->getInputPortCount() > 0)); // !!!!!
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QList<tfxp> getRoots(const QList<tfxp> &fxs, TFxSet *terminals)</tfxp></tfxp>
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
QList<tfxp> roots;</tfxp>
|
|
Toshihiro Shimizu |
890ddd |
int i;
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < fxs.size(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
TFx *fx = fxs[i].getPointer();
|
|
Toshihiro Shimizu |
890ddd |
int j;
|
|
Toshihiro Shimizu |
890ddd |
bool isRoot = true;
|
|
Toshihiro Shimizu |
890ddd |
for (j = 0; j < fx->getOutputConnectionCount(); j++) {
|
|
Toshihiro Shimizu |
890ddd |
TFx *outFx = fx->getOutputConnection(j)->getOwnerFx();
|
|
Toshihiro Shimizu |
890ddd |
if (outFx && std::find_if(fxs.begin(), fxs.end(), MatchesFx(outFx)) != fxs.end() &&
|
|
Toshihiro Shimizu |
890ddd |
!terminals->containsFx(fx))
|
|
Toshihiro Shimizu |
890ddd |
isRoot = false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (isRoot)
|
|
Toshihiro Shimizu |
890ddd |
roots.append(fx);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
return roots;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
} // namespace
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==================================================================
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
// FxSchematicScene::SupportLinks
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//==================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::SupportLinks::addBridgeLink(SchematicLink *link)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (link && !m_bridges.contains(link))
|
|
Toshihiro Shimizu |
890ddd |
m_bridges.push_back(link);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::SupportLinks::addOutputLink(SchematicLink *link)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (link && !m_outputs.contains(link))
|
|
Toshihiro Shimizu |
890ddd |
m_outputs.push_back(link);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::SupportLinks::addInputLink(SchematicLink *link)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (link && !m_inputs.contains(link))
|
|
Toshihiro Shimizu |
890ddd |
m_inputs.push_back(link);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::SupportLinks::hideBridgeLinks()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int i;
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < m_bridges.size(); i++)
|
|
Toshihiro Shimizu |
890ddd |
m_bridges[i]->hide();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::SupportLinks::hideInputLinks()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int i;
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < m_inputs.size(); i++)
|
|
Toshihiro Shimizu |
890ddd |
m_inputs[i]->hide();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::SupportLinks::hideOutputLinks()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int i;
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < m_outputs.size(); i++)
|
|
Toshihiro Shimizu |
890ddd |
m_outputs[i]->hide();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::SupportLinks::showBridgeLinks()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int i;
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < m_bridges.size(); i++)
|
|
Toshihiro Shimizu |
890ddd |
m_bridges[i]->show();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::SupportLinks::showInputLinks()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int i;
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < m_inputs.size(); i++)
|
|
Toshihiro Shimizu |
890ddd |
m_inputs[i]->show();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::SupportLinks::showOutputLinks()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int i;
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < m_outputs.size(); i++)
|
|
Toshihiro Shimizu |
890ddd |
m_outputs[i]->show();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::SupportLinks::removeBridgeLinks(bool deleteLink)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int i;
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < m_bridges.size(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
SchematicLink *link = m_bridges[i];
|
|
Toshihiro Shimizu |
890ddd |
m_bridges.removeAt(i);
|
|
Toshihiro Shimizu |
890ddd |
if (deleteLink) {
|
|
Toshihiro Shimizu |
890ddd |
link->getStartPort()->removeLink(link);
|
|
Toshihiro Shimizu |
890ddd |
link->getEndPort()->removeLink(link);
|
|
Toshihiro Shimizu |
890ddd |
delete link;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::SupportLinks::removeInputLinks(bool deleteLink)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int i;
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < m_inputs.size(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
SchematicLink *link = m_inputs[i];
|
|
Toshihiro Shimizu |
890ddd |
m_inputs.removeAt(i);
|
|
Toshihiro Shimizu |
890ddd |
if (deleteLink) {
|
|
Toshihiro Shimizu |
890ddd |
link->getStartPort()->removeLink(link);
|
|
Toshihiro Shimizu |
890ddd |
link->getEndPort()->removeLink(link);
|
|
Toshihiro Shimizu |
890ddd |
delete link;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::SupportLinks::removeOutputLinks(bool deleteLink)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int i;
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < m_outputs.size(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
SchematicLink *link = m_outputs[i];
|
|
Toshihiro Shimizu |
890ddd |
m_outputs.removeAt(i);
|
|
Toshihiro Shimizu |
890ddd |
if (deleteLink) {
|
|
Toshihiro Shimizu |
890ddd |
link->getStartPort()->removeLink(link);
|
|
Toshihiro Shimizu |
890ddd |
link->getEndPort()->removeLink(link);
|
|
Toshihiro Shimizu |
890ddd |
delete link;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::SupportLinks::clearAll()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_bridges.clear();
|
|
Toshihiro Shimizu |
890ddd |
m_inputs.clear();
|
|
Toshihiro Shimizu |
890ddd |
m_outputs.clear();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int FxSchematicScene::SupportLinks::size()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return m_bridges.size() + m_inputs.size() + m_outputs.size();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==================================================================
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
// FxSchematicScene
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//==================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
FxSchematicScene::FxSchematicScene(QWidget *parent)
|
|
Toshihiro Shimizu |
890ddd |
: SchematicScene(parent), m_firstPoint(sceneRect().center()), m_xshHandle(0), m_fxHandle(0), m_addFxContextMenu(), m_disconnectionLinks(), m_connectionLinks(), m_isConnected(false), m_linkUnlinkSimulation(false), m_altPressed(false), m_lastPos(0, 0), m_currentFxNode(0), m_gridDimension(eSmall), m_isLargeScaled(true)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_selection = new FxSelection();
|
|
Toshihiro Shimizu |
890ddd |
m_selection->setFxSchematicScene(this);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
connect(m_selection, SIGNAL(doCollapse(const QList<tfxp> &)), this, SLOT(onCollapse(const QList<tfxp> &)));</tfxp></tfxp>
|
|
Toshihiro Shimizu |
890ddd |
connect(m_selection, SIGNAL(doExplodeChild(const QList<tfxp> &)), this, SIGNAL(doExplodeChild(const QList<tfxp> &)));</tfxp></tfxp>
|
|
Toshihiro Shimizu |
890ddd |
connect(this, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_addFxContextMenu.setSelection(m_selection);
|
|
Toshihiro Shimizu |
890ddd |
m_highlightedLinks.clear();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
FxSchematicScene::~FxSchematicScene()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_selection)
|
|
Toshihiro Shimizu |
890ddd |
delete m_selection;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::setApplication(TApplication *app)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_app = app;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_xshHandle = app->getCurrentXsheet();
|
|
Toshihiro Shimizu |
890ddd |
m_fxHandle = app->getCurrentFx();
|
|
Toshihiro Shimizu |
890ddd |
m_frameHandle = app->getCurrentFrame();
|
|
Toshihiro Shimizu |
890ddd |
m_columnHandle = app->getCurrentColumn();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (m_fxHandle)
|
|
Toshihiro Shimizu |
890ddd |
connect(m_fxHandle, SIGNAL(fxSwitched()), this, SLOT(onCurrentFxSwitched()));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_addFxContextMenu.setApplication(app);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_selection->setXsheetHandle(m_xshHandle);
|
|
Toshihiro Shimizu |
890ddd |
m_selection->setFxHandle(m_fxHandle);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::updateScene()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (!views().empty())
|
|
Toshihiro Shimizu |
890ddd |
#if QT_VERSION >= 0x050000
|
|
Toshihiro Shimizu |
890ddd |
m_isLargeScaled = views().at(0)->matrix().determinant() >= 1.0;
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
m_isLargeScaled = views().at(0)->matrix().det() >= 1.0;
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
m_disconnectionLinks.clearAll();
|
|
Toshihiro Shimizu |
890ddd |
m_connectionLinks.clearAll();
|
|
Toshihiro Shimizu |
890ddd |
m_selectionOldPos.clear();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
clearSelection();
|
|
Toshihiro Shimizu |
890ddd |
clearAllItems();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_table.clear();
|
|
Toshihiro Shimizu |
890ddd |
m_groupedTable.clear();
|
|
Toshihiro Shimizu |
890ddd |
m_groupEditorTable.clear();
|
|
Toshihiro Shimizu |
890ddd |
m_macroEditorTable.clear();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_currentFxNode = 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// GroupId->Fx
|
|
Toshihiro Shimizu |
890ddd |
QMap<int, qlist<tfxp="">> groupedFxs;</int,>
|
|
Toshihiro Shimizu |
890ddd |
QMap<int, *="" qlist<schematicnode="">> editedGroup;</int,>
|
|
Toshihiro Shimizu |
890ddd |
QMap<tmacrofx *="" *,="" qlist<schematicnode="">> editedMacro;</tmacrofx>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TXsheet *xsh = m_xshHandle->getXsheet();
|
|
Toshihiro Shimizu |
890ddd |
m_gridDimension = xsh->getFxDag()->getDagGridDimension();
|
|
Toshihiro Shimizu |
890ddd |
TFxSet *fxSet = xsh->getFxDag()->getInternalFxs();
|
|
Toshihiro Shimizu |
890ddd |
int i;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
FxDag *fxDag = xsh->getFxDag();
|
|
Toshihiro Shimizu |
890ddd |
//Add XSheetFX node
|
|
Toshihiro Shimizu |
890ddd |
addFxSchematicNode(fxDag->getXsheetFx());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//Add outputFx nodes
|
|
Toshihiro Shimizu |
890ddd |
int k;
|
|
Toshihiro Shimizu |
890ddd |
for (k = 0; k < fxDag->getOutputFxCount(); k++) {
|
|
Toshihiro Shimizu |
890ddd |
TOutputFx *fx = fxDag->getOutputFx(k);
|
|
Toshihiro Shimizu |
890ddd |
if (fx->getAttributes()->isGrouped() && !fx->getAttributes()->isGroupEditing()) {
|
|
Toshihiro Shimizu |
890ddd |
groupedFxs[fx->getAttributes()->getGroupId()].push_back(fx);
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
SchematicNode *node = addFxSchematicNode(fx);
|
|
Toshihiro Shimizu |
890ddd |
if (fx->getAttributes()->isGrouped())
|
|
Toshihiro Shimizu |
890ddd |
editedGroup[fx->getAttributes()->getEditingGroupId()].append(node);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//Add columnFx and zeraryFx nodes
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < xsh->getColumnCount(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
TXshColumn *column = xsh->getColumn(i);
|
|
Toshihiro Shimizu |
890ddd |
TFx *fx = 0;
|
|
Toshihiro Shimizu |
890ddd |
if (TXshLevelColumn *lc = column->getLevelColumn())
|
|
Toshihiro Shimizu |
890ddd |
fx = lc->getLevelColumnFx();
|
|
Toshihiro Shimizu |
890ddd |
else if (TXshPaletteColumn *pc = dynamic_cast<txshpalettecolumn *="">(column))</txshpalettecolumn>
|
|
Toshihiro Shimizu |
890ddd |
fx = pc->getPaletteColumnFx();
|
|
Toshihiro Shimizu |
890ddd |
else if (TXshZeraryFxColumn *zc = dynamic_cast<txshzeraryfxcolumn *="">(column))</txshzeraryfxcolumn>
|
|
Toshihiro Shimizu |
890ddd |
fx = zc->getZeraryColumnFx();
|
|
Toshihiro Shimizu |
890ddd |
if (!fx)
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (fx->getAttributes()->isGrouped() && !fx->getAttributes()->isGroupEditing()) {
|
|
Toshihiro Shimizu |
890ddd |
groupedFxs[fx->getAttributes()->getGroupId()].push_back(fx);
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (column->isEmpty() && fx && fx->getOutputConnectionCount() == 0)
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
SchematicNode *node = addFxSchematicNode(fx);
|
|
Toshihiro Shimizu |
890ddd |
if (fx->getAttributes()->isGrouped())
|
|
Toshihiro Shimizu |
890ddd |
editedGroup[fx->getAttributes()->getEditingGroupId()].append(node);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//Add normalFx
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < fxSet->getFxCount(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
TFx *fx = fxSet->getFx(i);
|
|
Toshihiro Shimizu |
890ddd |
TMacroFx *macro = dynamic_cast<tmacrofx *="">(fx);</tmacrofx>
|
|
Toshihiro Shimizu |
890ddd |
if (fx->getAttributes()->isGrouped() && !fx->getAttributes()->isGroupEditing()) {
|
|
Toshihiro Shimizu |
890ddd |
groupedFxs[fx->getAttributes()->getGroupId()].push_back(fx);
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
} else if (macro && macro->isEditing()) {
|
|
Toshihiro Shimizu |
890ddd |
vector<tfxp> fxs = macro->getFxs();</tfxp>
|
|
Toshihiro Shimizu |
890ddd |
int j;
|
|
Toshihiro Shimizu |
890ddd |
for (j = 0; j < (int)fxs.size(); j++) {
|
|
Toshihiro Shimizu |
890ddd |
SchematicNode *node = addFxSchematicNode(fxs[j].getPointer());
|
|
Toshihiro Shimizu |
890ddd |
editedMacro[macro].append(node);
|
|
Toshihiro Shimizu |
890ddd |
if (fxs[j]->getAttributes()->isGrouped() && macro->getAttributes()->isGroupEditing())
|
|
Toshihiro Shimizu |
890ddd |
editedGroup[fx->getAttributes()->getEditingGroupId()].append(node);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
SchematicNode *node = addFxSchematicNode(fx);
|
|
Toshihiro Shimizu |
890ddd |
if (fx->getAttributes()->isGrouped())
|
|
Toshihiro Shimizu |
890ddd |
editedGroup[fx->getAttributes()->getEditingGroupId()].append(node);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//grouped node
|
|
Toshihiro Shimizu |
890ddd |
QMap<int, qlist<tfxp="">>::const_iterator it;</int,>
|
|
Toshihiro Shimizu |
890ddd |
for (it = groupedFxs.begin(); it != groupedFxs.end(); it++) {
|
|
Toshihiro Shimizu |
890ddd |
FxSchematicNode *node = addGroupedFxSchematicNode(it.key(), it.value());
|
|
Toshihiro Shimizu |
890ddd |
TFx *fx = node->getFx();
|
|
Toshihiro Shimizu |
890ddd |
assert(fx);
|
|
Toshihiro Shimizu |
890ddd |
int editingGroupId = fx->getAttributes()->getEditingGroupId();
|
|
Toshihiro Shimizu |
890ddd |
if (editingGroupId != -1)
|
|
Toshihiro Shimizu |
890ddd |
editedGroup[editingGroupId].append(node);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
keepSubgroup(editedGroup);
|
|
Toshihiro Shimizu |
890ddd |
updateEditedGroups(editedGroup);
|
|
Toshihiro Shimizu |
890ddd |
updateEditedMacros(editedMacro);
|
|
Toshihiro Shimizu |
890ddd |
updateLink();
|
|
Toshihiro Shimizu |
890ddd |
m_nodesToPlace.clear();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::updateEditedGroups(const QMap<int, *="" qlist<schematicnode="">> &editedGroup)</int,>
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
QMap<int, *="" qlist<schematicnode="">>::const_iterator it;</int,>
|
|
Toshihiro Shimizu |
890ddd |
for (it = editedGroup.begin(); it != editedGroup.end(); it++) {
|
|
Toshihiro Shimizu |
890ddd |
int zValue = 2;
|
|
Toshihiro Shimizu |
890ddd |
QMap<int, *="" qlist<schematicnode="">>::const_iterator it2 = editedGroup.begin();</int,>
|
|
Toshihiro Shimizu |
890ddd |
while (it2 != editedGroup.end()) {
|
|
Toshihiro Shimizu |
890ddd |
FxSchematicNode *placedFxNode = dynamic_cast<fxschematicnode *="">(it2.value()[0]);</fxschematicnode>
|
|
Toshihiro Shimizu |
890ddd |
FxSchematicNode *fxNode = dynamic_cast<fxschematicnode *="">(it.value()[0]);</fxschematicnode>
|
|
Toshihiro Shimizu |
890ddd |
if (!placedFxNode || !fxNode) {
|
|
Toshihiro Shimizu |
890ddd |
it2++;
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
int placedGroupedId = placedFxNode->getFx()->getAttributes()->getEditingGroupId();
|
|
Toshihiro Shimizu |
890ddd |
if (fxNode->getFx()->getAttributes()->isContainedInGroup(placedGroupedId) &&
|
|
Toshihiro Shimizu |
890ddd |
fxNode->getFx()->getAttributes()->getEditingGroupId() != it2.key())
|
|
Toshihiro Shimizu |
890ddd |
zValue += 2;
|
|
Toshihiro Shimizu |
890ddd |
it2++;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
FxSchematicGroupEditor *node = addEditedGroupedFxSchematicNode(it.key(), it.value());
|
|
Toshihiro Shimizu |
890ddd |
node->setZValue(zValue);
|
|
Toshihiro Shimizu |
890ddd |
node->setGroupedNodeZValue(zValue + 1);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::updateEditedMacros(const QMap<tmacrofx *="" *,="" qlist<schematicnode="">> &editedMacro)</tmacrofx>
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
QMap<tmacrofx *="" *,="" qlist<schematicnode="">>::const_iterator it;</tmacrofx>
|
|
Toshihiro Shimizu |
890ddd |
for (it = editedMacro.begin(); it != editedMacro.end(); it++) {
|
|
Toshihiro Shimizu |
890ddd |
TMacroFx *macro = it.key();
|
|
Toshihiro Shimizu |
890ddd |
int zValue = 2;
|
|
Toshihiro Shimizu |
890ddd |
if (macro->getAttributes()->isGrouped()) {
|
|
Toshihiro Shimizu |
890ddd |
FxSchematicGroupEditor *containingGroup = m_groupEditorTable[macro->getAttributes()->getEditingGroupId()];
|
|
Toshihiro Shimizu |
890ddd |
assert(containingGroup);
|
|
Toshihiro Shimizu |
890ddd |
zValue = containingGroup->zValue() + 2;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
FxSchematicMacroEditor *node = addEditedMacroFxSchematicNode(it.key(), it.value());
|
|
Toshihiro Shimizu |
890ddd |
node->setZValue(zValue);
|
|
Toshihiro Shimizu |
890ddd |
node->setGroupedNodeZValue(zValue + 1);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
FxSchematicNode *FxSchematicScene::addFxSchematicNode(TFx *fx)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
FxSchematicNode *node = createFxSchematicNode(fx);
|
|
Toshihiro Shimizu |
890ddd |
if (!node)
|
|
Toshihiro Shimizu |
890ddd |
return 0;
|
|
Toshihiro Shimizu |
890ddd |
connect(node, SIGNAL(sceneChanged()), this, SLOT(onSceneChanged()));
|
|
Toshihiro Shimizu |
890ddd |
connect(node, SIGNAL(xsheetChanged()), this, SLOT(onXsheetChanged()));
|
|
Toshihiro Shimizu |
890ddd |
connect(node, SIGNAL(switchCurrentFx(TFx *)), this, SLOT(onSwitchCurrentFx(TFx *)));
|
|
Toshihiro Shimizu |
890ddd |
connect(node, SIGNAL(currentColumnChanged(int)), this, SLOT(onCurrentColumnChanged(int)));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
connect(node, SIGNAL(fxNodeDoubleClicked()), this, SLOT(onFxNodeDoubleClicked()));
|
|
Toshihiro Shimizu |
890ddd |
if (fx->getAttributes()->getDagNodePos() == TConst::nowhere) {
|
|
Toshihiro Shimizu |
890ddd |
node->resize(m_gridDimension == 0);
|
|
Toshihiro Shimizu |
890ddd |
placeNode(node);
|
|
Toshihiro Shimizu |
890ddd |
} else
|
|
Toshihiro Shimizu |
890ddd |
updatePosition(node, fx->getAttributes()->getDagNodePos());
|
|
Toshihiro Shimizu |
890ddd |
m_table[fx] = node;
|
|
Toshihiro Shimizu |
890ddd |
return node;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
FxSchematicNode *FxSchematicScene::addGroupedFxSchematicNode(int groupId, const QList<tfxp> &groupedFxs)</tfxp>
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TFxSet *terminals = getXsheet()->getFxDag()->getTerminalFxs();
|
|
Toshihiro Shimizu |
890ddd |
QList<tfxp> roots = getRoots(groupedFxs, terminals);</tfxp>
|
|
Toshihiro Shimizu |
890ddd |
if (roots.isEmpty())
|
|
Toshihiro Shimizu |
890ddd |
return 0;
|
|
Toshihiro Shimizu |
890ddd |
wstring name = roots[0]->getAttributes()->getGroupName(false);
|
|
Toshihiro Shimizu |
890ddd |
FxGroupNode *node = new FxGroupNode(this, groupedFxs, roots, groupId, name);
|
|
Toshihiro Shimizu |
890ddd |
if (!node)
|
|
Toshihiro Shimizu |
890ddd |
return 0;
|
|
Toshihiro Shimizu |
890ddd |
connect(node, SIGNAL(sceneChanged()), this, SLOT(onSceneChanged()));
|
|
Toshihiro Shimizu |
890ddd |
connect(node, SIGNAL(xsheetChanged()), this, SLOT(onXsheetChanged()));
|
|
Toshihiro Shimizu |
890ddd |
connect(node, SIGNAL(switchCurrentFx(TFx *)), this, SLOT(onSwitchCurrentFx(TFx *)));
|
|
Toshihiro Shimizu |
890ddd |
connect(node, SIGNAL(currentColumnChanged(int)), this, SLOT(onCurrentColumnChanged(int)));
|
|
Toshihiro Shimizu |
890ddd |
m_groupedTable[groupId] = node;
|
|
Toshihiro Shimizu |
890ddd |
return node;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
FxSchematicGroupEditor *FxSchematicScene::addEditedGroupedFxSchematicNode(int groupId,
|
|
Toshihiro Shimizu |
890ddd |
const QList<schematicnode *=""> &groupedFxs)</schematicnode>
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
FxSchematicGroupEditor *editorGroup = new FxSchematicGroupEditor(groupId, groupedFxs, this);
|
|
Toshihiro Shimizu |
890ddd |
m_groupEditorTable[groupId] = editorGroup;
|
|
Toshihiro Shimizu |
890ddd |
return editorGroup;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
FxSchematicMacroEditor *FxSchematicScene::addEditedMacroFxSchematicNode(TMacroFx *macro, const QList<schematicnode *=""> &groupedFxs)</schematicnode>
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
FxSchematicMacroEditor *editorMacro = new FxSchematicMacroEditor(macro, groupedFxs, this);
|
|
Toshihiro Shimizu |
890ddd |
m_macroEditorTable[macro] = editorMacro;
|
|
Toshihiro Shimizu |
890ddd |
return editorMacro;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::updatePosition(FxSchematicNode *node, const TPointD &pos)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
node->setPos(QPointF(pos.x, pos.y));
|
|
Toshihiro Shimizu |
890ddd |
node->getFx()->getAttributes()->setDagNodePos(pos);
|
|
Toshihiro Shimizu |
890ddd |
QVector<schematicnode *=""> placedNodes = getPlacedNode(node);</schematicnode>
|
|
Toshihiro Shimizu |
890ddd |
int step = m_gridDimension == eLarge ? 100 : 50;
|
|
Toshihiro Shimizu |
890ddd |
TPointD offset(0, -step);
|
|
Toshihiro Shimizu |
890ddd |
int i;
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < placedNodes.size(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
FxSchematicNode *placedNode = dynamic_cast<fxschematicnode *="">(placedNodes[i]);</fxschematicnode>
|
|
Toshihiro Shimizu |
890ddd |
assert(placedNode);
|
|
Toshihiro Shimizu |
890ddd |
TPointD newPos = placedNode->getFx()->getAttributes()->getDagNodePos() + offset;
|
|
Toshihiro Shimizu |
890ddd |
updatePosition(placedNode, newPos);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! create node depends on the fx type
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
FxSchematicNode *FxSchematicScene::createFxSchematicNode(TFx *fx)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (TLevelColumnFx *lcFx = dynamic_cast<tlevelcolumnfx *="">(fx))</tlevelcolumnfx>
|
|
Toshihiro Shimizu |
890ddd |
return new FxSchematicColumnNode(this, lcFx);
|
|
Toshihiro Shimizu |
890ddd |
else if (TPaletteColumnFx *pfx = dynamic_cast<tpalettecolumnfx *="">(fx))</tpalettecolumnfx>
|
|
Toshihiro Shimizu |
890ddd |
return new FxSchematicPaletteNode(this, pfx);
|
|
Toshihiro Shimizu |
890ddd |
else if (TZeraryColumnFx *zfx = dynamic_cast<tzerarycolumnfx *="">(fx))</tzerarycolumnfx>
|
|
Toshihiro Shimizu |
890ddd |
return new FxSchematicZeraryNode(this, zfx);
|
|
Toshihiro Shimizu |
890ddd |
else if (TXsheetFx *xfx = dynamic_cast<txsheetfx *="">(fx))</txsheetfx>
|
|
Toshihiro Shimizu |
890ddd |
return new FxSchematicXSheetNode(this, xfx);
|
|
Toshihiro Shimizu |
890ddd |
else if (TOutputFx *ofx = dynamic_cast<toutputfx *="">(fx))</toutputfx>
|
|
Toshihiro Shimizu |
890ddd |
return new FxSchematicOutputNode(this, ofx);
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
return new FxSchematicNormalFxNode(this, fx);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! place nodes of which positions are not specified manually
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::placeNode(FxSchematicNode *node)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (!node)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
int step = m_gridDimension == eLarge ? 100 : 50;
|
|
Toshihiro Shimizu |
890ddd |
FxDag *fxDag = m_xshHandle->getXsheet()->getFxDag();
|
|
Toshihiro Shimizu |
890ddd |
QRectF nodeRect = node->boundingRect();
|
|
Toshihiro Shimizu |
890ddd |
if (node->isA(eOutpuFx)) {
|
|
Toshihiro Shimizu |
890ddd |
//I'm placing an output node
|
|
Toshihiro Shimizu |
890ddd |
TFx *xsheetFx = fxDag->getXsheetFx();
|
|
Toshihiro Shimizu |
890ddd |
TFxPort *outPort = xsheetFx->getOutputConnection(0);
|
|
Toshihiro Shimizu |
890ddd |
TFx *connectedOutput = outPort ? outPort->getOwnerFx() : 0;
|
|
Toshihiro Shimizu |
890ddd |
if (connectedOutput && connectedOutput == node->getFx()) {
|
|
Toshihiro Shimizu |
890ddd |
//The output node is connected to the xsheet node
|
|
Toshihiro Shimizu |
890ddd |
TPointD pos = xsheetFx->getAttributes()->getDagNodePos();
|
|
Toshihiro Shimizu |
890ddd |
if (pos != TConst::nowhere)
|
|
Toshihiro Shimizu |
890ddd |
nodeRect.translate(pos.x + 120, pos.y);
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
nodeRect.translate(sceneRect().center());
|
|
Toshihiro Shimizu |
890ddd |
while (!isAnEmptyZone(nodeRect))
|
|
Toshihiro Shimizu |
890ddd |
nodeRect.translate(0, step);
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
//The output node is not connected to the xsheet node
|
|
Toshihiro Shimizu |
890ddd |
TFx *fx = node->getFx();
|
|
Toshihiro Shimizu |
890ddd |
TFxPort *port = fx->getInputPort(0);
|
|
Toshihiro Shimizu |
890ddd |
TFx *inputFx = port->getFx();
|
|
Toshihiro Shimizu |
890ddd |
if (inputFx) {
|
|
Toshihiro Shimizu |
890ddd |
//The output node is connected to another node
|
|
Toshihiro Shimizu |
890ddd |
TPointD pos = inputFx->getAttributes()->getDagNodePos();
|
|
Toshihiro Shimizu |
890ddd |
if (pos != TConst::nowhere)
|
|
Toshihiro Shimizu |
890ddd |
nodeRect.translate(pos.x + 120, pos.y);
|
|
Toshihiro Shimizu |
890ddd |
else {
|
|
Toshihiro Shimizu |
890ddd |
m_nodesToPlace[inputFx].append(node);
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
//The output node is not connected
|
|
Toshihiro Shimizu |
890ddd |
QPointF pos = sceneRect().center();
|
|
Toshihiro Shimizu |
890ddd |
nodeRect.translate(pos);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
while (!isAnEmptyZone(nodeRect))
|
|
Toshihiro Shimizu |
890ddd |
nodeRect.translate(0, step);
|
|
Toshihiro Shimizu |
890ddd |
QPointF newPos = nodeRect.topLeft();
|
|
Toshihiro Shimizu |
890ddd |
node->getFx()->getAttributes()->setDagNodePos(TPointD(newPos.x(), newPos.y()));
|
|
Toshihiro Shimizu |
890ddd |
node->setPos(newPos);
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
} else if (node->isA(eXSheetFx)) {
|
|
Toshihiro Shimizu |
890ddd |
//I'm placing the xsheet node
|
|
Toshihiro Shimizu |
890ddd |
TFxSet *terminalFxs = fxDag->getTerminalFxs();
|
|
Toshihiro Shimizu |
890ddd |
int i;
|
|
Toshihiro Shimizu |
890ddd |
double maxX = m_firstPoint.x();
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < terminalFxs->getFxCount(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
TFx *terminalFx = terminalFxs->getFx(i);
|
|
Toshihiro Shimizu |
890ddd |
if (terminalFx->getAttributes()->getDagNodePos() == TConst::nowhere)
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
maxX = tmax(maxX, terminalFx->getAttributes()->getDagNodePos().x);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
TPointD oldPos = node->getFx()->getAttributes()->getDagNodePos();
|
|
Toshihiro Shimizu |
890ddd |
QPointF pos;
|
|
Toshihiro Shimizu |
890ddd |
if (oldPos == TConst::nowhere)
|
|
Toshihiro Shimizu |
890ddd |
pos = QPointF(maxX + 120, m_firstPoint.y());
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
pos = QPointF(maxX + 120 > oldPos.x ? maxX + 120 : oldPos.x, oldPos.y);
|
|
Toshihiro Shimizu |
890ddd |
node->getFx()->getAttributes()->setDagNodePos(TPointD(pos.x(), pos.y()));
|
|
Toshihiro Shimizu |
890ddd |
node->setPos(pos);
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
} else if (node->isA(eMacroFx) || node->isA(eNormalFx) ||
|
|
Toshihiro Shimizu |
890ddd |
node->isA(eNormalLayerBlendingFx) || node->isA(eNormalMatteFx) || node->isA(eNormalImageAdjustFx)) {
|
|
Toshihiro Shimizu |
890ddd |
//I'm placing an effect or a macro
|
|
Toshihiro Shimizu |
890ddd |
TFx *inputFx = node->getFx()->getInputPort(0)->getFx();
|
|
Toshihiro Shimizu |
890ddd |
QPointF pos;
|
|
Toshihiro Shimizu |
890ddd |
if (inputFx) {
|
|
Toshihiro Shimizu |
890ddd |
if (inputFx->getAttributes()->getDagNodePos() != TConst::nowhere) {
|
|
Toshihiro Shimizu |
890ddd |
TPointD dagPos = inputFx->getAttributes()->getDagNodePos() + TPointD(150, 0);
|
|
Toshihiro Shimizu |
890ddd |
pos = QPointF(dagPos.x, dagPos.y);
|
|
Toshihiro Shimizu |
890ddd |
nodeRect.moveTopLeft(pos);
|
|
Toshihiro Shimizu |
890ddd |
while (!isAnEmptyZone(nodeRect))
|
|
Toshihiro Shimizu |
890ddd |
nodeRect.translate(0, -step);
|
|
Toshihiro Shimizu |
890ddd |
pos = nodeRect.topLeft();
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
m_nodesToPlace[inputFx].append(node);
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
pos = sceneRect().center();
|
|
Toshihiro Shimizu |
890ddd |
nodeRect.moveTopLeft(pos);
|
|
Toshihiro Shimizu |
890ddd |
while (!isAnEmptyZone(nodeRect))
|
|
Toshihiro Shimizu |
890ddd |
nodeRect.translate(0, -step);
|
|
Toshihiro Shimizu |
890ddd |
pos = nodeRect.topLeft();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
node->getFx()->getAttributes()->setDagNodePos(TPointD(pos.x(), pos.y()));
|
|
Toshihiro Shimizu |
890ddd |
node->setPos(QPointF(pos));
|
|
Toshihiro Shimizu |
890ddd |
if (m_nodesToPlace.contains(node->getFx())) {
|
|
Toshihiro Shimizu |
890ddd |
QList<fxschematicnode *=""> nodes = m_nodesToPlace[node->getFx()];</fxschematicnode>
|
|
Toshihiro Shimizu |
890ddd |
int i;
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < nodes.size(); i++)
|
|
Toshihiro Shimizu |
890ddd |
placeNode(nodes[i]);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
} else if (node->isA(eZeraryFx) || node->isA(eColumnFx) || node->isA(eGroupedFx)) {
|
|
Toshihiro Shimizu |
890ddd |
//I'm placing a column
|
|
Toshihiro Shimizu |
890ddd |
nodeRect.translate(m_firstPoint);
|
|
Toshihiro Shimizu |
890ddd |
nodeRect.translate(10, 10);
|
|
Toshihiro Shimizu |
890ddd |
while (!isAnEmptyZone(nodeRect))
|
|
Toshihiro Shimizu |
890ddd |
nodeRect.translate(0, -step);
|
|
Toshihiro Shimizu |
890ddd |
QPointF newPos = nodeRect.topLeft();
|
|
Toshihiro Shimizu |
890ddd |
node->getFx()->getAttributes()->setDagNodePos(TPointD(newPos.x(), newPos.y()));
|
|
Toshihiro Shimizu |
890ddd |
node->setPos(QPointF(newPos));
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::updateLink()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TXsheet *xsh = m_xshHandle->getXsheet();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Iterate the fxs table
|
|
Toshihiro Shimizu |
890ddd |
QMap<tfx *="" *,="" fxschematicnode="">::iterator it;</tfx>
|
|
Toshihiro Shimizu |
890ddd |
for (it = m_table.begin(); it != m_table.end(); ++it) {
|
|
Toshihiro Shimizu |
890ddd |
FxSchematicNode *node = it.value();
|
|
Toshihiro Shimizu |
890ddd |
if (!node)
|
|
Toshihiro Shimizu |
890ddd |
continue; // Should be asserted? Is it legal?
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFx *fx = it.key();
|
|
Toshihiro Shimizu |
890ddd |
TFx *inputPortsFx = fx;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (TZeraryColumnFx *fx2 = dynamic_cast<tzerarycolumnfx *="">(fx)) {</tzerarycolumnfx>
|
|
Toshihiro Shimizu |
890ddd |
inputPortsFx = fx2->getZeraryFx();
|
|
Toshihiro Shimizu |
890ddd |
if (!inputPortsFx)
|
|
Toshihiro Shimizu |
890ddd |
return; // Should really never happen. Should be asserted...
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0; i != inputPortsFx->getInputPortCount(); ++i) {
|
|
Toshihiro Shimizu |
890ddd |
TFxPort *port = inputPortsFx->getInputPort(i);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (TFx *linkedFx = port->getFx()) {
|
|
Toshihiro Shimizu |
890ddd |
if (!linkedFx->getAttributes()->isGrouped() || linkedFx->getAttributes()->isGroupEditing()) {
|
|
Toshihiro Shimizu |
890ddd |
// Not in a group / open group case
|
|
Toshihiro Shimizu |
890ddd |
assert(m_table.contains(linkedFx));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (m_table.contains(linkedFx)) {
|
|
Toshihiro Shimizu |
890ddd |
FxSchematicNode *linkedNode = m_table[linkedFx];
|
|
Toshihiro Shimizu |
890ddd |
SchematicPort *p0 = linkedNode->getOutputPort();
|
|
Toshihiro Shimizu |
890ddd |
SchematicPort *p1 = node->getInputPort(i);
|
|
Toshihiro Shimizu |
890ddd |
if (p0 && p1)
|
|
Toshihiro Shimizu |
890ddd |
p0->makeLink(p1);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
assert(m_groupedTable.contains(linkedFx->getAttributes()->getGroupId()));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (m_groupedTable.contains(linkedFx->getAttributes()->getGroupId())) {
|
|
Toshihiro Shimizu |
890ddd |
FxSchematicNode *linkedNode = m_groupedTable[linkedFx->getAttributes()->getGroupId()];
|
|
Toshihiro Shimizu |
890ddd |
SchematicPort *p0 = linkedNode->getOutputPort();
|
|
Toshihiro Shimizu |
890ddd |
SchematicPort *p1 = node->getInputPort(i);
|
|
Toshihiro Shimizu |
890ddd |
if (p0 && p1)
|
|
Toshihiro Shimizu |
890ddd |
p0->makeLink(p1);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (xsh->getFxDag()->getTerminalFxs()->containsFx(fx)) {
|
|
Toshihiro Shimizu |
890ddd |
SchematicPort *p0 = node->getOutputPort();
|
|
Toshihiro Shimizu |
890ddd |
SchematicPort *p1 = m_table[xsh->getFxDag()->getXsheetFx()]->getInputPort(0);
|
|
Toshihiro Shimizu |
890ddd |
p0->makeLink(p1);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
QMap<int, *="" fxgroupnode="">::iterator it2;</int,>
|
|
Toshihiro Shimizu |
890ddd |
for (it2 = m_groupedTable.begin(); it2 != m_groupedTable.end(); it2++) {
|
|
Toshihiro Shimizu |
890ddd |
FxGroupNode *node = it2.value();
|
|
Toshihiro Shimizu |
890ddd |
if (!node)
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
int i, fxCount = node->getFxCount();
|
|
Toshihiro Shimizu |
890ddd |
bool xsheetConnected = false;
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < fxCount; i++) {
|
|
Toshihiro Shimizu |
890ddd |
TFx *fx = node->getFx(i);
|
|
Toshihiro Shimizu |
890ddd |
if (xsh->getFxDag()->getTerminalFxs()->containsFx(fx) && !xsheetConnected) {
|
|
Toshihiro Shimizu |
890ddd |
SchematicPort *p0 = node->getOutputPort();
|
|
Toshihiro Shimizu |
890ddd |
SchematicPort *p1 = m_table[xsh->getFxDag()->getXsheetFx()]->getInputPort(0);
|
|
Toshihiro Shimizu |
890ddd |
p0->makeLink(p1);
|
|
Toshihiro Shimizu |
890ddd |
xsheetConnected = true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TZeraryColumnFx *zfx = dynamic_cast<tzerarycolumnfx *="">(fx);</tzerarycolumnfx>
|
|
Toshihiro Shimizu |
890ddd |
if (zfx)
|
|
Toshihiro Shimizu |
890ddd |
fx = zfx->getZeraryFx();
|
|
Toshihiro Shimizu |
890ddd |
if (fx) {
|
|
Toshihiro Shimizu |
890ddd |
int j;
|
|
Toshihiro Shimizu |
890ddd |
for (j = 0; j < fx->getInputPortCount(); j++) {
|
|
Toshihiro Shimizu |
890ddd |
TFx *linkedFx = fx->getInputPort(j)->getFx();
|
|
Toshihiro Shimizu |
890ddd |
if (!linkedFx)
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
if (!linkedFx->getAttributes()->isGrouped() || linkedFx->getAttributes()->isGroupEditing()) {
|
|
Toshihiro Shimizu |
890ddd |
assert(m_table.contains(linkedFx));
|
|
Toshihiro Shimizu |
890ddd |
if (m_table.contains(linkedFx)) {
|
|
Toshihiro Shimizu |
890ddd |
FxSchematicNode *linkedNode = m_table[linkedFx];
|
|
Toshihiro Shimizu |
890ddd |
SchematicPort *p0 = linkedNode->getOutputPort();
|
|
Toshihiro Shimizu |
890ddd |
SchematicPort *p1 = node->getInputPort(0);
|
|
Toshihiro Shimizu |
890ddd |
if (p0 && p1)
|
|
Toshihiro Shimizu |
890ddd |
p0->makeLink(p1);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
int linkedGroupId = linkedFx->getAttributes()->getGroupId();
|
|
Toshihiro Shimizu |
890ddd |
assert(m_groupedTable.contains(linkedGroupId));
|
|
Toshihiro Shimizu |
890ddd |
if (m_groupedTable.contains(linkedGroupId)) {
|
|
Toshihiro Shimizu |
890ddd |
FxGroupNode *linkedNode = m_groupedTable[linkedGroupId];
|
|
Toshihiro Shimizu |
890ddd |
if (linkedNode == node)
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
SchematicPort *p0 = linkedNode->getOutputPort();
|
|
Toshihiro Shimizu |
890ddd |
SchematicPort *p1 = node->getInputPort(0);
|
|
Toshihiro Shimizu |
890ddd |
if (p0 && p1 && !p0->isLinkedTo(p1))
|
|
Toshihiro Shimizu |
890ddd |
p0->makeLink(p1);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//to solve an edit macro problem: create a dummy link
|
|
Toshihiro Shimizu |
890ddd |
QMap<tmacrofx *="" *,="" fxschematicmacroeditor="">::iterator it3;</tmacrofx>
|
|
Toshihiro Shimizu |
890ddd |
for (it3 = m_macroEditorTable.begin(); it3 != m_macroEditorTable.end(); it3++) {
|
|
Toshihiro Shimizu |
890ddd |
TMacroFx *macro = it3.key();
|
|
Toshihiro Shimizu |
890ddd |
int i;
|
|
Toshihiro Shimizu |
890ddd |
FxSchematicNode *root = m_table[macro->getRoot()];
|
|
Toshihiro Shimizu |
890ddd |
SchematicPort *p0 = root->getOutputPort();
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < macro->getOutputConnectionCount(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
TFxPort *outConnection = macro->getOutputConnection(i);
|
|
Toshihiro Shimizu |
890ddd |
TFx *outFx = outConnection->getOwnerFx();
|
|
Toshihiro Shimizu |
890ddd |
TMacroFx *outMacroFx = dynamic_cast<tmacrofx *="">(outFx);</tmacrofx>
|
|
Toshihiro Shimizu |
890ddd |
if (outMacroFx && outMacroFx->isEditing()) {
|
|
Toshihiro Shimizu |
890ddd |
vector<tfxp> fxs = outMacroFx->getFxs();</tfxp>
|
|
Toshihiro Shimizu |
890ddd |
int k;
|
|
Toshihiro Shimizu |
890ddd |
for (k = 0; k < (int)fxs.size(); k++) {
|
|
Toshihiro Shimizu |
890ddd |
TFx *fx = fxs[k].getPointer();
|
|
Toshihiro Shimizu |
890ddd |
int j;
|
|
Toshihiro Shimizu |
890ddd |
for (j = 0; j < fx->getInputPortCount(); j++)
|
|
Toshihiro Shimizu |
890ddd |
if (outConnection == fx->getInputPort(j)) {
|
|
Toshihiro Shimizu |
890ddd |
outFx = fx;
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (outFx != outMacroFx)
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int j;
|
|
Toshihiro Shimizu |
890ddd |
for (j = 0; j < outFx->getInputPortCount(); j++)
|
|
Toshihiro Shimizu |
890ddd |
if (outFx->getInputPort(j)->getFx() == macro) {
|
|
Toshihiro Shimizu |
890ddd |
SchematicPort *p1 = m_table[outFx]->getInputPort(j);
|
|
Toshihiro Shimizu |
890ddd |
p0->makeLink(p1);
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (xsh->getFxDag()->getTerminalFxs()->containsFx(macro)) {
|
|
Toshihiro Shimizu |
890ddd |
assert(root);
|
|
Toshihiro Shimizu |
890ddd |
if (!root)
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
SchematicPort *p1 = m_table[xsh->getFxDag()->getXsheetFx()]->getInputPort(0);
|
|
Toshihiro Shimizu |
890ddd |
p0->makeLink(p1);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
updateDuplcatedNodesLink();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::contextMenuEvent(QGraphicsSceneContextMenuEvent *cme)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
QPointF scenePos = cme->scenePos();
|
|
Toshihiro Shimizu |
890ddd |
QList<qgraphicsitem *=""> itemList = items(scenePos);</qgraphicsitem>
|
|
Toshihiro Shimizu |
890ddd |
if (!itemList.isEmpty()) {
|
|
Toshihiro Shimizu |
890ddd |
SchematicScene::contextMenuEvent(cme);
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QMenu menu(views()[0]);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (cme->modifiers() & Qt::ControlModifier) {
|
|
Toshihiro Shimizu |
890ddd |
menu.addAction(m_addFxContextMenu.getAgainCommand(AddFxContextMenu::Add));
|
|
Toshihiro Shimizu |
890ddd |
if (!menu.actions().isEmpty()) {
|
|
Toshihiro Shimizu |
890ddd |
menu.exec(cme->screenPos());
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QAction *addOutputFx = CommandManager::instance()->getAction("MI_NewOutputFx");
|
|
Toshihiro Shimizu |
890ddd |
QAction *copy = CommandManager::instance()->getAction("MI_Copy");
|
|
Toshihiro Shimizu |
890ddd |
QAction *cut = CommandManager::instance()->getAction("MI_Cut");
|
|
Toshihiro Shimizu |
890ddd |
QAction *paste = CommandManager::instance()->getAction("MI_Paste");
|
|
Toshihiro Shimizu |
890ddd |
QIcon addOutputFxIcon = createQIconOnOffPNG("output", false);
|
|
Toshihiro Shimizu |
890ddd |
if (addOutputFx)
|
|
Toshihiro Shimizu |
890ddd |
addOutputFx->setIcon(addOutputFxIcon);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_addFxContextMenu.setCurrentCursorScenePos(cme->scenePos());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
menu.addMenu(m_addFxContextMenu.getAddMenu());
|
|
Toshihiro Shimizu |
890ddd |
if (addOutputFx)
|
|
Toshihiro Shimizu |
890ddd |
menu.addAction(addOutputFx);
|
|
Toshihiro Shimizu |
890ddd |
menu.addSeparator();
|
|
Toshihiro Shimizu |
890ddd |
menu.addAction(copy);
|
|
Toshihiro Shimizu |
890ddd |
menu.addAction(cut);
|
|
Toshihiro Shimizu |
890ddd |
menu.addAction(paste);
|
|
Toshihiro Shimizu |
890ddd |
m_selection->setPastePosition(TPointD(scenePos.x(), scenePos.y()));
|
|
Toshihiro Shimizu |
890ddd |
menu.exec(cme->screenPos());
|
|
Toshihiro Shimizu |
890ddd |
m_selection->setPastePosition(TConst::nowhere);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QPointF FxSchematicScene::nearestPoint(const QPointF &point)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
QRectF rect(0, 0, 0.1, 0.1);
|
|
Toshihiro Shimizu |
890ddd |
rect.moveCenter(point);
|
|
Toshihiro Shimizu |
890ddd |
QList<qgraphicsitem *=""> itemList = items(rect);</qgraphicsitem>
|
|
Toshihiro Shimizu |
890ddd |
while (itemList.isEmpty()) {
|
|
Toshihiro Shimizu |
890ddd |
rect.adjust(-0.1, -0.1, 0.1, 0.1);
|
|
Toshihiro Shimizu |
890ddd |
itemList = items(rect);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
#if QT_VERSION >= 0x050000
|
|
Toshihiro Shimizu |
890ddd |
/*
|
|
Toshihiro Shimizu |
890ddd |
FIXME: QTransform() のデフォルトは Qt4.8 の itemAt() と比べて equivant だろうか?
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
QGraphicsItem *item = itemAt(rect.bottomLeft(), QTransform());
|
|
Toshihiro Shimizu |
890ddd |
if (item)
|
|
Toshihiro Shimizu |
890ddd |
return rect.bottomLeft();
|
|
Toshihiro Shimizu |
890ddd |
item = itemAt(rect.bottomRight(), QTransform());
|
|
Toshihiro Shimizu |
890ddd |
if (item)
|
|
Toshihiro Shimizu |
890ddd |
return rect.bottomRight();
|
|
Toshihiro Shimizu |
890ddd |
item = itemAt(rect.topLeft(), QTransform());
|
|
Toshihiro Shimizu |
890ddd |
if (item)
|
|
Toshihiro Shimizu |
890ddd |
return rect.topLeft();
|
|
Toshihiro Shimizu |
890ddd |
item = itemAt(rect.topRight(), QTransform());
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
QGraphicsItem *item = itemAt(rect.bottomLeft());
|
|
Toshihiro Shimizu |
890ddd |
if (item)
|
|
Toshihiro Shimizu |
890ddd |
return rect.bottomLeft();
|
|
Toshihiro Shimizu |
890ddd |
item = itemAt(rect.bottomRight());
|
|
Toshihiro Shimizu |
890ddd |
if (item)
|
|
Toshihiro Shimizu |
890ddd |
return rect.bottomRight();
|
|
Toshihiro Shimizu |
890ddd |
item = itemAt(rect.topLeft());
|
|
Toshihiro Shimizu |
890ddd |
if (item)
|
|
Toshihiro Shimizu |
890ddd |
return rect.topLeft();
|
|
Toshihiro Shimizu |
890ddd |
item = itemAt(rect.topRight());
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
if (item)
|
|
Toshihiro Shimizu |
890ddd |
return rect.topRight();
|
|
Toshihiro Shimizu |
890ddd |
return QPointF();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
FxSchematicNode *FxSchematicScene::getFxNodeFromPosition(const QPointF &pos)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
QList<qgraphicsitem *=""> pickedItems = items(pos);</qgraphicsitem>
|
|
Toshihiro Shimizu |
890ddd |
int i = 0;
|
|
Toshihiro Shimizu |
890ddd |
for (i; i < pickedItems.size(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
FxSchematicNode *fxNode = dynamic_cast<fxschematicnode *="">(pickedItems.at(i));</fxschematicnode>
|
|
Toshihiro Shimizu |
890ddd |
if (fxNode)
|
|
Toshihiro Shimizu |
890ddd |
return fxNode;
|
|
Toshihiro Shimizu |
890ddd |
FxSchematicPort *fxPort = dynamic_cast<fxschematicport *="">(pickedItems.at(i));</fxschematicport>
|
|
Toshihiro Shimizu |
890ddd |
if (fxPort)
|
|
Toshihiro Shimizu |
890ddd |
return fxPort->getDock()->getNode();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
return 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::updateDuplcatedNodesLink()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
QMap<tfx *="" *,="" fxschematicnode="">::iterator it;</tfx>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// fx2node contains only duplicated nodes
|
|
Toshihiro Shimizu |
890ddd |
// and zerary duplicated node s
|
|
Toshihiro Shimizu |
890ddd |
QMap<tfx *="" *,="" fxschematicnode=""> fx2node;</tfx>
|
|
Toshihiro Shimizu |
890ddd |
for (it = m_table.begin(); it != m_table.end(); ++it) {
|
|
Toshihiro Shimizu |
890ddd |
TFx *fx = it.key();
|
|
Toshihiro Shimizu |
890ddd |
FxSchematicNode *node = it.value();
|
|
Toshihiro Shimizu |
890ddd |
if (TZeraryColumnFx *zcfx = dynamic_cast<tzerarycolumnfx *="">(fx)) {</tzerarycolumnfx>
|
|
Toshihiro Shimizu |
890ddd |
fx = zcfx->getZeraryFx();
|
|
Toshihiro Shimizu |
890ddd |
if (!fx)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
assert(fx2node.count(fx) == 0);
|
|
Toshihiro Shimizu |
890ddd |
if (fx->getLinkedFx() == fx)
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
fx2node[fx] = node;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// trovo i link
|
|
Toshihiro Shimizu |
890ddd |
std::set<tfx *=""> visited;</tfx>
|
|
Toshihiro Shimizu |
890ddd |
for (it = fx2node.begin(); it != fx2node.end(); ++it) {
|
|
Toshihiro Shimizu |
890ddd |
TFx *fx = it.key();
|
|
Toshihiro Shimizu |
890ddd |
FxSchematicNode *node = it.value();
|
|
Toshihiro Shimizu |
890ddd |
assert(fx->getLinkedFx() != fx);
|
|
Toshihiro Shimizu |
890ddd |
if (visited.count(fx) > 0)
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
visited.insert(fx);
|
|
Toshihiro Shimizu |
890ddd |
FxSchematicNode *lastNode = node;
|
|
Toshihiro Shimizu |
890ddd |
assert(lastNode);
|
|
Toshihiro Shimizu |
890ddd |
FxSchematicPort *lastPort = lastNode->getLinkPort();
|
|
Toshihiro Shimizu |
890ddd |
assert(lastPort);
|
|
Toshihiro Shimizu |
890ddd |
for (fx = fx->getLinkedFx(); fx != it.key(); fx = fx->getLinkedFx()) {
|
|
Toshihiro Shimizu |
890ddd |
assert(visited.count(fx) == 0);
|
|
Toshihiro Shimizu |
890ddd |
if (visited.count(fx) > 0)
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
visited.insert(fx);
|
|
Toshihiro Shimizu |
890ddd |
QMap<tfx *="" *,="" fxschematicnode="">::iterator h;</tfx>
|
|
Toshihiro Shimizu |
890ddd |
h = fx2node.find(fx);
|
|
Toshihiro Shimizu |
890ddd |
if (h == fx2node.end())
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
assert(h != fx2node.end());
|
|
Toshihiro Shimizu |
890ddd |
FxSchematicNode *node = h.value();
|
|
Toshihiro Shimizu |
890ddd |
assert(node);
|
|
Toshihiro Shimizu |
890ddd |
FxSchematicPort *port = node->getLinkPort();
|
|
Toshihiro Shimizu |
890ddd |
assert(port);
|
|
Toshihiro Shimizu |
890ddd |
if (port && lastPort)
|
|
Toshihiro Shimizu |
890ddd |
port->makeLink(lastPort);
|
|
Toshihiro Shimizu |
890ddd |
lastNode = node;
|
|
Toshihiro Shimizu |
890ddd |
lastPort = port;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QGraphicsItem *FxSchematicScene::getCurrentNode()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
QList<qgraphicsitem *=""> allItems = items();</qgraphicsitem>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QList<qgraphicsitem *="">::iterator it = allItems.begin();</qgraphicsitem>
|
|
Toshihiro Shimizu |
890ddd |
for (it; it != allItems.end(); it++) {
|
|
Toshihiro Shimizu |
890ddd |
FxSchematicNode *node = dynamic_cast<fxschematicnode *="">(*it);</fxschematicnode>
|
|
Toshihiro Shimizu |
890ddd |
if (node && node->getFx() == m_fxHandle->getFx())
|
|
Toshihiro Shimizu |
890ddd |
return node;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
return 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::onSelectionSwitched(TSelection *oldSel, TSelection *newSel)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_selection == oldSel && m_selection != newSel)
|
|
Toshihiro Shimizu |
890ddd |
clearSelection();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::onSelectionChanged()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_selection->selectNone();
|
|
Toshihiro Shimizu |
890ddd |
int i, size = m_highlightedLinks.size();
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < size; i++) {
|
|
Toshihiro Shimizu |
890ddd |
SchematicLink *link = m_highlightedLinks[i];
|
|
Toshihiro Shimizu |
890ddd |
link->setHighlighted(false);
|
|
Toshihiro Shimizu |
890ddd |
link->update();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
m_highlightedLinks.clear();
|
|
Toshihiro Shimizu |
890ddd |
QList<qgraphicsitem *=""> slcItems = selectedItems();</qgraphicsitem>
|
|
Toshihiro Shimizu |
890ddd |
QList<qgraphicsitem *="">::iterator it;</qgraphicsitem>
|
|
Toshihiro Shimizu |
890ddd |
for (it = slcItems.begin(); it != slcItems.end(); it++) {
|
|
Toshihiro Shimizu |
890ddd |
FxSchematicNode *node = dynamic_cast<fxschematicnode *="">(*it);</fxschematicnode>
|
|
Toshihiro Shimizu |
890ddd |
if (node) {
|
|
Toshihiro Shimizu |
890ddd |
if (!node->isA(eGroupedFx)) {
|
|
Toshihiro Shimizu |
890ddd |
if (node->isA(eXSheetFx))
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
m_selection->select(node->getFx());
|
|
Toshihiro Shimizu |
890ddd |
if (node->isA(eColumnFx)) {
|
|
Toshihiro Shimizu |
890ddd |
FxSchematicColumnNode *columnNode = dynamic_cast<fxschematiccolumnnode *="">(node);</fxschematiccolumnnode>
|
|
Toshihiro Shimizu |
890ddd |
if (columnNode)
|
|
Toshihiro Shimizu |
890ddd |
m_selection->select(columnNode->getColumnIndex());
|
|
Toshihiro Shimizu |
890ddd |
else {
|
|
Toshihiro Shimizu |
890ddd |
FxSchematicPaletteNode *paletteNode = dynamic_cast<fxschematicpalettenode *="">(node);</fxschematicpalettenode>
|
|
Toshihiro Shimizu |
890ddd |
if (paletteNode)
|
|
Toshihiro Shimizu |
890ddd |
m_selection->select(paletteNode->getColumnIndex());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
FxGroupNode *groupNode = dynamic_cast<fxgroupnode *="">(node);</fxgroupnode>
|
|
Toshihiro Shimizu |
890ddd |
assert(groupNode);
|
|
Toshihiro Shimizu |
890ddd |
QList<tfxp> fxs = groupNode->getGroupedFxs();</tfxp>
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < fxs.size(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
m_selection->select(fxs[i].getPointer());
|
|
Toshihiro Shimizu |
890ddd |
TLevelColumnFx *colFx = dynamic_cast<tlevelcolumnfx *="">(fxs[i].getPointer());</tlevelcolumnfx>
|
|
Toshihiro Shimizu |
890ddd |
if (colFx) {
|
|
Toshihiro Shimizu |
890ddd |
if (TXshLevelColumn *column = colFx->getColumn()) {
|
|
Toshihiro Shimizu |
890ddd |
int colIndex = column->getIndex();
|
|
Toshihiro Shimizu |
890ddd |
m_selection->select(colIndex);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
highlightLinks(node, true);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
SchematicLink *link = dynamic_cast<schematiclink *="">(*it);</schematiclink>
|
|
Toshihiro Shimizu |
890ddd |
if (link)
|
|
Toshihiro Shimizu |
890ddd |
m_selection->select(link);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
m_selection->makeCurrent();
|
|
Toshihiro Shimizu |
890ddd |
TSelectionHandle *selHandle = TSelectionHandle::getCurrent();
|
|
Toshihiro Shimizu |
890ddd |
selHandle->notifySelectionChanged();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::reorderScene()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int step = m_gridDimension == eLarge ? 100 : 50;
|
|
Toshihiro Shimizu |
890ddd |
m_placedFxs.clear();
|
|
Toshihiro Shimizu |
890ddd |
QPointF sceneCenter = sceneRect().center();
|
|
Toshihiro Shimizu |
890ddd |
double minY = sceneCenter.y();
|
|
Toshihiro Shimizu |
890ddd |
double maxX = sceneCenter.x();
|
|
Toshihiro Shimizu |
890ddd |
double y = minY;
|
|
Toshihiro Shimizu |
890ddd |
double x = maxX;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TXsheet *xsh = m_xshHandle->getXsheet();
|
|
Toshihiro Shimizu |
890ddd |
int i = 0;
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < xsh->getColumnCount(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
TXshColumn *column = xsh->getColumn(i);
|
|
Toshihiro Shimizu |
890ddd |
TFx *fx = column->getFx();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (column->isEmpty() || !fx)
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TZeraryColumnFx *zfx = dynamic_cast<tzerarycolumnfx *="">(fx);</tzerarycolumnfx>
|
|
Toshihiro Shimizu |
890ddd |
if (zfx && (zfx->getZeraryFx()->getInputPortCount() > 0)) {
|
|
Toshihiro Shimizu |
890ddd |
TFxPort *port = zfx->getZeraryFx()->getInputPort(0);
|
|
Toshihiro Shimizu |
890ddd |
if (port && port->getFx())
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (zfx && m_placedFxs.contains(zfx->getZeraryFx()))
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
x = sceneCenter.x();
|
|
Toshihiro Shimizu |
890ddd |
placeNodeAndParents(fx, x, maxX, minY);
|
|
Toshihiro Shimizu |
890ddd |
y -= step;
|
|
Toshihiro Shimizu |
890ddd |
minY = tmin(y, minY);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//remove retrolink
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < xsh->getColumnCount(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
TXshColumn *column = xsh->getColumn(i);
|
|
Toshihiro Shimizu |
890ddd |
TFx *fx = column->getFx();
|
|
Toshihiro Shimizu |
890ddd |
if (column->isEmpty() || !fx)
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TZeraryColumnFx *zfx = dynamic_cast<tzerarycolumnfx *="">(fx);</tzerarycolumnfx>
|
|
Toshihiro Shimizu |
890ddd |
if (zfx && m_placedFxs.contains(zfx->getZeraryFx()))
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (zfx && (zfx->getZeraryFx()->getInputPortCount() > 0)) {
|
|
Toshihiro Shimizu |
890ddd |
TFxPort *port = zfx->getZeraryFx()->getInputPort(0);
|
|
Toshihiro Shimizu |
890ddd |
if (port && port->getFx())
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
for (int j = 0; j < fx->getOutputConnectionCount(); j++) {
|
|
Toshihiro Shimizu |
890ddd |
TFx *outFx = fx->getOutputConnection(j)->getOwnerFx();
|
|
Toshihiro Shimizu |
890ddd |
removeRetroLinks(outFx, maxX);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
double middleY = (sceneCenter.y() + minY + step) * 0.5;
|
|
Toshihiro Shimizu |
890ddd |
placeNodeAndParents(xsh->getFxDag()->getXsheetFx(), maxX, maxX, middleY);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
FxDag *fxDag = xsh->getFxDag();
|
|
Toshihiro Shimizu |
890ddd |
TFxSet *fxSet = fxDag->getInternalFxs();
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < fxSet->getFxCount(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
TFx *fx = fxSet->getFx(i);
|
|
Toshihiro Shimizu |
890ddd |
if (m_placedFxs.contains(fx))
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
fx->getAttributes()->setDagNodePos(TPointD(sceneCenter.x() + 120, minY));
|
|
Toshihiro Shimizu |
890ddd |
minY -= step;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
updateScene();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::removeRetroLinks(TFx *fx, double &maxX)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (!fx)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0; i < fx->getInputPortCount(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
TFx *inFx = fx->getInputPort(i)->getFx();
|
|
Toshihiro Shimizu |
890ddd |
if (!inFx)
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
TPointD inFxPos = inFx->getAttributes()->getDagNodePos();
|
|
Toshihiro Shimizu |
890ddd |
TPointD fxPos = fx->getAttributes()->getDagNodePos();
|
|
Toshihiro Shimizu |
890ddd |
if (fxPos.x <= inFxPos.x) {
|
|
Toshihiro Shimizu |
890ddd |
while (fxPos.x <= inFxPos.x)
|
|
Toshihiro Shimizu |
890ddd |
fxPos.x += 150;
|
|
Toshihiro Shimizu |
890ddd |
maxX = tmax(fxPos.x + 150, maxX);
|
|
Toshihiro Shimizu |
890ddd |
fx->getAttributes()->setDagNodePos(fxPos);
|
|
Toshihiro Shimizu |
890ddd |
for (int j = 0; j < fx->getOutputConnectionCount(); j++) {
|
|
Toshihiro Shimizu |
890ddd |
TFx *outFx = fx->getOutputConnection(j)->getOwnerFx();
|
|
Toshihiro Shimizu |
890ddd |
removeRetroLinks(outFx, maxX);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::placeNodeAndParents(TFx *fx, double x, double &maxX, double &minY)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int step = m_gridDimension == eLarge ? 100 : 50;
|
|
Toshihiro Shimizu |
890ddd |
if (!fx)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
m_placedFxs.append(fx);
|
|
Toshihiro Shimizu |
890ddd |
if (fx->getFxType() == "STD_particlesFx" ||
|
|
Toshihiro Shimizu |
890ddd |
fx->getFxType() == "STD_Iwa_ParticlesFx") {
|
|
Toshihiro Shimizu |
890ddd |
TXsheet *xsh = m_xshHandle->getXsheet();
|
|
Toshihiro Shimizu |
890ddd |
int i = 0;
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < xsh->getColumnCount(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
TFx *columnFx = xsh->getColumn(i)->getFx();
|
|
Toshihiro Shimizu |
890ddd |
TZeraryColumnFx *zfx = dynamic_cast<tzerarycolumnfx *="">(columnFx);</tzerarycolumnfx>
|
|
Toshihiro Shimizu |
890ddd |
if (zfx && zfx->getZeraryFx() == fx) {
|
|
Toshihiro Shimizu |
890ddd |
fx = zfx;
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
double y = minY;
|
|
Toshihiro Shimizu |
890ddd |
fx->getAttributes()->setDagNodePos(TPointD(x, y));
|
|
Toshihiro Shimizu |
890ddd |
if (fx->getOutputConnectionCount() == 0)
|
|
Toshihiro Shimizu |
890ddd |
minY -= step;
|
|
Toshihiro Shimizu |
890ddd |
x += 120;
|
|
Toshihiro Shimizu |
890ddd |
maxX = tmax(maxX, x);
|
|
Toshihiro Shimizu |
890ddd |
int i;
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < fx->getOutputConnectionCount(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
TFx *outputFx = fx->getOutputConnection(i)->getOwnerFx();
|
|
Toshihiro Shimizu |
890ddd |
//controllo se e' una porta sorgente
|
|
Toshihiro Shimizu |
890ddd |
TFxPort *port = outputFx->getInputPort(0);
|
|
Toshihiro Shimizu |
890ddd |
if (port && port->getFx() != fx)
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
if (!m_placedFxs.contains(outputFx) || outputFx->getAttributes()->getDagNodePos().x < x) {
|
|
Toshihiro Shimizu |
890ddd |
placeNodeAndParents(outputFx, x, maxX, minY);
|
|
Toshihiro Shimizu |
890ddd |
y -= step;
|
|
Toshihiro Shimizu |
890ddd |
minY = tmin(y, minY);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::onDisconnectFromXSheet()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
std::list<tfxp, std::allocator<tfxp="">> list = m_selection->getFxs().toStdList();</tfxp,>
|
|
Toshihiro Shimizu |
890ddd |
TFxCommand::disconnectNodesFromXsheet(list, m_xshHandle);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::onConnectToXSheet()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
std::list<tfxp, std::allocator<tfxp="">> list = m_selection->getFxs().toStdList();</tfxp,>
|
|
Toshihiro Shimizu |
890ddd |
TFxCommand::connectNodesToXsheet(list, m_xshHandle);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::onDeleteFx()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
std::list<tfxp, std::allocator<tfxp="">> fxList = m_selection->getFxs().toStdList();</tfxp,>
|
|
Toshihiro Shimizu |
890ddd |
std::list<tfxcommand::link> linkList = m_selection->getLinks().toStdList();</tfxcommand::link>
|
|
Toshihiro Shimizu |
890ddd |
std::list<int> columnIndexList = m_selection->getColumnIndexes().toStdList();</int>
|
|
Toshihiro Shimizu |
890ddd |
TFxCommand::deleteSelection(fxList, linkList, columnIndexList, m_xshHandle, m_fxHandle);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::onDuplicateFx()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
QList<tfxp> fxs = m_selection->getFxs();</tfxp>
|
|
Toshihiro Shimizu |
890ddd |
if (fxs.empty())
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TUndoManager::manager()->beginBlock();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int i, size = fxs.size();
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i != size; ++i)
|
|
Toshihiro Shimizu |
890ddd |
TFxCommand::duplicateFx(fxs[i].getPointer(), m_xshHandle, m_fxHandle);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TUndoManager::manager()->endBlock();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::onUnlinkFx()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
QList<tfxp> fxs = m_selection->getFxs();</tfxp>
|
|
Toshihiro Shimizu |
890ddd |
if (fxs.empty())
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TUndoManager::manager()->beginBlock();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int i, size = fxs.size();
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i != size; ++i)
|
|
Toshihiro Shimizu |
890ddd |
TFxCommand::unlinkFx(fxs[i].getPointer(), m_fxHandle, m_xshHandle);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TUndoManager::manager()->endBlock();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::onMacroFx()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TFxCommand::makeMacroFx(m_selection->getFxs().toVector().toStdVector(), m_app);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::onExplodeMacroFx()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (TMacroFx *macroFx = dynamic_cast<tmacrofx *="">(m_fxHandle->getFx()))</tmacrofx>
|
|
Toshihiro Shimizu |
890ddd |
TFxCommand::explodeMacroFx(macroFx, m_app);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::onOpenMacroFx()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (TMacroFx *macroFx = dynamic_cast<tmacrofx *="">(m_fxHandle->getFx())) {</tmacrofx>
|
|
Toshihiro Shimizu |
890ddd |
macroFx->editMacro(true);
|
|
Toshihiro Shimizu |
890ddd |
updateScene();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::onSavePresetFx()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
CommandManager::instance()->getAction("MI_SavePreset")->trigger();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::onRemoveOutput()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TFxCommand::removeOutputFx(m_fxHandle->getFx(), m_xshHandle, m_fxHandle);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::onActivateOutput()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TFxCommand::makeOutputFxCurrent(m_fxHandle->getFx(), m_xshHandle);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::onPreview()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
emit showPreview(m_fxHandle->getFx());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::onCacheFx()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
setEnableCache(true);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::onUncacheFx()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
setEnableCache(false);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::setEnableCache(bool toggle)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
QList<tfxp> selectedFxs = m_selection->getFxs();</tfxp>
|
|
Toshihiro Shimizu |
890ddd |
int i;
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < selectedFxs.size(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
TFx *fx = selectedFxs[i].getPointer();
|
|
Toshihiro Shimizu |
890ddd |
TZeraryColumnFx *zcfx = dynamic_cast<tzerarycolumnfx *="">(fx);</tzerarycolumnfx>
|
|
Toshihiro Shimizu |
890ddd |
if (zcfx)
|
|
Toshihiro Shimizu |
890ddd |
fx = zcfx->getZeraryFx();
|
|
Toshihiro Shimizu |
890ddd |
TFxAttributes *attr = fx->getAttributes();
|
|
Toshihiro Shimizu |
890ddd |
if (!attr->isGrouped() || attr->isGroupEditing())
|
|
Toshihiro Shimizu |
890ddd |
if (toggle)
|
|
Toshihiro Shimizu |
890ddd |
TPassiveCacheManager::instance()->enableCache(fx);
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
TPassiveCacheManager::instance()->disableCache(fx);
|
|
Toshihiro Shimizu |
890ddd |
else {
|
|
Toshihiro Shimizu |
890ddd |
QMap<int, *="" fxgroupnode="">::iterator it;</int,>
|
|
Toshihiro Shimizu |
890ddd |
for (it = m_groupedTable.begin(); it != m_groupedTable.end(); it++) {
|
|
Toshihiro Shimizu |
890ddd |
FxGroupNode *group = it.value();
|
|
Toshihiro Shimizu |
890ddd |
QList<tfxp> roots = group->getRootFxs();</tfxp>
|
|
Toshihiro Shimizu |
890ddd |
int j;
|
|
Toshihiro Shimizu |
890ddd |
for (j = 0; j < roots.size(); j++)
|
|
Toshihiro Shimizu |
890ddd |
if (fx == roots[j].getPointer())
|
|
Toshihiro Shimizu |
890ddd |
if (toggle)
|
|
Toshihiro Shimizu |
890ddd |
TPassiveCacheManager::instance()->enableCache(fx);
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
TPassiveCacheManager::instance()->disableCache(fx);
|
|
Toshihiro Shimizu |
890ddd |
group->update();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::onCollapse(const QList<tfxp> &fxs)</tfxp>
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
emit doCollapse(fxs);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::onOpenSubxsheet()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
CommandManager *cm = CommandManager::instance();
|
|
Toshihiro Shimizu |
890ddd |
cm->execute("MI_OpenChild");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TXsheet *FxSchematicScene::getXsheet()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return m_xshHandle->getXsheet();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::onXsheetChanged()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_xshHandle->notifyXsheetChanged();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::onSceneChanged()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_app->getCurrentScene()->notifySceneChanged();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::onSwitchCurrentFx(TFx *fx)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_fxHandle->getFx() == fx)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
if (fx) {
|
|
Toshihiro Shimizu |
890ddd |
// Forbid update of the swatch upon column switch. This could generate
|
|
Toshihiro Shimizu |
890ddd |
// a further useless render...
|
|
Toshihiro Shimizu |
890ddd |
SwatchViewer::suspendRendering(true, false);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int columnIndex = fx->getReferenceColumnIndex();
|
|
Toshihiro Shimizu |
890ddd |
if (columnIndex >= 0) {
|
|
Toshihiro Shimizu |
890ddd |
m_columnHandle->setColumnIndex(columnIndex);
|
|
Toshihiro Shimizu |
890ddd |
m_app->getCurrentObject()->setObjectId(TStageObjectId::ColumnId(columnIndex));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
SwatchViewer::suspendRendering(false);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_fxHandle->setFx(fx, false); //Setting the fx updates the swatch
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
emit editObject();
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
m_fxHandle->setFx(0, false);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::onFxNodeDoubleClicked()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
//emitting fxSettingsShouldBeSwitched
|
|
Toshihiro Shimizu |
890ddd |
m_fxHandle->onFxNodeDoubleClicked();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::onCurrentFxSwitched()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_currentFxNode)
|
|
Toshihiro Shimizu |
890ddd |
m_currentFxNode->setIsCurrentFxLinked(false, 0);
|
|
Toshihiro Shimizu |
890ddd |
if (m_table.contains(m_fxHandle->getFx())) {
|
|
Toshihiro Shimizu |
890ddd |
m_currentFxNode = m_table[m_fxHandle->getFx()];
|
|
Toshihiro Shimizu |
890ddd |
m_currentFxNode->setIsCurrentFxLinked(true, 0);
|
|
Toshihiro Shimizu |
890ddd |
} else
|
|
Toshihiro Shimizu |
890ddd |
m_currentFxNode = 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::onCurrentColumnChanged(int index)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_app->getCurrentColumn()->setColumnIndex(index);
|
|
Toshihiro Shimizu |
890ddd |
m_app->getCurrentObject()->setObjectId(TStageObjectId::ColumnId(index));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFx *FxSchematicScene::getCurrentFx()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return m_fxHandle->getFx();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::mousePressEvent(QGraphicsSceneMouseEvent *me)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
// avoid clear of selection by middle-click
|
|
Toshihiro Shimizu |
890ddd |
if (me->button() != Qt::MidButton)
|
|
Toshihiro Shimizu |
890ddd |
SchematicScene::mousePressEvent(me);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (me->button() == Qt::RightButton) {
|
|
Toshihiro Shimizu |
890ddd |
QList<qgraphicsitem *=""> pointedItems = items(me->scenePos());</qgraphicsitem>
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0; i < pointedItems.size(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
FxSchematicNode *sn = dynamic_cast<fxschematicnode *="">(pointedItems[i]);</fxschematicnode>
|
|
Toshihiro Shimizu |
890ddd |
if (sn) {
|
|
Toshihiro Shimizu |
890ddd |
m_fxHandle->setFx(sn->getFx(), false);
|
|
Toshihiro Shimizu |
890ddd |
if (!m_selection->isSelected(sn->getFx()))
|
|
Toshihiro Shimizu |
890ddd |
m_selection->select(sn->getFx());
|
|
Toshihiro Shimizu |
890ddd |
m_selection->makeCurrent();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QList<qgraphicsitem *=""> items = selectedItems();</qgraphicsitem>
|
|
Toshihiro Shimizu |
890ddd |
#if QT_VERSION >= 0x050000
|
|
Toshihiro Shimizu |
890ddd |
QGraphicsItem *item = itemAt(me->scenePos(), QTransform());
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
QGraphicsItem *item = itemAt(me->scenePos());
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
FxSchematicPort *port = dynamic_cast<fxschematicport *="">(item);</fxschematicport>
|
|
Toshihiro Shimizu |
890ddd |
FxSchematicLink *link = dynamic_cast<fxschematiclink *="">(item);</fxschematiclink>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (me->button() == Qt::MidButton) {
|
|
Toshihiro Shimizu |
890ddd |
int i;
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < items.size(); i++)
|
|
Toshihiro Shimizu |
890ddd |
items[i]->setSelected(true);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*
|
|
Toshihiro Shimizu |
890ddd |
ここに入ったとき、
|
|
Toshihiro Shimizu |
890ddd |
① 上記のSchematicScene::mousePressEvent(me)が呼ばれ
|
|
Toshihiro Shimizu |
890ddd |
② 最上段にあるSchematicNode::mousePressEvent内でsetSelected(this)が呼ばれ
|
|
Toshihiro Shimizu |
890ddd |
③ シグナルQGraphicsScene::selectionChanged()がエミットされ
|
|
Toshihiro Shimizu |
890ddd |
④ スロットFxSchematticScene::onSelectionChanged()が呼ばれ
|
|
Toshihiro Shimizu |
890ddd |
その中で、いったんselectNone()され、その後選択ノードが追加される。
|
|
Toshihiro Shimizu |
890ddd |
ここにいたるまでにm_selectionが正しく更新される保障が無い。
|
|
Toshihiro Shimizu |
890ddd |
よって、選択Fx無しと勘違いして、FxSettingsが更新されないおそれがある。
|
|
Toshihiro Shimizu |
890ddd |
そこで、m_selection->isEmpty()では無く、QGraphicsScene::selectedItems()の個数で
|
|
Toshihiro Shimizu |
890ddd |
直接判断することにする
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
if (selectedItems().isEmpty()) {
|
|
Toshihiro Shimizu |
890ddd |
if (me->button() != Qt::MidButton && !item)
|
|
Toshihiro Shimizu |
890ddd |
m_fxHandle->setFx(0, false);
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
m_isConnected = false;
|
|
Toshihiro Shimizu |
890ddd |
if (!canDisconnectSelection(m_selection))
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
m_selectionOldPos.clear();
|
|
Toshihiro Shimizu |
890ddd |
QList<tfxp> selectedFxs = m_selection->getFxs();</tfxp>
|
|
Toshihiro Shimizu |
890ddd |
int i;
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < selectedFxs.size(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
TFxP selectedFx = selectedFxs[i];
|
|
Toshihiro Shimizu |
890ddd |
TPointD pos = selectedFx->getAttributes()->getDagNodePos();
|
|
Toshihiro Shimizu |
890ddd |
m_selectionOldPos.append(QPair<tfxp, tpointd="">(selectedFx, pos));</tfxp,>
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
FxsData fxsData;
|
|
Toshihiro Shimizu |
890ddd |
fxsData.setFxs(m_selection->getFxs(), m_selection->getLinks(),
|
|
Toshihiro Shimizu |
890ddd |
m_selection->getColumnIndexes(), m_xshHandle->getXsheet());
|
|
Toshihiro Shimizu |
890ddd |
if (fxsData.isConnected() && me->button() == Qt::LeftButton && !port && !link)
|
|
Toshihiro Shimizu |
890ddd |
m_isConnected = true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::mouseMoveEvent(QGraphicsSceneMouseEvent *me)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
SchematicScene::mouseMoveEvent(me);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_lastPos = me->scenePos();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool leftButton = (QApplication::mouseButtons() == Qt::LeftButton);
|
|
Toshihiro Shimizu |
890ddd |
bool altButton = (QApplication::keyboardModifiers() == Qt::AltModifier);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (leftButton && m_isConnected && altButton) {
|
|
Toshihiro Shimizu |
890ddd |
m_linkUnlinkSimulation = true;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
simulateDisconnectSelection(true);
|
|
Toshihiro Shimizu |
890ddd |
m_connectionLinks.showBridgeLinks();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#if QT_VERSION >= 0x050000
|
|
Toshihiro Shimizu |
890ddd |
SchematicLink *link = dynamic_cast<schematiclink *="">(itemAt(m_lastPos, QTransform()));</schematiclink>
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
SchematicLink *link = dynamic_cast<schematiclink *="">(itemAt(m_lastPos));</schematiclink>
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
if (link && (link->getEndPort() && link->getStartPort())) {
|
|
Toshihiro Shimizu |
890ddd |
TFxCommand::Link fxLink = m_selection->getBoundingFxs(link);
|
|
Toshihiro Shimizu |
890ddd |
if (fxLink == TFxCommand::Link())
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFx *inputFx = fxLink.m_inputFx.getPointer();
|
|
Toshihiro Shimizu |
890ddd |
TFx *outputFx = fxLink.m_outputFx.getPointer();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFxSet *internalFxs = getXsheet()->getFxDag()->getInternalFxs();
|
|
Toshihiro Shimizu |
890ddd |
if (!internalFxs->containsFx(inputFx) && !dynamic_cast<tcolumnfx *="">(inputFx) &&</tcolumnfx>
|
|
Toshihiro Shimizu |
890ddd |
!dynamic_cast<txsheetfx *="">(inputFx) && !dynamic_cast<toutputfx *="">(inputFx))</toutputfx></txsheetfx>
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
if (!internalFxs->containsFx(outputFx) && !dynamic_cast<tcolumnfx *="">(outputFx) &&</tcolumnfx>
|
|
Toshihiro Shimizu |
890ddd |
!dynamic_cast<txsheetfx *="">(outputFx) && !dynamic_cast<toutputfx *="">(outputFx))</toutputfx></txsheetfx>
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_connectionLinks.hideBridgeLinks();
|
|
Toshihiro Shimizu |
890ddd |
simulateInsertSelection(link, altButton && !!link);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *me)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
SchematicScene::mouseReleaseEvent(me);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_linkUnlinkSimulation = false;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if ((m_disconnectionLinks.size() == 0) && (m_connectionLinks.size() == 0))
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TUndoManager::manager()->beginBlock();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool altButton = QApplication::keyboardModifiers() == Qt::AltModifier;
|
|
Toshihiro Shimizu |
890ddd |
if (altButton && m_isConnected) {
|
|
Toshihiro Shimizu |
890ddd |
if (m_connectionLinks.size() > 0) {
|
|
Toshihiro Shimizu |
890ddd |
const QList<schematiclink *=""> &bridgeLinks = m_connectionLinks.getBridgeLinks();</schematiclink>
|
|
Toshihiro Shimizu |
890ddd |
assert(bridgeLinks.size() <= 1);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
SchematicLink *link = bridgeLinks[0];
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (link) {
|
|
Toshihiro Shimizu |
890ddd |
FxSchematicNode *outputNode = dynamic_cast<fxschematicnode *="">(link->getEndPort()->getNode());</fxschematicnode>
|
|
Toshihiro Shimizu |
890ddd |
FxSchematicNode *inputNode = dynamic_cast<fxschematicnode *="">(link->getStartPort()->getNode());</fxschematicnode>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (inputNode && outputNode) {
|
|
Toshihiro Shimizu |
890ddd |
SchematicPort *port = link->getStartPort();
|
|
Toshihiro Shimizu |
890ddd |
if (port->getType() == 200 || port->getType() == 204)
|
|
Toshihiro Shimizu |
890ddd |
port = link->getOtherPort(port);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int i;
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < outputNode->getInputPortCount(); i++)
|
|
Toshihiro Shimizu |
890ddd |
if (port == outputNode->getInputPort(i))
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFxCommand::Link fxLink;
|
|
Toshihiro Shimizu |
890ddd |
fxLink.m_outputFx = outputNode->getFx();
|
|
Toshihiro Shimizu |
890ddd |
fxLink.m_inputFx = inputNode->getFx();
|
|
Toshihiro Shimizu |
890ddd |
if (!outputNode->isA(eXSheetFx))
|
|
Toshihiro Shimizu |
890ddd |
fxLink.m_index = i;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFxCommand::connectFxs(fxLink, m_selection->getFxs().toStdList(), m_xshHandle, m_selectionOldPos);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
} else if (m_disconnectionLinks.size() > 0) {
|
|
Toshihiro Shimizu |
890ddd |
QList<tfxp> fxs = m_selection->getFxs();</tfxp>
|
|
Toshihiro Shimizu |
890ddd |
TFxCommand::disconnectFxs(fxs.toStdList(), m_xshHandle, m_selectionOldPos);
|
|
Toshihiro Shimizu |
890ddd |
m_selectionOldPos.clear();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TUndoManager::manager()->endBlock();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_isConnected = false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool FxSchematicScene::event(QEvent *e)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
bool ret = SchematicScene::event(e);
|
|
Toshihiro Shimizu |
890ddd |
bool altPressed = QApplication::keyboardModifiers() == Qt::AltModifier;
|
|
Toshihiro Shimizu |
890ddd |
if (m_linkUnlinkSimulation && m_altPressed != altPressed)
|
|
Toshihiro Shimizu |
890ddd |
onAltModifierChanged(altPressed);
|
|
Toshihiro Shimizu |
890ddd |
m_altPressed = altPressed;
|
|
Toshihiro Shimizu |
890ddd |
return ret;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::onInsertPaste()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (!m_selection->insertPasteSelection())
|
|
Toshihiro Shimizu |
890ddd |
DVGui::error(tr("Cannot Paste Insert a selection of unconnected FX nodes.\nSelect FX nodes and related links before copying or cutting the selection you want to paste."));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::onAddPaste()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (!m_selection->addPasteSelection())
|
|
Toshihiro Shimizu |
890ddd |
DVGui::error(tr("Cannot Paste Add a selection of unconnected FX nodes.\nSelect FX nodes and related links before copying or cutting the selection you want to paste."));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::onReplacePaste()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (!m_selection->replacePasteSelection())
|
|
Toshihiro Shimizu |
890ddd |
DVGui::error(tr("Cannot Paste Replace a selection of unconnected FX nodes.\nSelect FX nodes and related links before copying or cutting the selection you want to paste."));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::onAltModifierChanged(bool altPressed)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (altPressed) {
|
|
Toshihiro Shimizu |
890ddd |
if (m_disconnectionLinks.size() == 0 && m_linkUnlinkSimulation)
|
|
Toshihiro Shimizu |
890ddd |
simulateDisconnectSelection(altPressed);
|
|
Toshihiro Shimizu |
890ddd |
if (m_connectionLinks.size() == 0 && m_linkUnlinkSimulation) {
|
|
Toshihiro Shimizu |
890ddd |
m_connectionLinks.showBridgeLinks();
|
|
Toshihiro Shimizu |
890ddd |
#if QT_VERSION >= 0x050000
|
|
Toshihiro Shimizu |
890ddd |
SchematicLink *link = dynamic_cast<schematiclink *="">(itemAt(m_lastPos, QTransform()));</schematiclink>
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
SchematicLink *link = dynamic_cast<schematiclink *="">(itemAt(m_lastPos));</schematiclink>
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
if (link && (!link->getEndPort() || !link->getStartPort()))
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
m_connectionLinks.hideBridgeLinks();
|
|
Toshihiro Shimizu |
890ddd |
simulateInsertSelection(link, altPressed && !!link);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
if (m_disconnectionLinks.size() > 0 && m_linkUnlinkSimulation)
|
|
Toshihiro Shimizu |
890ddd |
simulateDisconnectSelection(altPressed);
|
|
Toshihiro Shimizu |
890ddd |
if (m_connectionLinks.size() > 0 && m_linkUnlinkSimulation) {
|
|
Toshihiro Shimizu |
890ddd |
m_connectionLinks.showBridgeLinks();
|
|
Toshihiro Shimizu |
890ddd |
#if QT_VERSION >= 0x050000
|
|
Toshihiro Shimizu |
890ddd |
SchematicLink *link = dynamic_cast<schematiclink *="">(itemAt(m_lastPos, QTransform()));</schematiclink>
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
SchematicLink *link = dynamic_cast<schematiclink *="">(itemAt(m_lastPos));</schematiclink>
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
if (link && (!link->getEndPort() || !link->getStartPort()))
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
m_connectionLinks.hideBridgeLinks();
|
|
Toshihiro Shimizu |
890ddd |
simulateInsertSelection(link, altPressed && !!link);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::onEditGroup()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_selection->isEmpty())
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
QList<tfxp> fxs = m_selection->getFxs();</tfxp>
|
|
Toshihiro Shimizu |
890ddd |
int i;
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < fxs.size(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
if (fxs[i]->getAttributes()->isGrouped() && !fxs[i]->getAttributes()->isGroupEditing()) {
|
|
Toshihiro Shimizu |
890ddd |
fxs[i]->getAttributes()->editGroup();
|
|
Toshihiro Shimizu |
890ddd |
TMacroFx *macro = dynamic_cast<tmacrofx *="">(fxs[i].getPointer());</tmacrofx>
|
|
Toshihiro Shimizu |
890ddd |
if (macro) {
|
|
Toshihiro Shimizu |
890ddd |
vector<tfxp> macroFxs = macro->getFxs();</tfxp>
|
|
Toshihiro Shimizu |
890ddd |
int j;
|
|
Toshihiro Shimizu |
890ddd |
for (j = 0; j < (int)macroFxs.size(); j++)
|
|
Toshihiro Shimizu |
890ddd |
macroFxs[j]->getAttributes()->editGroup();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
updateScene();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::highlightLinks(FxSchematicNode *node, bool value)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int i, portCount = node->getInputPortCount();
|
|
Toshihiro Shimizu |
890ddd |
//SchematicLink* ghostLink = m_supportLinks.getDisconnectionLink(eGhost);
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < portCount; i++) {
|
|
Toshihiro Shimizu |
890ddd |
FxSchematicPort *port = node->getInputPort(i);
|
|
Toshihiro Shimizu |
890ddd |
int j, linkCount = port->getLinkCount();
|
|
Toshihiro Shimizu |
890ddd |
for (j = 0; j < linkCount; j++) {
|
|
Toshihiro Shimizu |
890ddd |
SchematicLink *link = port->getLink(j);
|
|
Toshihiro Shimizu |
890ddd |
if (!link)
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
if (m_disconnectionLinks.isABridgeLink(link))
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
link->setHighlighted(value);
|
|
Toshihiro Shimizu |
890ddd |
link->update();
|
|
Toshihiro Shimizu |
890ddd |
m_highlightedLinks.push_back(link);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
FxSchematicPort *port = node->getOutputPort();
|
|
Toshihiro Shimizu |
890ddd |
if (port) {
|
|
Toshihiro Shimizu |
890ddd |
int linkCount = port->getLinkCount();
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < linkCount; i++) {
|
|
Toshihiro Shimizu |
890ddd |
SchematicLink *link = port->getLink(i);
|
|
Toshihiro Shimizu |
890ddd |
if (!link)
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
if (m_disconnectionLinks.isABridgeLink(link))
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
link->setHighlighted(value);
|
|
Toshihiro Shimizu |
890ddd |
link->update();
|
|
Toshihiro Shimizu |
890ddd |
m_highlightedLinks.push_back(link);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
port = node->getLinkPort();
|
|
Toshihiro Shimizu |
890ddd |
if (port) {
|
|
Toshihiro Shimizu |
890ddd |
SchematicLink *link = port->getLink(0);
|
|
Toshihiro Shimizu |
890ddd |
if (link && !m_disconnectionLinks.isABridgeLink(link)) {
|
|
Toshihiro Shimizu |
890ddd |
link->setHighlighted(value);
|
|
Toshihiro Shimizu |
890ddd |
link->update();
|
|
Toshihiro Shimizu |
890ddd |
m_highlightedLinks.push_back(link);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::simulateDisconnectSelection(bool disconnect)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_selection->isEmpty())
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
QList<tfxp> selectedFxs = m_selection->getFxs();</tfxp>
|
|
Toshihiro Shimizu |
890ddd |
if (selectedFxs.isEmpty())
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
QMap<tfx *,="" bool=""> visitedFxs;</tfx>
|
|
Toshihiro Shimizu |
890ddd |
int i;
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < selectedFxs.size(); i++)
|
|
Toshihiro Shimizu |
890ddd |
visitedFxs[selectedFxs[i].getPointer()] = false;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFx *inputFx = 0, *outputFx = 0;
|
|
Toshihiro Shimizu |
890ddd |
findBoundariesFxs(inputFx, outputFx, visitedFxs);
|
|
Toshihiro Shimizu |
890ddd |
FxSchematicNode *inputNode = m_table[inputFx];
|
|
Toshihiro Shimizu |
890ddd |
FxSchematicNode *outputNode = m_table[outputFx];
|
|
Toshihiro Shimizu |
890ddd |
assert(inputNode && outputNode);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
FxSchematicPort *inputPort = 0, *outputPort = 0;
|
|
Toshihiro Shimizu |
890ddd |
SchematicPort *otherInputPort = 0;
|
|
Toshihiro Shimizu |
890ddd |
QList<schematicport *=""> otherOutputPorts;</schematicport>
|
|
Toshihiro Shimizu |
890ddd |
if (inputNode->getInputPortCount() > 0) {
|
|
Toshihiro Shimizu |
890ddd |
inputPort = inputNode->getInputPort(0);
|
|
Toshihiro Shimizu |
890ddd |
if (inputPort) {
|
|
Toshihiro Shimizu |
890ddd |
SchematicLink *inputLink = inputPort->getLink(0);
|
|
Toshihiro Shimizu |
890ddd |
if (inputLink && !m_connectionLinks.isAnInputLink(inputLink)) {
|
|
Toshihiro Shimizu |
890ddd |
if (!m_disconnectionLinks.isAnInputLink(inputLink))
|
|
Toshihiro Shimizu |
890ddd |
m_disconnectionLinks.addInputLink(inputLink);
|
|
Toshihiro Shimizu |
890ddd |
otherInputPort = inputLink->getOtherPort(inputPort);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
outputPort = outputNode->getOutputPort();
|
|
Toshihiro Shimizu |
890ddd |
if (outputPort) {
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < outputPort->getLinkCount(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
SchematicLink *outputLink = outputPort->getLink(i);
|
|
Toshihiro Shimizu |
890ddd |
if (outputLink && !m_connectionLinks.isAnOutputLink(outputLink)) {
|
|
Toshihiro Shimizu |
890ddd |
if (!m_disconnectionLinks.isAnOutputLink(outputLink))
|
|
Toshihiro Shimizu |
890ddd |
m_disconnectionLinks.addOutputLink(outputLink);
|
|
Toshihiro Shimizu |
890ddd |
otherOutputPorts.push_back(outputLink->getOtherPort(outputPort));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (disconnect) {
|
|
Toshihiro Shimizu |
890ddd |
m_disconnectionLinks.hideInputLinks();
|
|
Toshihiro Shimizu |
890ddd |
m_disconnectionLinks.hideOutputLinks();
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
m_disconnectionLinks.showInputLinks();
|
|
Toshihiro Shimizu |
890ddd |
m_disconnectionLinks.showOutputLinks();
|
|
Toshihiro Shimizu |
890ddd |
m_disconnectionLinks.removeInputLinks();
|
|
Toshihiro Shimizu |
890ddd |
m_disconnectionLinks.removeOutputLinks();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (otherInputPort) {
|
|
Toshihiro Shimizu |
890ddd |
if (disconnect) {
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < otherOutputPorts.size(); i++)
|
|
Toshihiro Shimizu |
890ddd |
m_disconnectionLinks.addBridgeLink(otherOutputPorts[i]->makeLink(otherInputPort));
|
|
Toshihiro Shimizu |
890ddd |
} else
|
|
Toshihiro Shimizu |
890ddd |
m_disconnectionLinks.removeBridgeLinks(true);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::simulateInsertSelection(SchematicLink *link, bool connect)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (!link) {
|
|
Toshihiro Shimizu |
890ddd |
m_connectionLinks.showBridgeLinks();
|
|
Toshihiro Shimizu |
890ddd |
m_connectionLinks.hideInputLinks();
|
|
Toshihiro Shimizu |
890ddd |
m_connectionLinks.hideOutputLinks();
|
|
Toshihiro Shimizu |
890ddd |
m_connectionLinks.removeBridgeLinks();
|
|
Toshihiro Shimizu |
890ddd |
m_connectionLinks.removeInputLinks(true);
|
|
Toshihiro Shimizu |
890ddd |
m_connectionLinks.removeOutputLinks(true);
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
if (m_disconnectionLinks.isABridgeLink(link) || m_selection->isEmpty())
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (connect) {
|
|
Toshihiro Shimizu |
890ddd |
m_connectionLinks.addBridgeLink(link);
|
|
Toshihiro Shimizu |
890ddd |
m_connectionLinks.hideBridgeLinks();
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
m_connectionLinks.showBridgeLinks();
|
|
Toshihiro Shimizu |
890ddd |
m_connectionLinks.removeBridgeLinks();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
SchematicPort *inputPort = 0, *outputPort = 0;
|
|
Toshihiro Shimizu |
890ddd |
if (link) {
|
|
Toshihiro Shimizu |
890ddd |
if (link->getStartPort()->getType() == eFxInputPort) {
|
|
Toshihiro Shimizu |
890ddd |
inputPort = link->getStartPort();
|
|
Toshihiro Shimizu |
890ddd |
outputPort = link->getEndPort();
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
inputPort = link->getEndPort();
|
|
Toshihiro Shimizu |
890ddd |
outputPort = link->getStartPort();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QMap<tfx *,="" bool=""> visitedFxs;</tfx>
|
|
Toshihiro Shimizu |
890ddd |
QList<tfxp> selectedFxs = m_selection->getFxs();</tfxp>
|
|
Toshihiro Shimizu |
890ddd |
if (selectedFxs.isEmpty())
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
int i;
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < selectedFxs.size(); i++)
|
|
Toshihiro Shimizu |
890ddd |
visitedFxs[selectedFxs[i].getPointer()] = false;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFx *inputFx = 0, *outputFx = 0;
|
|
Toshihiro Shimizu |
890ddd |
findBoundariesFxs(inputFx, outputFx, visitedFxs);
|
|
Toshihiro Shimizu |
890ddd |
FxSchematicNode *inputNode = m_table[inputFx];
|
|
Toshihiro Shimizu |
890ddd |
FxSchematicNode *outputNode = m_table[outputFx];
|
|
Toshihiro Shimizu |
890ddd |
assert(inputNode && outputNode);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (inputNode->getInputPortCount() > 0) {
|
|
Toshihiro Shimizu |
890ddd |
SchematicPort *inputNodePort = inputNode->getInputPort(0);
|
|
Toshihiro Shimizu |
890ddd |
if (inputNodePort && outputPort)
|
|
Toshihiro Shimizu |
890ddd |
m_connectionLinks.addInputLink(inputNodePort->makeLink(outputPort));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
SchematicPort *outputNodePort = outputNode->getOutputPort();
|
|
Toshihiro Shimizu |
890ddd |
if (outputNodePort && inputPort)
|
|
Toshihiro Shimizu |
890ddd |
m_connectionLinks.addOutputLink(inputPort->makeLink(outputNodePort));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (connect) {
|
|
Toshihiro Shimizu |
890ddd |
m_connectionLinks.showInputLinks();
|
|
Toshihiro Shimizu |
890ddd |
m_connectionLinks.showOutputLinks();
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
m_connectionLinks.hideInputLinks();
|
|
Toshihiro Shimizu |
890ddd |
m_connectionLinks.hideOutputLinks();
|
|
Toshihiro Shimizu |
890ddd |
m_connectionLinks.removeInputLinks(true);
|
|
Toshihiro Shimizu |
890ddd |
m_connectionLinks.removeOutputLinks(true);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! in order to select nods after pasting the copied fx nodes from FxSelection
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::selectNodes(QList<tfxp> &fxs)</tfxp>
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
clearSelection();
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0; i < (int)fxs.size(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
TFx *tempFx = fxs[i].getPointer();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QMap<tfx *="" *,="" fxschematicnode="">::iterator it;</tfx>
|
|
Toshihiro Shimizu |
890ddd |
it = m_table.find(tempFx);
|
|
Toshihiro Shimizu |
890ddd |
if (it == m_table.end())
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
it.value()->setSelected(true);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
update();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::updateNestedGroupEditors(FxSchematicNode *node, const QPointF &newPos)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (!node)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
QStack<int> groupIdStack = node->getFx()->getAttributes()->getGroupIdStack();</int>
|
|
Toshihiro Shimizu |
890ddd |
int i;
|
|
Toshihiro Shimizu |
890ddd |
QRectF rect;
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < groupIdStack.size(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
if (m_groupEditorTable.contains(groupIdStack[i])) {
|
|
Toshihiro Shimizu |
890ddd |
QRectF app = m_groupEditorTable[groupIdStack[i]]->sceneBoundingRect();
|
|
Toshihiro Shimizu |
890ddd |
if (rect.isEmpty())
|
|
Toshihiro Shimizu |
890ddd |
rect = app;
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
#if QT_VERSION >= 0x050000
|
|
Toshihiro Shimizu |
890ddd |
rect = rect.united(app);
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
rect = rect.unite(app);
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
QMap<tmacrofx *="" *,="" fxschematicmacroeditor="">::iterator it;</tmacrofx>
|
|
Toshihiro Shimizu |
890ddd |
for (it = m_macroEditorTable.begin(); it != m_macroEditorTable.end(); it++) {
|
|
Toshihiro Shimizu |
890ddd |
if (it.value()->contains(node)) {
|
|
Toshihiro Shimizu |
890ddd |
QRectF app = it.value()->sceneBoundingRect();
|
|
Toshihiro Shimizu |
890ddd |
if (rect.isEmpty())
|
|
Toshihiro Shimizu |
890ddd |
rect = app;
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
#if QT_VERSION >= 0x050000
|
|
Toshihiro Shimizu |
890ddd |
rect = rect.united(app);
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
rect = rect.unite(app);
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
node->setPos(newPos);
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < groupIdStack.size(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
if (!m_groupEditorTable.contains(groupIdStack[i]))
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
#if QT_VERSION >= 0x050000
|
|
Toshihiro Shimizu |
890ddd |
rect = rect.united(m_groupEditorTable[groupIdStack[i]]->sceneBoundingRect());
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
rect = rect.unite(m_groupEditorTable[groupIdStack[i]]->sceneBoundingRect());
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
QRectF app = m_groupEditorTable[groupIdStack[i]]->boundingSceneRect();
|
|
Toshihiro Shimizu |
890ddd |
if (m_groupEditorTable[groupIdStack[i]]->scenePos() != app.topLeft())
|
|
Toshihiro Shimizu |
890ddd |
m_groupEditorTable[groupIdStack[i]]->setPos(app.topLeft());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
for (it = m_macroEditorTable.begin(); it != m_macroEditorTable.end(); it++) {
|
|
Toshihiro Shimizu |
890ddd |
FxSchematicMacroEditor *editor = it.value();
|
|
Toshihiro Shimizu |
890ddd |
if (editor->contains(node)) {
|
|
Toshihiro Shimizu |
890ddd |
QRectF app = editor->sceneBoundingRect();
|
|
Toshihiro Shimizu |
890ddd |
#if QT_VERSION >= 0x050000
|
|
Toshihiro Shimizu |
890ddd |
rect = rect.united(app);
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
rect = rect.unite(app);
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
app = editor->boundingSceneRect();
|
|
Toshihiro Shimizu |
890ddd |
if (editor->scenePos() != app.topLeft())
|
|
Toshihiro Shimizu |
890ddd |
editor->setPos(app.topLeft());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
update(rect);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::closeInnerMacroEditor(int groupId)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(m_groupEditorTable.contains(groupId));
|
|
Toshihiro Shimizu |
890ddd |
QMap<tmacrofx *="" *,="" fxschematicmacroeditor="">::iterator it;</tmacrofx>
|
|
Toshihiro Shimizu |
890ddd |
for (it = m_macroEditorTable.begin(); it != m_macroEditorTable.end(); it++) {
|
|
Toshihiro Shimizu |
890ddd |
TMacroFx *macro = it.key();
|
|
Toshihiro Shimizu |
890ddd |
assert(macro);
|
|
Toshihiro Shimizu |
890ddd |
if (macro->getAttributes()->isContainedInGroup(groupId)) {
|
|
Toshihiro Shimizu |
890ddd |
macro->editMacro(false);
|
|
Toshihiro Shimizu |
890ddd |
macro->getAttributes()->closeEditingGroup(groupId);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::resizeNodes(bool maximizedNode)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
//resize nodes
|
|
Toshihiro Shimizu |
890ddd |
m_gridDimension = maximizedNode ? eLarge : eSmall;
|
|
Toshihiro Shimizu |
890ddd |
m_xshHandle->getXsheet()->getFxDag()->setDagGridDimension(m_gridDimension);
|
|
Toshihiro Shimizu |
890ddd |
QMap<tfx *="" *,="" fxschematicnode="">::iterator it1;</tfx>
|
|
Toshihiro Shimizu |
890ddd |
for (it1 = m_table.begin(); it1 != m_table.end(); it1++) {
|
|
Toshihiro Shimizu |
890ddd |
if (!it1.value())
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
it1.value()->resize(maximizedNode);
|
|
Toshihiro Shimizu |
890ddd |
TFx *fx = it1.value()->getFx();
|
|
Toshihiro Shimizu |
890ddd |
updatePositionOnResize(fx, maximizedNode);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
QMap<int, *="" fxgroupnode="">::iterator it2;</int,>
|
|
Toshihiro Shimizu |
890ddd |
for (it2 = m_groupedTable.begin(); it2 != m_groupedTable.end(); it2++) {
|
|
Toshihiro Shimizu |
890ddd |
if (!it2.value())
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
it2.value()->resize(maximizedNode);
|
|
Toshihiro Shimizu |
890ddd |
QList<tfxp> groupedFxs = it2.value()->getGroupedFxs();</tfxp>
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0; i < groupedFxs.size(); i++)
|
|
Toshihiro Shimizu |
890ddd |
updatePositionOnResize(groupedFxs[i].getPointer(), maximizedNode);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QMap<tmacrofx *="" *,="" fxschematicmacroeditor="">::iterator it3;</tmacrofx>
|
|
Toshihiro Shimizu |
890ddd |
for (it3 = m_macroEditorTable.begin(); it3 != m_macroEditorTable.end(); it3++) {
|
|
Toshihiro Shimizu |
890ddd |
if (!it3.value())
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
it3.value()->resizeNodes(maximizedNode);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
updateScene();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxSchematicScene::updatePositionOnResize(TFx *fx, bool maximizedNode)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TPointD oldPos = fx->getAttributes()->getDagNodePos();
|
|
Toshihiro Shimizu |
890ddd |
double oldPosY = oldPos.y - 25000;
|
|
Toshihiro Shimizu |
890ddd |
double newPosY = maximizedNode ? oldPosY * 2 : oldPosY * 0.5;
|
|
Toshihiro Shimizu |
890ddd |
fx->getAttributes()->setDagNodePos(TPointD(oldPos.x, newPosY + 25000));
|
|
Toshihiro Shimizu |
890ddd |
}
|