|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/schematicviewer.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzQt includes
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/schematicnode.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/fxschematicnode.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/schematicgroupeditor.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/stageschematicscene.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/fxschematicscene.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/menubarcommand.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/tselectionhandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/gutil.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/imageutils.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/dvscrollwidget.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzLib includes
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txsheethandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tcolumnhandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tobjecthandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tfxhandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txsheet.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshlevelcolumn.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tcolumnfx.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshzeraryfxcolumn.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/preferences.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/fxdag.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tapplication.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tscenehandle.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Qt includes
|
|
Toshihiro Shimizu |
890ddd |
#include <qgraphicsscenemouseevent></qgraphicsscenemouseevent>
|
|
Toshihiro Shimizu |
890ddd |
#include <qmouseevent></qmouseevent>
|
|
Campbell Barton |
d0e335 |
#include <qgraphicsitem></qgraphicsitem>
|
|
Toshihiro Shimizu |
890ddd |
#include <qtoolbar></qtoolbar>
|
|
Toshihiro Shimizu |
890ddd |
#include <qtoolbutton></qtoolbutton>
|
|
Toshihiro Shimizu |
890ddd |
#include <qmenu></qmenu>
|
|
Toshihiro Shimizu |
890ddd |
#include <qicon></qicon>
|
|
Toshihiro Shimizu |
890ddd |
#include <qaction></qaction>
|
|
Toshihiro Shimizu |
890ddd |
#include <qmainwindow></qmainwindow>
|
|
Toshihiro Shimizu |
890ddd |
#include <qvboxlayout></qvboxlayout>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// STD includes
|
|
Toshihiro Shimizu |
890ddd |
#include "assert.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "math.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
namespace {
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class SchematicZoomer final : public ImageUtils::ShortcutZoomer {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
SchematicZoomer(QWidget *parent) : ShortcutZoomer(parent) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
bool zoom(bool zoomin, bool resetZoom) override {
|
|
Shinya Kitaoka |
120a6e |
static_cast<schematicsceneviewer *="">(getWidget())->zoomQt(zoomin, resetZoom);</schematicsceneviewer>
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
} // namespace
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==================================================================
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
// SchematicScene
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//==================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
SchematicScene::SchematicScene(QWidget *parent) : QGraphicsScene(parent) {
|
|
Shinya Kitaoka |
120a6e |
setSceneRect(0, 0, 50000, 50000);
|
|
Shinya Kitaoka |
120a6e |
setItemIndexMethod(NoIndex);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
SchematicScene::~SchematicScene() { clearAllItems(); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SchematicScene::showEvent(QShowEvent *se) {
|
|
Shinya Kitaoka |
120a6e |
TSelectionHandle *selHandle = TSelectionHandle::getCurrent();
|
|
Shinya Kitaoka |
120a6e |
connect(selHandle, SIGNAL(selectionSwitched(TSelection *, TSelection *)),
|
|
Shinya Kitaoka |
120a6e |
this, SLOT(onSelectionSwitched(TSelection *, TSelection *)));
|
|
Shinya Kitaoka |
120a6e |
clearSelection();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SchematicScene::hideEvent(QHideEvent *se) {
|
|
Shinya Kitaoka |
120a6e |
TSelectionHandle *selHandle = TSelectionHandle::getCurrent();
|
|
Shinya Kitaoka |
120a6e |
disconnect(selHandle, SIGNAL(selectionSwitched(TSelection *, TSelection *)),
|
|
Shinya Kitaoka |
120a6e |
this, SLOT(onSelectionSwitched(TSelection *, TSelection *)));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*! Removes and then deletes all item in the scene.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SchematicScene::clearAllItems() {
|
|
Shinya Kitaoka |
120a6e |
clearSelection();
|
|
Shinya Kitaoka |
120a6e |
m_highlightedLinks.clear();
|
|
Shinya Kitaoka |
120a6e |
QList<schematicwindoweditor *=""> editors;</schematicwindoweditor>
|
|
Shinya Kitaoka |
120a6e |
QList<schematicnode *=""> nodes;</schematicnode>
|
|
Shinya Kitaoka |
120a6e |
QList<schematiclink *=""> links;</schematiclink>
|
|
Shinya Kitaoka |
120a6e |
int i;
|
|
Shinya Kitaoka |
120a6e |
QList<qgraphicsitem *=""> sceneItems = items();</qgraphicsitem>
|
|
Shinya Kitaoka |
120a6e |
int size = sceneItems.size();
|
|
Shinya Kitaoka |
120a6e |
// create nodes and links list
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < size; i++) {
|
|
Shinya Kitaoka |
120a6e |
QGraphicsItem *item = sceneItems.at(i);
|
|
Shinya Kitaoka |
120a6e |
SchematicWindowEditor *editor = dynamic_cast<schematicwindoweditor *="">(item);</schematicwindoweditor>
|
|
Shinya Kitaoka |
120a6e |
SchematicNode *node = dynamic_cast<schematicnode *="">(item);</schematicnode>
|
|
Shinya Kitaoka |
120a6e |
SchematicLink *link = dynamic_cast<schematiclink *="">(item);</schematiclink>
|
|
Shinya Kitaoka |
120a6e |
if (editor) editors.append(editor);
|
|
Shinya Kitaoka |
120a6e |
if (node) nodes.append(node);
|
|
Shinya Kitaoka |
120a6e |
if (link) links.append(link);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
while (links.size() > 0) {
|
|
Shinya Kitaoka |
120a6e |
SchematicLink *link = links.back();
|
|
Shinya Kitaoka |
120a6e |
removeItem(link);
|
|
Shinya Kitaoka |
120a6e |
links.removeLast();
|
|
Shinya Kitaoka |
120a6e |
SchematicPort *startPort = link->getStartPort();
|
|
Shinya Kitaoka |
120a6e |
SchematicPort *endPort = link->getEndPort();
|
|
Shinya Kitaoka |
120a6e |
if (startPort) startPort->removeLink(link);
|
|
Shinya Kitaoka |
120a6e |
if (endPort) endPort->removeLink(link);
|
|
Shinya Kitaoka |
120a6e |
delete link;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
while (editors.size() > 0) {
|
|
Shinya Kitaoka |
120a6e |
SchematicWindowEditor *editor = editors.back();
|
|
Shinya Kitaoka |
120a6e |
removeItem(editor);
|
|
Shinya Kitaoka |
120a6e |
editors.removeLast();
|
|
Shinya Kitaoka |
120a6e |
delete editor;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
while (nodes.size() > 0) {
|
|
Shinya Kitaoka |
120a6e |
SchematicNode *node = nodes.back();
|
|
Shinya Kitaoka |
120a6e |
removeItem(node);
|
|
Shinya Kitaoka |
120a6e |
nodes.removeLast();
|
|
Shinya Kitaoka |
120a6e |
delete node;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
assert(items().size() == 0);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! check if any item exists in the rect
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
bool SchematicScene::isAnEmptyZone(const QRectF &rect) {
|
|
Shinya Kitaoka |
120a6e |
QList<qgraphicsitem *=""> allItems = items();</qgraphicsitem>
|
|
Shinya Kitaoka |
120a6e |
for (auto const level : allItems) {
|
|
Shinya Kitaoka |
120a6e |
SchematicNode *node = dynamic_cast<schematicnode *="">(level);</schematicnode>
|
|
Shinya Kitaoka |
120a6e |
if (!node) continue;
|
|
Shinya Kitaoka |
120a6e |
FxSchematicNode *fxNode = dynamic_cast<fxschematicnode *="">(node);</fxschematicnode>
|
|
Shinya Kitaoka |
120a6e |
if (fxNode && fxNode->isA(eXSheetFx)) continue;
|
|
Shinya Kitaoka |
120a6e |
if (node->boundingRect().translated(node->scenePos()).intersects(rect))
|
|
Shinya Kitaoka |
120a6e |
return false;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QVector<schematicnode *=""> SchematicScene::getPlacedNode(SchematicNode *node) {</schematicnode>
|
|
Shinya Kitaoka |
120a6e |
QRectF rect = node->boundingRect().translated(node->scenePos());
|
|
Shinya Kitaoka |
120a6e |
QList<qgraphicsitem *=""> allItems = items();</qgraphicsitem>
|
|
Shinya Kitaoka |
120a6e |
QVector<schematicnode *=""> nodes;</schematicnode>
|
|
Shinya Kitaoka |
120a6e |
for (auto const item : allItems) {
|
|
Shinya Kitaoka |
120a6e |
SchematicNode *placedNode = dynamic_cast<schematicnode *="">(item);</schematicnode>
|
|
Shinya Kitaoka |
120a6e |
if (!placedNode || placedNode == node) continue;
|
|
Shinya Kitaoka |
120a6e |
QRectF nodeRect =
|
|
Shinya Kitaoka |
120a6e |
placedNode->boundingRect().translated(placedNode->scenePos());
|
|
Shinya Kitaoka |
120a6e |
QRectF enlargedRect = rect.adjusted(-10, -10, 10, 10);
|
|
Shinya Kitaoka |
120a6e |
if (enlargedRect.contains(nodeRect)) nodes.push_back(placedNode);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return nodes;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==================================================================
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
// SchematicSceneViewer
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//==================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
SchematicSceneViewer::SchematicSceneViewer(QWidget *parent)
|
|
Shinya Kitaoka |
120a6e |
: QGraphicsView(parent)
|
|
Shinya Kitaoka |
120a6e |
, m_buttonState(Qt::NoButton)
|
|
Shinya Kitaoka |
120a6e |
, m_oldWinPos()
|
|
Shinya Kitaoka |
120a6e |
, m_oldScenePos()
|
|
Shinya Kitaoka |
120a6e |
, m_firstShowing(true) {
|
|
Shinya Kitaoka |
120a6e |
setObjectName("SchematicSceneViewer");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
Shinya Kitaoka |
120a6e |
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
Shinya Kitaoka |
120a6e |
setDragMode(QGraphicsView::NoDrag);
|
|
Shinya Kitaoka |
120a6e |
setTransformationAnchor(QGraphicsView::NoAnchor);
|
|
Shinya Kitaoka |
120a6e |
setRenderHint(QPainter::SmoothPixmapTransform);
|
|
Shinya Kitaoka |
120a6e |
setRenderHint(QPainter::TextAntialiasing);
|
|
Shinya Kitaoka |
120a6e |
setRenderHint(QPainter::Antialiasing);
|
|
Shinya Kitaoka |
120a6e |
setInteractive(true);
|
|
Shinya Kitaoka |
120a6e |
setViewportUpdateMode(QGraphicsView::SmartViewportUpdate);
|
|
Shinya Kitaoka |
120a6e |
show();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
SchematicSceneViewer::~SchematicSceneViewer() {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
/*! Reimplemets the QGraphicsView::mousePressEvent()
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
void SchematicSceneViewer::mousePressEvent(QMouseEvent *me) {
|
|
Shinya Kitaoka |
120a6e |
m_buttonState = me->button();
|
|
Shinya Kitaoka |
120a6e |
m_oldWinPos = me->pos();
|
|
Shinya Kitaoka |
120a6e |
m_oldScenePos = mapToScene(m_oldWinPos);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool drawRect = true;
|
|
Shinya Kitaoka |
120a6e |
QList<qgraphicsitem *=""> pointedItems = items(me->pos());</qgraphicsitem>
|
|
Shinya Kitaoka |
120a6e |
int i;
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < pointedItems.size(); i++) {
|
|
Shinya Kitaoka |
120a6e |
SchematicWindowEditor *editor =
|
|
Shinya Kitaoka |
120a6e |
dynamic_cast<schematicwindoweditor *="">(pointedItems[i]);</schematicwindoweditor>
|
|
Shinya Kitaoka |
120a6e |
if (!editor) {
|
|
Shinya Kitaoka |
120a6e |
drawRect = false;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (m_buttonState == Qt::LeftButton && drawRect)
|
|
Shinya Kitaoka |
120a6e |
setDragMode(QGraphicsView::RubberBandDrag);
|
|
Shinya Kitaoka |
120a6e |
QGraphicsView::mousePressEvent(me);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
/*! Reimplemets the QGraphicsView::mouseMoveEvent()
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
void SchematicSceneViewer::mouseMoveEvent(QMouseEvent *me) {
|
|
Shinya Kitaoka |
120a6e |
QPoint currWinPos = me->pos();
|
|
Shinya Kitaoka |
120a6e |
QPointF currScenePos = mapToScene(currWinPos);
|
|
Shinya Kitaoka |
120a6e |
if (m_buttonState == Qt::MidButton) {
|
|
Shinya Kitaoka |
120a6e |
// Panning
|
|
Shinya Kitaoka |
120a6e |
setInteractive(false);
|
|
Shinya Kitaoka |
120a6e |
// I need to disable QGraphicsView event handling to avoid the generation of
|
|
Shinya Kitaoka |
120a6e |
// 'virtual' mouseMoveEvent
|
|
Shinya Kitaoka |
120a6e |
QPointF delta = currScenePos - m_oldScenePos;
|
|
Shinya Kitaoka |
120a6e |
translate(delta.x(), delta.y());
|
|
Shinya Kitaoka |
120a6e |
currScenePos = mapToScene(currWinPos);
|
|
Shinya Kitaoka |
120a6e |
// translate has changed the matrix affecting the mapToScene() method. I
|
|
Shinya Kitaoka |
120a6e |
// have to recompute currScenePos
|
|
Shinya Kitaoka |
120a6e |
setInteractive(true);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
m_oldWinPos = currWinPos;
|
|
Shinya Kitaoka |
120a6e |
m_oldScenePos = currScenePos;
|
|
Shinya Kitaoka |
120a6e |
QGraphicsView::mouseMoveEvent(me);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/*! Reimplemets the QGraphicsView::mouseReleaseEvent()
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
void SchematicSceneViewer::mouseReleaseEvent(QMouseEvent *me) {
|
|
Shinya Kitaoka |
120a6e |
m_buttonState = Qt::NoButton;
|
|
Shinya Kitaoka |
120a6e |
QGraphicsView::mouseReleaseEvent(me);
|
|
Shinya Kitaoka |
120a6e |
setDragMode(QGraphicsView::NoDrag);
|
|
Shinya Kitaoka |
120a6e |
// update();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SchematicSceneViewer::keyPressEvent(QKeyEvent *ke) {
|
|
Shinya Kitaoka |
120a6e |
ke->ignore();
|
|
Shinya Kitaoka |
120a6e |
QGraphicsView::keyPressEvent(ke);
|
|
Shinya Kitaoka |
120a6e |
if (!ke->isAccepted()) SchematicZoomer(this).exec(ke);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
/*! Reimplemets the QGraphicsView::wheelEvent()
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
void SchematicSceneViewer::wheelEvent(QWheelEvent *me) {
|
|
Shinya Kitaoka |
120a6e |
me->accept();
|
|
Shinya Kitaoka |
120a6e |
double factor = exp(me->delta() * 0.001);
|
|
Shinya Kitaoka |
120a6e |
changeScale(me->pos(), factor);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SchematicSceneViewer::zoomQt(bool zoomin, bool resetZoom) {
|
|
Toshihiro Shimizu |
890ddd |
#if QT_VERSION >= 0x050000
|
|
Shinya Kitaoka |
120a6e |
double scale2 = matrix().determinant();
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Shinya Kitaoka |
120a6e |
double scale2 = matrix().det();
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// if the zoom scale is changed over 100% in FxSchematic, call updateScene
|
|
Shinya Kitaoka |
120a6e |
bool beforeIsLarge = (scale2 >= 1.0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (resetZoom ||
|
|
Shinya Kitaoka |
120a6e |
((scale2 < 100000 || !zoomin) && (scale2 > 0.001 * 0.05 || zoomin))) {
|
|
Shinya Kitaoka |
120a6e |
double oldZoomScale = sqrt(scale2);
|
|
Shinya Kitaoka |
120a6e |
double zoomScale = resetZoom ? 1 : ImageUtils::getQuantizedZoomFactor(
|
|
Shinya Kitaoka |
120a6e |
oldZoomScale, zoomin);
|
|
Shinya Kitaoka |
120a6e |
QMatrix scale =
|
|
Shinya Kitaoka |
120a6e |
QMatrix().scale(zoomScale / oldZoomScale, zoomScale / oldZoomScale);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// See QGraphicsView::mapToScene()'s doc for details
|
|
Shinya Kitaoka |
120a6e |
QRect rect(0, 0, width(), height());
|
|
Shinya Kitaoka |
120a6e |
QRectF sceneCenterRect(
|
|
Shinya Kitaoka |
120a6e |
mapToScene(QRect(rect.center(), QSize(2, 2))).boundingRect());
|
|
Shinya Kitaoka |
120a6e |
setMatrix(scale, true);
|
|
Shinya Kitaoka |
120a6e |
centerOn(sceneCenterRect.center());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#if QT_VERSION >= 0x050000
|
|
Shinya Kitaoka |
120a6e |
bool afterIsLarge = (matrix().determinant() >= 1.0);
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Shinya Kitaoka |
120a6e |
bool afterIsLarge = (matrix().det() >= 1.0);
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Shinya Kitaoka |
120a6e |
if (beforeIsLarge != afterIsLarge) {
|
|
Shinya Kitaoka |
120a6e |
FxSchematicScene *fxScene = qobject_cast<fxschematicscene *="">(scene());</fxschematicscene>
|
|
Shinya Kitaoka |
120a6e |
if (fxScene) fxScene->updateScene();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*! The view is scaled around the point \b winPos by \b scaleFactor;
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
void SchematicSceneViewer::changeScale(const QPoint &winPos,
|
|
Shinya Kitaoka |
120a6e |
qreal scaleFactor) {
|
|
Toshihiro Shimizu |
890ddd |
#if QT_VERSION >= 0x050000
|
|
Shinya Kitaoka |
120a6e |
bool beforeIsLarge = (matrix().determinant() >= 1.0);
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Shinya Kitaoka |
120a6e |
bool beforeIsLarge = (matrix().det() >= 1.0);
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Shinya Kitaoka |
120a6e |
QPointF startScenePos = mapToScene(winPos);
|
|
Shinya Kitaoka |
120a6e |
QMatrix scale = QMatrix().scale(scaleFactor, scaleFactor);
|
|
Shinya Kitaoka |
120a6e |
setMatrix(scale, true);
|
|
Shinya Kitaoka |
120a6e |
QPointF endScenePos = mapToScene(winPos);
|
|
Shinya Kitaoka |
120a6e |
QPointF delta = endScenePos - startScenePos;
|
|
Shinya Kitaoka |
120a6e |
translate(delta.x(), delta.y());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#if QT_VERSION >= 0x050000
|
|
Shinya Kitaoka |
120a6e |
bool afterIsLarge = (matrix().determinant() >= 1.0);
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Shinya Kitaoka |
120a6e |
bool afterIsLarge = (matrix().det() >= 1.0);
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Shinya Kitaoka |
120a6e |
if (beforeIsLarge != afterIsLarge) {
|
|
Shinya Kitaoka |
120a6e |
FxSchematicScene *fxScene = qobject_cast<fxschematicscene *="">(scene());</fxschematicscene>
|
|
Shinya Kitaoka |
120a6e |
if (fxScene) fxScene->updateScene();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SchematicSceneViewer::fitScene() {
|
|
Shinya Kitaoka |
120a6e |
if (scene()) {
|
|
Toshihiro Shimizu |
890ddd |
#if QT_VERSION >= 0x050000
|
|
Shinya Kitaoka |
120a6e |
bool beforeIsLarge = (matrix().determinant() >= 1.0);
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Shinya Kitaoka |
120a6e |
bool beforeIsLarge = (matrix().det() >= 1.0);
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QRectF rect = scene()->itemsBoundingRect();
|
|
Shinya Kitaoka |
120a6e |
fitInView(rect, Qt::KeepAspectRatio);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#if QT_VERSION >= 0x050000
|
|
Shinya Kitaoka |
120a6e |
bool afterIsLarge = (matrix().determinant() >= 1.0);
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Shinya Kitaoka |
120a6e |
bool afterIsLarge = (matrix().det() >= 1.0);
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Shinya Kitaoka |
120a6e |
if (beforeIsLarge != afterIsLarge) {
|
|
Shinya Kitaoka |
120a6e |
FxSchematicScene *fxScene = qobject_cast<fxschematicscene *="">(scene());</fxschematicscene>
|
|
Shinya Kitaoka |
120a6e |
if (fxScene) fxScene->updateScene();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SchematicSceneViewer::centerOnCurrent() {
|
|
Shinya Kitaoka |
120a6e |
SchematicScene *schematicScene = dynamic_cast<schematicscene *="">(scene());</schematicscene>
|
|
Shinya Kitaoka |
120a6e |
QGraphicsItem *node = schematicScene->getCurrentNode();
|
|
Shinya Kitaoka |
120a6e |
if (node) centerOn(node);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SchematicSceneViewer::reorderScene() {
|
|
Shinya Kitaoka |
120a6e |
SchematicScene *schematicScene = dynamic_cast<schematicscene *="">(scene());</schematicscene>
|
|
Shinya Kitaoka |
120a6e |
schematicScene->reorderScene();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SchematicSceneViewer::normalizeScene() {
|
|
Toshihiro Shimizu |
890ddd |
#if QT_VERSION >= 0x050000
|
|
Shinya Kitaoka |
120a6e |
bool beforeIsLarge = (matrix().determinant() >= 1.0);
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Shinya Kitaoka |
120a6e |
bool beforeIsLarge = (matrix().det() >= 1.0);
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Shinya Kitaoka |
120a6e |
// See QGraphicsView::mapToScene()'s doc for details
|
|
Shinya Kitaoka |
120a6e |
QRect rect(0, 0, width(), height());
|
|
Shinya Kitaoka |
120a6e |
QRectF sceneCenterRect(
|
|
Shinya Kitaoka |
120a6e |
mapToScene(QRect(rect.center(), QSize(2, 2))).boundingRect());
|
|
Shinya Kitaoka |
120a6e |
resetMatrix();
|
|
Toshihiro Shimizu |
890ddd |
#if defined(MACOSX)
|
|
Shinya Kitaoka |
120a6e |
scale(1.32, 1.32);
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Shinya Kitaoka |
120a6e |
centerOn(sceneCenterRect.center());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#if QT_VERSION >= 0x050000
|
|
Shinya Kitaoka |
120a6e |
bool afterIsLarge = (matrix().determinant() >= 1.0);
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Shinya Kitaoka |
120a6e |
bool afterIsLarge = (matrix().det() >= 1.0);
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Shinya Kitaoka |
120a6e |
if (beforeIsLarge != afterIsLarge) {
|
|
Shinya Kitaoka |
120a6e |
FxSchematicScene *fxScene = qobject_cast<fxschematicscene *="">(scene());</fxschematicscene>
|
|
Shinya Kitaoka |
120a6e |
if (fxScene) fxScene->updateScene();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SchematicSceneViewer::showEvent(QShowEvent *se) {
|
|
Shinya Kitaoka |
120a6e |
QGraphicsView::showEvent(se);
|
|
Shinya Kitaoka |
120a6e |
if (m_firstShowing) {
|
|
Shinya Kitaoka |
120a6e |
m_firstShowing = false;
|
|
Shinya Kitaoka |
120a6e |
QRectF rect = scene()->itemsBoundingRect();
|
|
Shinya Kitaoka |
120a6e |
resetMatrix();
|
|
Shinya Kitaoka |
120a6e |
centerOn(rect.center());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==================================================================
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
// SchematicViewer
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//==================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
SchematicViewer::SchematicViewer(QWidget *parent)
|
|
Shinya Kitaoka |
120a6e |
: QWidget(parent)
|
|
Shinya Kitaoka |
120a6e |
, m_fullSchematic(true)
|
|
Shinya Kitaoka |
120a6e |
, m_maximizedNode(false)
|
|
Shinya Kitaoka |
120a6e |
, m_sceneHandle(0) {
|
|
Shinya Kitaoka |
120a6e |
m_viewer = new SchematicSceneViewer(this);
|
|
Shinya Kitaoka |
120a6e |
m_stageScene = new StageSchematicScene(this);
|
|
Shinya Kitaoka |
120a6e |
m_fxScene = new FxSchematicScene(this);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
m_commonToolbar = new QToolBar(m_viewer);
|
|
Shinya Kitaoka |
120a6e |
m_stageToolbar = new QToolBar(m_viewer);
|
|
Shinya Kitaoka |
120a6e |
m_fxToolbar = new QToolBar(m_viewer);
|
|
Shinya Kitaoka |
120a6e |
m_swapToolbar = new QToolBar(m_viewer);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
m_commonToolbar->setObjectName("ToolBarWithoutBorder");
|
|
Shinya Kitaoka |
120a6e |
m_stageToolbar->setObjectName("ToolBarWithoutBorder");
|
|
Shinya Kitaoka |
120a6e |
m_fxToolbar->setObjectName("ToolBarWithoutBorder");
|
|
Shinya Kitaoka |
120a6e |
m_swapToolbar->setObjectName("ToolBarWithoutBorder");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
createToolbars();
|
|
Shinya Kitaoka |
120a6e |
createActions();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// layout
|
|
Shinya Kitaoka |
120a6e |
QVBoxLayout *mainLayout = new QVBoxLayout();
|
|
Shinya Kitaoka |
120a6e |
mainLayout->setMargin(1);
|
|
Shinya Kitaoka |
120a6e |
mainLayout->setSpacing(0);
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
mainLayout->addWidget(m_viewer, 1);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QFrame *bottomFrame = new QFrame(this);
|
|
Shinya Kitaoka |
120a6e |
bottomFrame->setObjectName("SchematicBottomFrame");
|
|
Shinya Kitaoka |
120a6e |
QHBoxLayout *horizontalLayout = new QHBoxLayout();
|
|
Shinya Kitaoka |
120a6e |
horizontalLayout->setMargin(0);
|
|
Shinya Kitaoka |
120a6e |
horizontalLayout->setSpacing(0);
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
horizontalLayout->addWidget(m_commonToolbar);
|
|
Shinya Kitaoka |
120a6e |
horizontalLayout->addStretch();
|
|
Shinya Kitaoka |
120a6e |
horizontalLayout->addWidget(m_fxToolbar);
|
|
Shinya Kitaoka |
120a6e |
horizontalLayout->addWidget(m_stageToolbar);
|
|
Shinya Kitaoka |
120a6e |
horizontalLayout->addWidget(m_swapToolbar);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
bottomFrame->setLayout(horizontalLayout);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
mainLayout->addWidget(bottomFrame, 0);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
setLayout(mainLayout);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
connect(m_fxScene, SIGNAL(showPreview(TFxP)), this,
|
|
Shinya Kitaoka |
120a6e |
SIGNAL(showPreview(TFxP)));
|
|
Shinya Kitaoka |
120a6e |
connect(m_fxScene, SIGNAL(doCollapse(const QList<tfxp> &)), this,</tfxp>
|
|
Shinya Kitaoka |
120a6e |
SIGNAL(doCollapse(const QList<tfxp> &)));</tfxp>
|
|
Shinya Kitaoka |
120a6e |
connect(m_stageScene, SIGNAL(doCollapse(QList<tstageobjectid>)), this,</tstageobjectid>
|
|
Shinya Kitaoka |
120a6e |
SIGNAL(doCollapse(QList<tstageobjectid>)));</tstageobjectid>
|
|
Shinya Kitaoka |
120a6e |
connect(m_fxScene, SIGNAL(doExplodeChild(const QList<tfxp> &)), this,</tfxp>
|
|
Shinya Kitaoka |
120a6e |
SIGNAL(doExplodeChild(const QList<tfxp> &)));</tfxp>
|
|
Shinya Kitaoka |
120a6e |
connect(m_stageScene, SIGNAL(doExplodeChild(QList<tstageobjectid>)), this,</tstageobjectid>
|
|
Shinya Kitaoka |
120a6e |
SIGNAL(doExplodeChild(QList<tstageobjectid>)));</tstageobjectid>
|
|
Shinya Kitaoka |
120a6e |
connect(m_stageScene, SIGNAL(editObject()), this, SIGNAL(editObject()));
|
|
Shinya Kitaoka |
120a6e |
connect(m_fxScene, SIGNAL(editObject()), this, SIGNAL(editObject()));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
m_viewer->setScene(m_stageScene);
|
|
Shinya Kitaoka |
120a6e |
m_fxToolbar->hide();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
setFocusProxy(m_viewer);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
SchematicViewer::~SchematicViewer() {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SchematicViewer::setApplication(TApplication *app) {
|
|
Shinya Kitaoka |
120a6e |
m_stageScene->setXsheetHandle(app->getCurrentXsheet());
|
|
Shinya Kitaoka |
120a6e |
m_stageScene->setObjectHandle(app->getCurrentObject());
|
|
Shinya Kitaoka |
120a6e |
m_stageScene->setFxHandle(app->getCurrentFx());
|
|
Shinya Kitaoka |
120a6e |
m_stageScene->setColumnHandle(app->getCurrentColumn());
|
|
Shinya Kitaoka |
120a6e |
m_stageScene->setSceneHandle(app->getCurrentScene());
|
|
Shinya Kitaoka |
120a6e |
m_stageScene->setFrameHandle(app->getCurrentFrame());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_fxScene->setApplication(app);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void SchematicViewer::updateSchematic() {
|
|
Shinya Kitaoka |
120a6e |
m_stageScene->updateScene();
|
|
Shinya Kitaoka |
120a6e |
m_fxScene->updateScene();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void SchematicViewer::setSchematicScene(SchematicScene *scene) {
|
|
Shinya Kitaoka |
120a6e |
if (scene) {
|
|
Shinya Kitaoka |
120a6e |
m_viewer->setScene(scene);
|
|
Shinya Kitaoka |
120a6e |
m_viewer->centerOn(scene->sceneRect().center());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void SchematicViewer::createToolbars() {
|
|
Shinya Kitaoka |
120a6e |
// Initialize them
|
|
Shinya Kitaoka |
120a6e |
m_stageToolbar->setMovable(false);
|
|
Shinya Kitaoka |
120a6e |
m_stageToolbar->setIconSize(QSize(23, 17));
|
|
Shinya Kitaoka |
120a6e |
m_stageToolbar->setLayoutDirection(Qt::RightToLeft);
|
|
Shinya Kitaoka |
120a6e |
m_stageToolbar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_commonToolbar->setMovable(false);
|
|
Shinya Kitaoka |
120a6e |
m_commonToolbar->setIconSize(QSize(23, 17));
|
|
Shinya Kitaoka |
120a6e |
m_commonToolbar->setLayoutDirection(Qt::RightToLeft);
|
|
Shinya Kitaoka |
120a6e |
m_commonToolbar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_fxToolbar->setMovable(false);
|
|
Shinya Kitaoka |
120a6e |
m_fxToolbar->setIconSize(QSize(23, 17));
|
|
Shinya Kitaoka |
120a6e |
m_fxToolbar->setLayoutDirection(Qt::RightToLeft);
|
|
Shinya Kitaoka |
120a6e |
m_fxToolbar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_swapToolbar->setMovable(false);
|
|
Shinya Kitaoka |
120a6e |
m_swapToolbar->setIconSize(QSize(23, 17));
|
|
Shinya Kitaoka |
120a6e |
m_swapToolbar->setLayoutDirection(Qt::RightToLeft);
|
|
Shinya Kitaoka |
120a6e |
m_swapToolbar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void SchematicViewer::createActions() {
|
|
Shinya Kitaoka |
120a6e |
// Create all actions
|
|
Shinya Kitaoka |
120a6e |
QAction *addPegbar = 0, *addSpline = 0, *addCamera = 0, *insertFx = 0,
|
|
Shinya Kitaoka |
120a6e |
*addOutputFx = 0, *switchPort = 0;
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
// Fit schematic
|
|
Shinya Kitaoka |
120a6e |
QIcon fitSchematicIcon = createQIconOnOffPNG("fit", false);
|
|
Shinya Kitaoka |
120a6e |
m_fitSchematic =
|
|
Shinya Kitaoka |
120a6e |
new QAction(fitSchematicIcon, tr("&Fit to Window"), m_commonToolbar);
|
|
Shinya Kitaoka |
120a6e |
connect(m_fitSchematic, SIGNAL(triggered()), m_viewer, SLOT(fitScene()));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Center On
|
|
Shinya Kitaoka |
120a6e |
QIcon centerOnIcon = createQIconOnOffPNG("centerselection", false);
|
|
Shinya Kitaoka |
120a6e |
m_centerOn =
|
|
Shinya Kitaoka |
120a6e |
new QAction(centerOnIcon, tr("&Focus on Current"), m_commonToolbar);
|
|
Shinya Kitaoka |
120a6e |
connect(m_centerOn, SIGNAL(triggered()), m_viewer, SLOT(centerOnCurrent()));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Reorder schematic
|
|
Shinya Kitaoka |
120a6e |
QIcon reorderIcon = createQIconOnOffPNG("reorder", false);
|
|
Shinya Kitaoka |
120a6e |
m_reorder = new QAction(reorderIcon, tr("&Reorder Nodes"), m_commonToolbar);
|
|
Shinya Kitaoka |
120a6e |
connect(m_reorder, SIGNAL(triggered()), m_viewer, SLOT(reorderScene()));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Normalize schematic schematic
|
|
Shinya Kitaoka |
120a6e |
QIcon normalizeIcon = createQIconOnOffPNG("resetsize", false);
|
|
Shinya Kitaoka |
120a6e |
m_normalize =
|
|
Shinya Kitaoka |
120a6e |
new QAction(normalizeIcon, tr("&Reset Size"), m_commonToolbar);
|
|
Shinya Kitaoka |
120a6e |
connect(m_normalize, SIGNAL(triggered()), m_viewer, SLOT(normalizeScene()));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QIcon nodeSizeIcon = createQIconOnOffPNG(
|
|
Shinya Kitaoka |
120a6e |
m_maximizedNode ? "minimizenodes" : "maximizenodes", false);
|
|
Shinya Kitaoka |
120a6e |
m_nodeSize =
|
|
Shinya Kitaoka |
120a6e |
new QAction(nodeSizeIcon, m_maximizedNode ? tr("&Minimize Nodes")
|
|
Shinya Kitaoka |
120a6e |
: tr("&Maximize Nodes"),
|
|
Shinya Kitaoka |
120a6e |
m_commonToolbar);
|
|
Shinya Kitaoka |
120a6e |
connect(m_nodeSize, SIGNAL(triggered()), this, SLOT(changeNodeSize()));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (m_fullSchematic) {
|
|
Shinya Kitaoka |
120a6e |
// AddPegbar
|
|
Shinya Kitaoka |
120a6e |
addPegbar = new QAction(tr("&New Pegbar"), m_stageToolbar);
|
|
Shinya Kitaoka |
120a6e |
QIcon addPegbarIcon = createQIconOnOffPNG("pegbar", false);
|
|
Shinya Kitaoka |
120a6e |
addPegbar->setIcon(addPegbarIcon);
|
|
Shinya Kitaoka |
120a6e |
connect(addPegbar, SIGNAL(triggered()), m_stageScene,
|
|
Shinya Kitaoka |
120a6e |
SLOT(onPegbarAdded()));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// AddCamera
|
|
Shinya Kitaoka |
120a6e |
addCamera = new QAction(tr("&New Camera"), m_stageToolbar);
|
|
Shinya Kitaoka |
120a6e |
QIcon addCameraIcon = createQIconOnOffPNG("camera", false);
|
|
Shinya Kitaoka |
120a6e |
addCamera->setIcon(addCameraIcon);
|
|
Shinya Kitaoka |
120a6e |
connect(addCamera, SIGNAL(triggered()), m_stageScene,
|
|
Shinya Kitaoka |
120a6e |
SLOT(onCameraAdded()));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// AddSpline
|
|
Shinya Kitaoka |
120a6e |
addSpline = new QAction(tr("&New Motion Path"), m_stageToolbar);
|
|
Shinya Kitaoka |
120a6e |
QIcon addSplineIcon = createQIconOnOffPNG("motionpath", false);
|
|
Shinya Kitaoka |
120a6e |
addSpline->setIcon(addSplineIcon);
|
|
Shinya Kitaoka |
120a6e |
connect(addSpline, SIGNAL(triggered()), m_stageScene,
|
|
Shinya Kitaoka |
120a6e |
SLOT(onSplineAdded()));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// Switch display of stage schematic's output port
|
|
Shinya Kitaoka |
120a6e |
switchPort =
|
|
Shinya Kitaoka |
120a6e |
new QAction(tr("&Swtich output port display mode"), m_stageToolbar);
|
|
Shinya Kitaoka |
120a6e |
switchPort->setCheckable(true);
|
|
Shinya Kitaoka |
120a6e |
switchPort->setChecked(m_stageScene->isShowLetterOnPortFlagEnabled());
|
|
Shinya Kitaoka |
120a6e |
QIcon switchPortIcon = createQIconOnOffPNG("switchport");
|
|
Shinya Kitaoka |
120a6e |
switchPort->setIcon(switchPortIcon);
|
|
Shinya Kitaoka |
120a6e |
connect(switchPort, SIGNAL(toggled(bool)), m_stageScene,
|
|
Shinya Kitaoka |
120a6e |
SLOT(onSwitchPortModeToggled(bool)));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// InsertFx
|
|
Shinya Kitaoka |
120a6e |
insertFx = CommandManager::instance()->getAction("MI_InsertFx");
|
|
Shinya Kitaoka |
120a6e |
if (insertFx) {
|
|
Shinya Kitaoka |
120a6e |
QIcon insertFxIcon = createQIconOnOffPNG("fx", false);
|
|
Shinya Kitaoka |
120a6e |
insertFx->setIcon(insertFxIcon);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// AddOutputFx
|
|
Shinya Kitaoka |
120a6e |
addOutputFx = CommandManager::instance()->getAction("MI_NewOutputFx");
|
|
Shinya Kitaoka |
120a6e |
QIcon addOutputFxIcon = createQIconOnOffPNG("output", false);
|
|
Shinya Kitaoka |
120a6e |
if (addOutputFx) addOutputFx->setIcon(addOutputFxIcon);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Swap fx/stage schematic
|
|
Shinya Kitaoka |
120a6e |
QIcon changeSchematicIcon = createQIconOnOffPNG("swap", false);
|
|
Shinya Kitaoka |
120a6e |
m_changeScene =
|
|
Shinya Kitaoka |
120a6e |
CommandManager::instance()->getAction("A_FxSchematicToggle", true);
|
|
Shinya Kitaoka |
120a6e |
if (m_changeScene) {
|
|
Shinya Kitaoka |
120a6e |
m_changeScene->setIcon(changeSchematicIcon);
|
|
Shinya Kitaoka |
120a6e |
connect(m_changeScene, SIGNAL(triggered()), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(onSceneChanged()));
|
|
Shinya Kitaoka |
120a6e |
} else
|
|
Shinya Kitaoka |
120a6e |
m_changeScene = 0;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// Add actions to toolbars (in reverse)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
m_commonToolbar->addSeparator();
|
|
Shinya Kitaoka |
120a6e |
m_commonToolbar->addAction(m_nodeSize);
|
|
Shinya Kitaoka |
120a6e |
m_commonToolbar->addAction(m_normalize);
|
|
Shinya Kitaoka |
120a6e |
m_commonToolbar->addAction(m_reorder);
|
|
Shinya Kitaoka |
120a6e |
m_commonToolbar->addAction(m_centerOn);
|
|
Shinya Kitaoka |
120a6e |
m_commonToolbar->addAction(m_fitSchematic);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (m_fullSchematic) {
|
|
Shinya Kitaoka |
120a6e |
m_stageToolbar->addSeparator();
|
|
Shinya Kitaoka |
120a6e |
m_stageToolbar->addAction(switchPort);
|
|
Shinya Kitaoka |
120a6e |
m_stageToolbar->addSeparator();
|
|
Shinya Kitaoka |
120a6e |
m_stageToolbar->addAction(addSpline);
|
|
Shinya Kitaoka |
120a6e |
m_stageToolbar->addAction(addCamera);
|
|
Shinya Kitaoka |
120a6e |
m_stageToolbar->addAction(addPegbar);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
m_fxToolbar->addSeparator();
|
|
Shinya Kitaoka |
120a6e |
m_fxToolbar->addAction(addOutputFx);
|
|
Shinya Kitaoka |
120a6e |
m_fxToolbar->addAction(insertFx);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (m_changeScene) m_swapToolbar->addAction(m_changeScene);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SchematicViewer::setStageSchematic() {
|
|
Shinya Kitaoka |
120a6e |
if (m_viewer->scene() != m_stageScene) {
|
|
Shinya Kitaoka |
120a6e |
m_viewer->setScene(m_stageScene);
|
|
Shinya Kitaoka |
120a6e |
QRectF rect = m_stageScene->itemsBoundingRect();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
m_viewer->resetMatrix();
|
|
Shinya Kitaoka |
120a6e |
m_viewer->centerOn(rect.center());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
m_fxToolbar->hide();
|
|
Shinya Kitaoka |
120a6e |
m_stageToolbar->show();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
m_viewer->update();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
parentWidget()->setWindowTitle(QObject::tr("Stage Schematic"));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SchematicViewer::setFxSchematic() {
|
|
Shinya Kitaoka |
120a6e |
if (m_viewer->scene() != m_fxScene) {
|
|
Shinya Kitaoka |
120a6e |
m_viewer->setScene(m_fxScene);
|
|
Shinya Kitaoka |
120a6e |
QRectF rect = m_fxScene->itemsBoundingRect();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
m_viewer->resetMatrix();
|
|
Shinya Kitaoka |
120a6e |
m_viewer->centerOn(rect.center());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
m_stageToolbar->hide();
|
|
Shinya Kitaoka |
120a6e |
m_fxToolbar->show();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// check if the fx scene was small scaled (icon view mode)
|
|
Shinya Kitaoka |
120a6e |
if (!m_fxScene->isLargeScaled()) m_fxScene->updateScene();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
m_viewer->update();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
parentWidget()->setWindowTitle(QObject::tr("FX Schematic"));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SchematicViewer::onSceneChanged() {
|
|
Shinya Kitaoka |
120a6e |
if (!hasFocus()) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QGraphicsScene *scene = m_viewer->scene();
|
|
Shinya Kitaoka |
120a6e |
if (scene == m_fxScene)
|
|
Shinya Kitaoka |
120a6e |
setStageSchematic();
|
|
Shinya Kitaoka |
120a6e |
else if (scene == m_stageScene)
|
|
Shinya Kitaoka |
120a6e |
setFxSchematic();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SchematicViewer::onSceneSwitched() {
|
|
Shinya Kitaoka |
120a6e |
m_maximizedNode = m_fxScene->getXsheetHandle()
|
|
Shinya Kitaoka |
120a6e |
->getXsheet()
|
|
Shinya Kitaoka |
120a6e |
->getFxDag()
|
|
Shinya Kitaoka |
120a6e |
->getDagGridDimension() == 0;
|
|
Shinya Kitaoka |
120a6e |
QIcon nodeSizeIcon = createQIconOnOffPNG(
|
|
Shinya Kitaoka |
120a6e |
m_maximizedNode ? "minimizenodes" : "maximizenodes", false);
|
|
Shinya Kitaoka |
120a6e |
m_nodeSize->setIcon(nodeSizeIcon);
|
|
Shinya Kitaoka |
120a6e |
QString label(m_maximizedNode ? tr("&Minimize Nodes")
|
|
Shinya Kitaoka |
120a6e |
: tr("&Maximize Nodes"));
|
|
Shinya Kitaoka |
120a6e |
m_nodeSize->setText(label);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// reset schematic
|
|
Shinya Kitaoka |
120a6e |
m_viewer->resetMatrix();
|
|
Shinya Kitaoka |
120a6e |
m_viewer->centerOn(m_viewer->scene()->itemsBoundingRect().center());
|
|
Shinya Kitaoka |
120a6e |
if (m_viewer->scene() == m_fxScene && !m_fxScene->isLargeScaled())
|
|
Shinya Kitaoka |
120a6e |
m_fxScene->updateScene();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool SchematicViewer::isStageSchematicViewed() {
|
|
Shinya Kitaoka |
120a6e |
QGraphicsScene *scene = m_viewer->scene();
|
|
Shinya Kitaoka |
120a6e |
return scene == m_stageScene;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SchematicViewer::setStageSchematicViewed(bool isStageSchematic) {
|
|
Shinya Kitaoka |
120a6e |
if (!m_fullSchematic) isStageSchematic = true;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (isStageSchematic == isStageSchematicViewed()) return;
|
|
Shinya Kitaoka |
120a6e |
if (isStageSchematic)
|
|
Shinya Kitaoka |
120a6e |
setStageSchematic();
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
setFxSchematic();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SchematicViewer::updateScenes() {
|
|
Shinya Kitaoka |
120a6e |
TStageObjectId id = m_stageScene->getCurrentObject();
|
|
Shinya Kitaoka |
120a6e |
if (id.isColumn()) {
|
|
Shinya Kitaoka |
120a6e |
m_stageScene->update();
|
|
Shinya Kitaoka |
120a6e |
TXsheet *xsh = m_stageScene->getXsheetHandle()->getXsheet();
|
|
Shinya Kitaoka |
120a6e |
if (!xsh) return;
|
|
Shinya Kitaoka |
120a6e |
TXshColumn *column = xsh->getColumn(id.getIndex());
|
|
Shinya Kitaoka |
120a6e |
if (!column) {
|
|
Shinya Kitaoka |
120a6e |
m_fxScene->getFxHandle()->setFx(0, false);
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
TFx *fx = column->getFx();
|
|
Shinya Kitaoka |
120a6e |
m_fxScene->getFxHandle()->setFx(fx, false);
|
|
Shinya Kitaoka |
120a6e |
m_fxScene->update();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SchematicViewer::changeNodeSize() {
|
|
Shinya Kitaoka |
120a6e |
m_maximizedNode = !m_maximizedNode;
|
|
Shinya Kitaoka |
120a6e |
// aggiono l'icona del pulsante;
|
|
Shinya Kitaoka |
120a6e |
m_fxScene->resizeNodes(m_maximizedNode);
|
|
Shinya Kitaoka |
120a6e |
m_stageScene->resizeNodes(m_maximizedNode);
|
|
Shinya Kitaoka |
120a6e |
QIcon nodeSizeIcon = createQIconOnOffPNG(
|
|
Shinya Kitaoka |
120a6e |
m_maximizedNode ? "minimizenodes" : "maximizenodes", false);
|
|
Shinya Kitaoka |
120a6e |
m_nodeSize->setIcon(nodeSizeIcon);
|
|
Shinya Kitaoka |
120a6e |
QString label(m_maximizedNode ? tr("&Minimize Nodes")
|
|
Shinya Kitaoka |
120a6e |
: tr("&Maximize Nodes"));
|
|
Shinya Kitaoka |
120a6e |
m_nodeSize->setText(label);
|
|
Toshihiro Shimizu |
890ddd |
}
|