|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/schematicgroupeditor.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/fxschematicnode.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/fxschematicscene.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/stageschematicnode.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/stageschematicscene.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/schematicnode.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/gutil.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/fxcommand.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tstageobjectcmd.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tstageobject.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tfxattributes.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tmacrofx.h"
|
|
Toshihiro Shimizu |
890ddd |
#include <qaction></qaction>
|
|
Toshihiro Shimizu |
890ddd |
#include <qmenu></qmenu>
|
|
Toshihiro Shimizu |
890ddd |
#include <qgraphicsscenecontextmenuevent></qgraphicsscenecontextmenuevent>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=====================================================
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Shinya Kitaoka |
120a6e |
// SchematicGroupEditor
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//=====================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
SchematicWindowEditor::SchematicWindowEditor(
|
|
Shinya Kitaoka |
120a6e |
const QList<schematicnode *=""> &groupedNode, SchematicScene *scene)</schematicnode>
|
|
Shinya Kitaoka |
120a6e |
: QGraphicsItem()
|
|
Shinya Kitaoka |
120a6e |
, m_groupedNode(groupedNode)
|
|
Shinya Kitaoka |
120a6e |
, m_scene(scene)
|
|
Shinya Kitaoka |
120a6e |
, m_lastPos()
|
|
Shinya Kitaoka |
120a6e |
, m_button(Qt::NoButton)
|
|
Shinya Kitaoka |
120a6e |
, m_isMacroEditor(false) {
|
|
Shinya Kitaoka |
120a6e |
scene->addItem(this);
|
|
Shinya Kitaoka |
120a6e |
m_nameItem = new SchematicName(this, 67, 14);
|
|
Shinya Kitaoka |
120a6e |
m_nameItem->setPos(-2, -2);
|
|
Shinya Kitaoka |
120a6e |
m_nameItem->setZValue(1);
|
|
Shinya Kitaoka |
120a6e |
m_nameItem->hide();
|
|
Shinya Kitaoka |
120a6e |
connect(m_nameItem, SIGNAL(focusOut()), this, SLOT(onNameChanged()));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
SchematicWindowEditor::~SchematicWindowEditor() {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QRectF SchematicWindowEditor::boundingRect() const {
|
|
Shinya Kitaoka |
120a6e |
QRectF rect = boundingSceneRect();
|
|
Shinya Kitaoka |
120a6e |
rect.moveTopLeft(QPointF(0, 0));
|
|
Shinya Kitaoka |
120a6e |
rect.adjust(-1, -1, 1, 1);
|
|
Shinya Kitaoka |
120a6e |
return rect;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SchematicWindowEditor::paint(QPainter *painter,
|
|
Shinya Kitaoka |
120a6e |
const QStyleOptionGraphicsItem *option,
|
|
Shinya Kitaoka |
120a6e |
QWidget *widget) {
|
|
Shinya Kitaoka |
120a6e |
painter->setPen(QColor(0, 0, 0, 255));
|
|
Shinya Kitaoka |
120a6e |
if (m_isMacroEditor)
|
|
Shinya Kitaoka |
120a6e |
painter->setBrush(QColor(132, 86, 123, 255));
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
painter->setBrush(QColor(76, 148, 177, 255));
|
|
Shinya Kitaoka |
120a6e |
QRectF bRect = boundingRect();
|
|
Shinya Kitaoka |
120a6e |
QRectF rect(0, 0, bRect.width(), 15);
|
|
Shinya Kitaoka |
120a6e |
painter->drawRect(rect);
|
|
Shinya Kitaoka |
120a6e |
rect = QRectF(0, 15, bRect.width(), bRect.height() - 15);
|
|
Shinya Kitaoka |
120a6e |
painter->setBrush(QColor(180, 180, 180, 125));
|
|
Shinya Kitaoka |
120a6e |
painter->drawRect(rect);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// draw the topRight cross
|
|
Shinya Kitaoka |
120a6e |
rect = QRectF(0, 0, 11, 11);
|
|
Shinya Kitaoka |
120a6e |
rect.moveTopLeft(QPointF(bRect.width() - 13, 2));
|
|
Shinya Kitaoka |
120a6e |
painter->drawRoundedRect(rect, 2, 2);
|
|
Shinya Kitaoka |
120a6e |
painter->setPen(Qt::black);
|
|
Shinya Kitaoka |
120a6e |
painter->drawLine(QPointF(rect.left() + 2, rect.top() + 2),
|
|
Shinya Kitaoka |
120a6e |
QPointF(rect.right() - 2, rect.bottom() - 2));
|
|
Shinya Kitaoka |
120a6e |
painter->drawLine(QPointF(rect.left() + 2, rect.bottom() - 2),
|
|
Shinya Kitaoka |
120a6e |
QPointF(rect.right() - 2, rect.top() + 2));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (!m_nameItem->isVisible()) {
|
|
Shinya Kitaoka |
120a6e |
painter->setPen(Qt::white);
|
|
Shinya Kitaoka |
120a6e |
QFont font("Verdana", 7);
|
|
Shinya Kitaoka |
120a6e |
painter->setFont(font);
|
|
Shinya Kitaoka |
120a6e |
QRectF rect = QRectF(2, 1, bRect.width() - 15, 13);
|
|
Shinya Kitaoka |
120a6e |
QString elidedName = elideText(m_groupName, font, rect.width());
|
|
Shinya Kitaoka |
120a6e |
painter->drawText(rect, elidedName);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SchematicWindowEditor::resizeNodes(bool maximizeNodes) {
|
|
Shinya Kitaoka |
120a6e |
prepareGeometryChange();
|
|
Shinya Kitaoka |
120a6e |
doResizeNodes(maximizeNodes);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SchematicWindowEditor::mousePressEvent(QGraphicsSceneMouseEvent *e) {
|
|
Shinya Kitaoka |
120a6e |
QRectF bRect = boundingRect();
|
|
Shinya Kitaoka |
120a6e |
QRectF rect = QRectF(0, 0, 11, 11);
|
|
Shinya Kitaoka |
120a6e |
rect.moveTopLeft(QPointF(bRect.width() - 13, 2));
|
|
Shinya Kitaoka |
120a6e |
if (rect.contains(e->pos())) {
|
|
Shinya Kitaoka |
120a6e |
closeEditor();
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
rect = QRectF(0, 0, bRect.width(), 15);
|
|
Shinya Kitaoka |
120a6e |
if (rect.contains(e->pos())) {
|
|
Shinya Kitaoka |
120a6e |
m_button = e->button();
|
|
Shinya Kitaoka |
120a6e |
m_lastPos = e->scenePos();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SchematicWindowEditor::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
|
|
Shinya Kitaoka |
120a6e |
if (m_button == Qt::LeftButton) {
|
|
Shinya Kitaoka |
120a6e |
QPointF delta = e->scenePos() - m_lastPos;
|
|
Shinya Kitaoka |
120a6e |
setPos(scenePos() + delta);
|
|
Shinya Kitaoka |
120a6e |
m_lastPos = e->scenePos();
|
|
Shinya Kitaoka |
120a6e |
int i;
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < m_groupedNode.size(); i++) {
|
|
Shinya Kitaoka |
120a6e |
SchematicNode *node = m_groupedNode[i];
|
|
Shinya Kitaoka |
120a6e |
node->setPosition(node->scenePos() + delta);
|
|
Shinya Kitaoka |
120a6e |
node->setSchematicNodePos(node->scenePos());
|
|
Shinya Kitaoka |
120a6e |
node->updateLinksGeometry();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
} else
|
|
Shinya Kitaoka |
120a6e |
e->ignore();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SchematicWindowEditor::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
|
|
Shinya Kitaoka |
120a6e |
m_button = Qt::NoButton;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SchematicWindowEditor::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *e) {
|
|
Shinya Kitaoka |
120a6e |
QRectF bRect = boundingRect();
|
|
Shinya Kitaoka |
120a6e |
QRectF rect = QRectF(2, 0, bRect.width() - 15, 15);
|
|
Shinya Kitaoka |
120a6e |
if (rect.contains(e->pos())) {
|
|
Shinya Kitaoka |
120a6e |
m_nameItem->setPlainText(m_groupName);
|
|
Shinya Kitaoka |
120a6e |
m_nameItem->show();
|
|
Shinya Kitaoka |
120a6e |
m_nameItem->setFocus();
|
|
Shinya Kitaoka |
120a6e |
setFlag(QGraphicsItem::ItemIsSelectable, false);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SchematicWindowEditor::contextMenuEvent(
|
|
Shinya Kitaoka |
120a6e |
QGraphicsSceneContextMenuEvent *e) {
|
|
Shinya Kitaoka |
120a6e |
QRectF bRect = boundingRect();
|
|
Shinya Kitaoka |
120a6e |
QRectF rect(0, 0, bRect.width(), 15);
|
|
Shinya Kitaoka |
120a6e |
if (!rect.contains(e->pos())) {
|
|
Shinya Kitaoka |
120a6e |
e->ignore();
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
QMenu menu(scene()->views()[0]);
|
|
Shinya Kitaoka |
120a6e |
QAction *close = new QAction(tr("&Close Editor"), &menu);
|
|
Shinya Kitaoka |
120a6e |
connect(close, SIGNAL(triggered()), this, SLOT(closeEditor()));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
menu.addAction(close);
|
|
Shinya Kitaoka |
120a6e |
menu.exec(e->screenPos());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=====================================================
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Shinya Kitaoka |
120a6e |
// FxSchematicGroupEditor
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//=====================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
FxSchematicGroupEditor::FxSchematicGroupEditor(
|
|
Shinya Kitaoka |
120a6e |
int groupId, const QList<schematicnode *=""> &groupedNode,</schematicnode>
|
|
Shinya Kitaoka |
120a6e |
SchematicScene *scene)
|
|
Shinya Kitaoka |
120a6e |
: SchematicWindowEditor(groupedNode, scene), m_groupId(groupId) {
|
|
Shinya Kitaoka |
120a6e |
initializeEditor();
|
|
Shinya Kitaoka |
120a6e |
setPos(boundingSceneRect().topLeft());
|
|
Shinya Kitaoka |
120a6e |
m_nameItem->setName(m_groupName);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
FxSchematicGroupEditor::~FxSchematicGroupEditor() {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void FxSchematicGroupEditor::initializeEditor() {
|
|
Shinya Kitaoka |
120a6e |
FxSchematicNode *node = dynamic_cast<fxschematicnode *="">(m_groupedNode[0]);</fxschematicnode>
|
|
Shinya Kitaoka |
120a6e |
assert(node);
|
|
Shinya Kitaoka |
120a6e |
TFx *fx = node->getFx();
|
|
Shinya Kitaoka |
120a6e |
assert(fx);
|
|
Shinya Kitaoka |
120a6e |
assert(m_groupId == fx->getAttributes()->getEditingGroupId());
|
|
Shinya Kitaoka |
120a6e |
m_groupName =
|
|
Shinya Kitaoka |
120a6e |
QString::fromStdWString(fx->getAttributes()->getEditingGroupName());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void FxSchematicGroupEditor::closeEditor() {
|
|
Shinya Kitaoka |
120a6e |
// Ptrebbero esserci delle macro aperte per edit nel gruppo...
|
|
Shinya Kitaoka |
120a6e |
// devo chiedere alla scena di chiuderle per me... da qui non posso farlo!
|
|
Shinya Kitaoka |
120a6e |
FxSchematicScene *fxScene = dynamic_cast<fxschematicscene *="">(scene());</fxschematicscene>
|
|
Shinya Kitaoka |
120a6e |
assert(fxScene);
|
|
Shinya Kitaoka |
120a6e |
fxScene->closeInnerMacroEditor(m_groupId);
|
|
Shinya Kitaoka |
120a6e |
int i;
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < m_groupedNode.size(); i++) {
|
|
Shinya Kitaoka |
120a6e |
FxSchematicNode *node = dynamic_cast<fxschematicnode *="">(m_groupedNode[i]);</fxschematicnode>
|
|
Shinya Kitaoka |
120a6e |
if (!node) continue;
|
|
Shinya Kitaoka |
120a6e |
FxGroupNode *groupNode = dynamic_cast<fxgroupnode *="">(node);</fxgroupnode>
|
|
Shinya Kitaoka |
120a6e |
if (groupNode) {
|
|
Shinya Kitaoka |
120a6e |
QList<tfxp> fxs = groupNode->getGroupedFxs();</tfxp>
|
|
Shinya Kitaoka |
120a6e |
assert(!fxs.isEmpty());
|
|
Shinya Kitaoka |
120a6e |
int j;
|
|
Shinya Kitaoka |
120a6e |
for (j = 0; j < fxs.size(); j++) {
|
|
Shinya Kitaoka |
120a6e |
fxs[j]->getAttributes()->closeEditingGroup(m_groupId);
|
|
Shinya Kitaoka |
120a6e |
TMacroFx *macro = dynamic_cast<tmacrofx *="">(fxs[j].getPointer());</tmacrofx>
|
|
Shinya Kitaoka |
120a6e |
if (macro) {
|
|
Shinya Kitaoka |
120a6e |
std::vector<tfxp> macroFxs = macro->getFxs();</tfxp>
|
|
Shinya Kitaoka |
120a6e |
int j;
|
|
Shinya Kitaoka |
120a6e |
for (j = 0; j < (int)macroFxs.size(); j++)
|
|
Shinya Kitaoka |
120a6e |
macroFxs[j]->getAttributes()->closeEditingGroup(m_groupId);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
TFx *fx = node->getFx();
|
|
Shinya Kitaoka |
120a6e |
assert(fx);
|
|
Shinya Kitaoka |
120a6e |
fx->getAttributes()->closeEditingGroup(m_groupId);
|
|
Shinya Kitaoka |
120a6e |
TMacroFx *macro = dynamic_cast<tmacrofx *="">(fx);</tmacrofx>
|
|
Shinya Kitaoka |
120a6e |
if (macro) {
|
|
Shinya Kitaoka |
120a6e |
std::vector<tfxp> macroFxs = macro->getFxs();</tfxp>
|
|
Shinya Kitaoka |
120a6e |
int j;
|
|
Shinya Kitaoka |
120a6e |
for (j = 0; j < (int)macroFxs.size(); j++)
|
|
Shinya Kitaoka |
120a6e |
macroFxs[j]->getAttributes()->closeEditingGroup(m_groupId);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
m_scene->updateScene();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void FxSchematicGroupEditor::onNameChanged() {
|
|
Shinya Kitaoka |
120a6e |
int i;
|
|
Shinya Kitaoka |
120a6e |
QList<tfxp> fxs;</tfxp>
|
|
Shinya Kitaoka |
120a6e |
m_nameItem->hide();
|
|
Shinya Kitaoka |
120a6e |
m_groupName = m_nameItem->toPlainText();
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < m_groupedNode.size(); i++) {
|
|
Shinya Kitaoka |
120a6e |
FxGroupNode *groupNode = dynamic_cast<fxgroupnode *="">(m_groupedNode[i]);</fxgroupnode>
|
|
Shinya Kitaoka |
120a6e |
FxSchematicNode *node = dynamic_cast<fxschematicnode *="">(m_groupedNode[i]);</fxschematicnode>
|
|
Shinya Kitaoka |
120a6e |
if (groupNode)
|
|
Shinya Kitaoka |
120a6e |
fxs.append(groupNode->getGroupedFxs());
|
|
Shinya Kitaoka |
120a6e |
else if (node)
|
|
Shinya Kitaoka |
120a6e |
fxs.append(node->getFx());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
setFlag(QGraphicsItem::ItemIsSelectable, true);
|
|
Shinya Kitaoka |
120a6e |
FxSchematicScene *fxScene = dynamic_cast<fxschematicscene *="">(scene());</fxschematicscene>
|
|
Shinya Kitaoka |
120a6e |
if (!fxScene) return;
|
|
shun-iwasawa |
443318 |
TFxCommand::renameGroup(std::list<tfxp>(fxs.begin(), fxs.end()),</tfxp>
|
|
shun-iwasawa |
443318 |
m_groupName.toStdWString(), true,
|
|
Shinya Kitaoka |
120a6e |
fxScene->getXsheetHandle());
|
|
Shinya Kitaoka |
120a6e |
update();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QRectF FxSchematicGroupEditor::boundingSceneRect() const {
|
|
Shinya Kitaoka |
120a6e |
QRectF rect = m_groupedNode[0]->boundingRect();
|
|
manongjohn |
adae7d |
QPointF shiftPos(m_groupedNode[0]->scenePos().x() - rect.left(),
|
|
manongjohn |
adae7d |
m_groupedNode[0]->scenePos().y() + rect.top() + 10);
|
|
manongjohn |
adae7d |
rect.moveTopLeft(shiftPos);
|
|
Shinya Kitaoka |
120a6e |
int i;
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < m_groupedNode.size(); i++) {
|
|
Shinya Kitaoka |
120a6e |
FxSchematicNode *node = dynamic_cast<fxschematicnode *="">(m_groupedNode[i]);</fxschematicnode>
|
|
Shinya Kitaoka |
120a6e |
assert(node);
|
|
Shinya Kitaoka |
120a6e |
TFx *fx = node->getFx();
|
|
Shinya Kitaoka |
120a6e |
assert(fx);
|
|
Shinya Kitaoka |
120a6e |
QRectF app = node->boundingRect();
|
|
manongjohn |
adae7d |
QPointF shiftAppPos(node->scenePos().x() - app.left(),
|
|
manongjohn |
adae7d |
node->scenePos().y() + app.top() + 10);
|
|
manongjohn |
adae7d |
app.moveTopLeft(shiftAppPos);
|
|
Shinya Kitaoka |
120a6e |
bool isASubgroupedNode =
|
|
Shinya Kitaoka |
120a6e |
fx->getAttributes()->getEditingGroupId() != m_groupId;
|
|
Shinya Kitaoka |
120a6e |
if (isASubgroupedNode) {
|
|
Shinya Kitaoka |
120a6e |
QStack<int> idStack = fx->getAttributes()->getGroupIdStack();</int>
|
|
Shinya Kitaoka |
120a6e |
int start = idStack.indexOf(fx->getAttributes()->getEditingGroupId());
|
|
Shinya Kitaoka |
120a6e |
int k = idStack.indexOf(m_groupId, start) + 1;
|
|
Shinya Kitaoka |
120a6e |
int factor = k * 30;
|
|
Shinya Kitaoka |
120a6e |
app.adjust(-factor, -factor, factor, factor);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
rect = rect.united(app);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
rect.adjust(-20, -35, 0, 20);
|
|
Shinya Kitaoka |
120a6e |
return rect;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void FxSchematicGroupEditor::setGroupedNodeZValue(int zValue) {
|
|
Shinya Kitaoka |
120a6e |
int i, size = m_groupedNode.size();
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < size; i++) {
|
|
Shinya Kitaoka |
120a6e |
FxSchematicNode *node = dynamic_cast<fxschematicnode *="">(m_groupedNode[i]);</fxschematicnode>
|
|
Shinya Kitaoka |
120a6e |
if (!node) continue;
|
|
Shinya Kitaoka |
120a6e |
if (node->getFx()->getAttributes()->getEditingGroupId() == m_groupId)
|
|
Shinya Kitaoka |
120a6e |
node->setZValue(zValue);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void FxSchematicGroupEditor::doResizeNodes(bool maximizeNodes) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=====================================================
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Shinya Kitaoka |
120a6e |
// FxSchematicMacroEditor
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//=====================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
FxSchematicMacroEditor::FxSchematicMacroEditor(
|
|
Shinya Kitaoka |
120a6e |
TMacroFx *macro, const QList<schematicnode *=""> &groupedNode,</schematicnode>
|
|
Shinya Kitaoka |
120a6e |
SchematicScene *scene)
|
|
Shinya Kitaoka |
120a6e |
: SchematicWindowEditor(groupedNode, scene), m_macro(macro) {
|
|
Shinya Kitaoka |
120a6e |
m_isMacroEditor = true;
|
|
Shinya Kitaoka |
120a6e |
initializeEditor();
|
|
Shinya Kitaoka |
120a6e |
setPos(boundingSceneRect().topLeft());
|
|
Shinya Kitaoka |
120a6e |
m_nameItem->setName(m_groupName);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
FxSchematicMacroEditor::~FxSchematicMacroEditor() {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void FxSchematicMacroEditor::initializeEditor() {
|
|
Shinya Kitaoka |
120a6e |
m_groupName = QString::fromStdWString(m_macro->getName());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void FxSchematicMacroEditor::closeEditor() {
|
|
Shinya Kitaoka |
120a6e |
m_macro->editMacro(false);
|
|
Shinya Kitaoka |
120a6e |
m_scene->updateScene();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void FxSchematicMacroEditor::onNameChanged() {
|
|
Shinya Kitaoka |
120a6e |
QList<tfxp> fxs;</tfxp>
|
|
Shinya Kitaoka |
120a6e |
m_nameItem->hide();
|
|
Shinya Kitaoka |
120a6e |
m_groupName = m_nameItem->toPlainText();
|
|
Shinya Kitaoka |
120a6e |
setFlag(QGraphicsItem::ItemIsSelectable, true);
|
|
Shinya Kitaoka |
120a6e |
FxSchematicScene *fxScene = dynamic_cast<fxschematicscene *="">(scene());</fxschematicscene>
|
|
Shinya Kitaoka |
120a6e |
if (!fxScene) return;
|
|
Shinya Kitaoka |
120a6e |
TFxCommand::renameFx(m_macro, m_groupName.toStdWString(),
|
|
Shinya Kitaoka |
120a6e |
fxScene->getXsheetHandle());
|
|
Shinya Kitaoka |
120a6e |
update();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QRectF FxSchematicMacroEditor::boundingSceneRect() const {
|
|
Shinya Kitaoka |
120a6e |
QRectF rect = m_groupedNode[0]->boundingRect();
|
|
manongjohn |
adae7d |
QPointF shiftPos(m_groupedNode[0]->scenePos().x() - rect.left(),
|
|
manongjohn |
adae7d |
m_groupedNode[0]->scenePos().y() + rect.top() + 10);
|
|
manongjohn |
adae7d |
rect.moveTopLeft(shiftPos);
|
|
Shinya Kitaoka |
120a6e |
int i;
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < m_groupedNode.size(); i++) {
|
|
Shinya Kitaoka |
120a6e |
FxSchematicNode *node = dynamic_cast<fxschematicnode *="">(m_groupedNode[i]);</fxschematicnode>
|
|
Shinya Kitaoka |
120a6e |
assert(node);
|
|
Shinya Kitaoka |
120a6e |
TFx *fx = node->getFx();
|
|
Shinya Kitaoka |
120a6e |
assert(fx);
|
|
Shinya Kitaoka |
120a6e |
QRectF app = node->boundingRect();
|
|
manongjohn |
adae7d |
QPointF shiftAppPos(node->scenePos().x() - app.left(),
|
|
manongjohn |
adae7d |
node->scenePos().y() + app.top() + 10);
|
|
manongjohn |
adae7d |
app.moveTopLeft(shiftAppPos);
|
|
Shinya Kitaoka |
120a6e |
rect = rect.united(app);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
rect.adjust(-20, -35, 0, 20);
|
|
Shinya Kitaoka |
120a6e |
return rect;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void FxSchematicMacroEditor::setGroupedNodeZValue(int zValue) {
|
|
Shinya Kitaoka |
120a6e |
int i, size = m_groupedNode.size();
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < size; i++) {
|
|
Shinya Kitaoka |
120a6e |
FxSchematicNode *node = dynamic_cast<fxschematicnode *="">(m_groupedNode[i]);</fxschematicnode>
|
|
Shinya Kitaoka |
120a6e |
if (!node) continue;
|
|
Shinya Kitaoka |
120a6e |
node->setZValue(zValue);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void FxSchematicMacroEditor::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
|
|
manongjohn |
f37f4a |
QPointF prevPos = pos();
|
|
Shinya Kitaoka |
120a6e |
SchematicWindowEditor::mouseMoveEvent(e);
|
|
Shinya Kitaoka |
120a6e |
if (m_button == Qt::LeftButton) {
|
|
manongjohn |
f37f4a |
QPointF delta = pos() - prevPos;
|
|
manongjohn |
f37f4a |
TFx *root = m_macro->getRoot();
|
|
manongjohn |
f37f4a |
TPointD oldPos = m_macro->getAttributes()->getDagNodePos();
|
|
manongjohn |
f37f4a |
m_macro->getAttributes()->setDagNodePos(oldPos +
|
|
manongjohn |
f37f4a |
TPointD(delta.x(), delta.y()));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void FxSchematicMacroEditor::doResizeNodes(bool maximizeNodes) {
|
|
Shinya Kitaoka |
120a6e |
m_macro->getAttributes()->setIsOpened(maximizeNodes);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=====================================================
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Shinya Kitaoka |
120a6e |
// StageSchematicGroupEditor
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//=====================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
StageSchematicGroupEditor::StageSchematicGroupEditor(
|
|
Shinya Kitaoka |
120a6e |
int groupId, const QList<schematicnode *=""> &groupedNode,</schematicnode>
|
|
Shinya Kitaoka |
120a6e |
SchematicScene *scene)
|
|
Shinya Kitaoka |
120a6e |
: SchematicWindowEditor(groupedNode, scene), m_groupId(groupId) {
|
|
Shinya Kitaoka |
120a6e |
initializeEditor();
|
|
Shinya Kitaoka |
120a6e |
setPos(boundingSceneRect().topLeft());
|
|
Shinya Kitaoka |
120a6e |
m_nameItem->setName(m_groupName);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
StageSchematicGroupEditor::~StageSchematicGroupEditor() {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QRectF StageSchematicGroupEditor::boundingSceneRect() const {
|
|
Shinya Kitaoka |
120a6e |
QRectF rect = m_groupedNode[0]->boundingRect();
|
|
manongjohn |
adae7d |
QPointF shiftPos(m_groupedNode[0]->scenePos().x() - rect.left(),
|
|
manongjohn |
adae7d |
m_groupedNode[0]->scenePos().y() + rect.top() + 10);
|
|
manongjohn |
adae7d |
rect.moveTopLeft(shiftPos);
|
|
Shinya Kitaoka |
120a6e |
int i;
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < m_groupedNode.size(); i++) {
|
|
Shinya Kitaoka |
120a6e |
StageSchematicNode *node =
|
|
Shinya Kitaoka |
120a6e |
dynamic_cast<stageschematicnode *="">(m_groupedNode[i]);</stageschematicnode>
|
|
Shinya Kitaoka |
120a6e |
assert(node);
|
|
Shinya Kitaoka |
120a6e |
TStageObject *obj = node->getStageObject();
|
|
Shinya Kitaoka |
120a6e |
assert(obj);
|
|
Shinya Kitaoka |
120a6e |
QRectF app = node->boundingRect();
|
|
manongjohn |
adae7d |
QPointF shiftAppPos(node->scenePos().x() - app.left(),
|
|
manongjohn |
adae7d |
node->scenePos().y() + app.top() + 10);
|
|
manongjohn |
adae7d |
app.moveTopLeft(shiftAppPos);
|
|
Shinya Kitaoka |
120a6e |
bool isASubgroupedNode = obj->getEditingGroupId() != m_groupId;
|
|
Shinya Kitaoka |
120a6e |
if (isASubgroupedNode) app.adjust(-30, -30, 30, 30);
|
|
Shinya Kitaoka |
120a6e |
rect = rect.united(app);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
rect.adjust(-20, -35, 0, 0);
|
|
Shinya Kitaoka |
120a6e |
return rect;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void StageSchematicGroupEditor::setGroupedNodeZValue(int zValue) {
|
|
Shinya Kitaoka |
120a6e |
int i, size = m_groupedNode.size();
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < size; i++) {
|
|
Shinya Kitaoka |
120a6e |
StageSchematicNode *node =
|
|
Shinya Kitaoka |
120a6e |
dynamic_cast<stageschematicnode *="">(m_groupedNode[i]);</stageschematicnode>
|
|
Shinya Kitaoka |
120a6e |
if (!node) continue;
|
|
Shinya Kitaoka |
120a6e |
if (node->getStageObject()->getEditingGroupId() == m_groupId)
|
|
Shinya Kitaoka |
120a6e |
node->setZValue(zValue);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void StageSchematicGroupEditor::closeEditor() {
|
|
Shinya Kitaoka |
120a6e |
int i;
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < m_groupedNode.size(); i++) {
|
|
Shinya Kitaoka |
120a6e |
StageSchematicNode *node =
|
|
Shinya Kitaoka |
120a6e |
dynamic_cast<stageschematicnode *="">(m_groupedNode[i]);</stageschematicnode>
|
|
Shinya Kitaoka |
120a6e |
if (!node) continue;
|
|
Shinya Kitaoka |
120a6e |
StageSchematicGroupNode *groupNode =
|
|
Shinya Kitaoka |
120a6e |
dynamic_cast<stageschematicgroupnode *="">(node);</stageschematicgroupnode>
|
|
Shinya Kitaoka |
120a6e |
if (groupNode) {
|
|
Shinya Kitaoka |
120a6e |
QList<tstageobject *=""> objs = groupNode->getGroupedObjects();</tstageobject>
|
|
Shinya Kitaoka |
120a6e |
assert(!objs.isEmpty());
|
|
Shinya Kitaoka |
120a6e |
int j;
|
|
Shinya Kitaoka |
120a6e |
for (j = 0; j < objs.size(); j++) objs[j]->closeEditingGroup(m_groupId);
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
TStageObject *obj = node->getStageObject();
|
|
Shinya Kitaoka |
120a6e |
assert(obj);
|
|
Shinya Kitaoka |
120a6e |
obj->closeEditingGroup(m_groupId);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
m_scene->updateScene();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void StageSchematicGroupEditor::onNameChanged() {
|
|
Shinya Kitaoka |
120a6e |
int i;
|
|
Shinya Kitaoka |
120a6e |
QList<tstageobject *=""> objs;</tstageobject>
|
|
Shinya Kitaoka |
120a6e |
m_nameItem->hide();
|
|
Shinya Kitaoka |
120a6e |
m_groupName = m_nameItem->toPlainText();
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < m_groupedNode.size(); i++) {
|
|
Shinya Kitaoka |
120a6e |
StageSchematicGroupNode *groupNode =
|
|
Shinya Kitaoka |
120a6e |
dynamic_cast<stageschematicgroupnode *="">(m_groupedNode[i]);</stageschematicgroupnode>
|
|
Shinya Kitaoka |
120a6e |
StageSchematicNode *node =
|
|
Shinya Kitaoka |
120a6e |
dynamic_cast<stageschematicnode *="">(m_groupedNode[i]);</stageschematicnode>
|
|
Shinya Kitaoka |
120a6e |
if (groupNode)
|
|
Shinya Kitaoka |
120a6e |
objs.append(groupNode->getGroupedObjects());
|
|
Shinya Kitaoka |
120a6e |
else if (node)
|
|
Shinya Kitaoka |
120a6e |
objs.append(node->getStageObject());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
setFlag(QGraphicsItem::ItemIsSelectable, true);
|
|
Shinya Kitaoka |
120a6e |
StageSchematicScene *stageScene =
|
|
Shinya Kitaoka |
120a6e |
dynamic_cast<stageschematicscene *="">(scene());</stageschematicscene>
|
|
Shinya Kitaoka |
120a6e |
if (!stageScene) return;
|
|
Shinya Kitaoka |
120a6e |
TStageObjectCmd::renameGroup(objs, m_groupName.toStdWString(), true,
|
|
Shinya Kitaoka |
120a6e |
stageScene->getXsheetHandle());
|
|
Shinya Kitaoka |
120a6e |
update();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void StageSchematicGroupEditor::initializeEditor() {
|
|
Shinya Kitaoka |
120a6e |
StageSchematicNode *node =
|
|
Shinya Kitaoka |
120a6e |
dynamic_cast<stageschematicnode *="">(m_groupedNode[0]);</stageschematicnode>
|
|
Shinya Kitaoka |
120a6e |
assert(node);
|
|
Shinya Kitaoka |
120a6e |
TStageObject *obj = node->getStageObject();
|
|
Shinya Kitaoka |
120a6e |
assert(obj);
|
|
Shinya Kitaoka |
120a6e |
assert(m_groupId == obj->getEditingGroupId());
|
|
Shinya Kitaoka |
120a6e |
m_groupName = QString::fromStdWString(obj->getEditingGroupName());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void StageSchematicGroupEditor::doResizeNodes(bool maximizeNodes) {
|
|
Shinya Kitaoka |
120a6e |
int i;
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < m_groupedNode.size(); i++) {
|
|
Shinya Kitaoka |
120a6e |
StageSchematicNode *node =
|
|
Shinya Kitaoka |
120a6e |
dynamic_cast<stageschematicnode *="">(m_groupedNode[i]);</stageschematicnode>
|
|
Shinya Kitaoka |
120a6e |
assert(node);
|
|
Shinya Kitaoka |
120a6e |
node->getStageObject()->setIsOpened(maximizeNodes);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|