diff --git a/DestinationGLCanvas.cpp b/DestinationGLCanvas.cpp
deleted file mode 100644
index a4defce..0000000
--- a/DestinationGLCanvas.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * DestinationGLCanvas.cpp
- *
- * (c) 2013 Sofian Audry -- info(@)sofianaudry(.)com
- * (c) 2013 Alexandre Quessy -- alexandre(@)quessy(.)net
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include "DestinationGLCanvas.h"
-#include "MainWindow.h"
-
-DestinationGLCanvas::DestinationGLCanvas(MainWindow* mainWindow, QWidget* parent, const QGLWidget* shareWidget, QGraphicsScene* scene)
-: MapperGLCanvas(mainWindow, parent, shareWidget, scene)
-{
-}
-
-MShape::ptr DestinationGLCanvas::getShapeFromMapping(const Mapping::ptr& mapping) const
-{
- return (mapping.isNull() ? MShape::ptr() : mapping->getShape());
-}
-
-QSharedPointer DestinationGLCanvas::getShapeGraphicsItemFromMapping(const Mapping::ptr& mapping) const
-{
- return (mapping.isNull() ? QSharedPointer() : MainWindow::instance()->getMappingGuiByMappingId(mapping->getId())->getGraphicsItem());
-}
diff --git a/DestinationGLCanvas.h b/DestinationGLCanvas.h
deleted file mode 100644
index 38f70af..0000000
--- a/DestinationGLCanvas.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * DestinationGLCanvas.h
- *
- * (c) 2013 Sofian Audry -- info(@)sofianaudry(.)com
- * (c) 2013 Alexandre Quessy -- alexandre(@)quessy(.)net
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#ifndef DESTINATIONGLCANVAS_H_
-#define DESTINATIONGLCANVAS_H_
-
-#include "MapperGLCanvas.h"
-#include "MappingManager.h"
-
-#include "MappingGui.h"
-
-class DestinationGLCanvas: public MapperGLCanvas
-{
- Q_OBJECT
-
-public:
- DestinationGLCanvas(MainWindow* mainWindow, QWidget* parent = 0, const QGLWidget* shareWidget = 0, QGraphicsScene* scene = 0);
- virtual ~DestinationGLCanvas() {}
-
- virtual bool isOutput() const { return true; }
- virtual MShape::ptr getShapeFromMapping(const Mapping::ptr& mapping) const;
- virtual QSharedPointer getShapeGraphicsItemFromMapping(const Mapping::ptr& mapping) const;
-};
-
-#endif /* DESTINATIONGLCANVAS_H_ */
diff --git a/MainWindow.cpp b/MainWindow.cpp
index 835d163..887c918 100644
--- a/MainWindow.cpp
+++ b/MainWindow.cpp
@@ -1389,12 +1389,12 @@ void MainWindow::createLayout()
mappingPropertyPanel->setMinimumHeight(MAPPING_PROPERTY_PANEL_MINIMUM_HEIGHT);
// Create canvases.
- sourceCanvas = new SourceGLCanvas(this);
+ sourceCanvas = new MapperGLCanvas(this, false);
sourceCanvas->setFocusPolicy(Qt::ClickFocus);
sourceCanvas->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
sourceCanvas->setMinimumSize(CANVAS_MINIMUM_WIDTH, CANVAS_MINIMUM_HEIGHT);
- destinationCanvas = new DestinationGLCanvas(this, 0, (QGLWidget*)sourceCanvas->viewport());
+ destinationCanvas = new MapperGLCanvas(this, true, 0, (QGLWidget*)sourceCanvas->viewport());
destinationCanvas->setFocusPolicy(Qt::ClickFocus);
destinationCanvas->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
destinationCanvas->setMinimumSize(CANVAS_MINIMUM_WIDTH, CANVAS_MINIMUM_HEIGHT);
diff --git a/MainWindow.h b/MainWindow.h
index 9c03d73..fe31217 100644
--- a/MainWindow.h
+++ b/MainWindow.h
@@ -32,11 +32,10 @@
#include "MM.h"
-#include "SourceGLCanvas.h"
+#include "MapperGLCanvas.h"
#ifdef HAVE_OSC
#include "OscInterface.h"
#endif
-#include "DestinationGLCanvas.h"
#include "OutputGLWindow.h"
#include "PreferencesDialog.h"
@@ -368,8 +367,8 @@ private:
QUndoView* undoView;
- SourceGLCanvas* sourceCanvas;
- DestinationGLCanvas* destinationCanvas;
+ MapperGLCanvas* sourceCanvas;
+ MapperGLCanvas* destinationCanvas;
OutputGLWindow* outputWindow;
ConsoleWindow* consoleWindow;
diff --git a/MapperGLCanvas.cpp b/MapperGLCanvas.cpp
index aa427f5..34d39c3 100644
--- a/MapperGLCanvas.cpp
+++ b/MapperGLCanvas.cpp
@@ -23,9 +23,10 @@
#include "MainWindow.h"
#include "Commands.h"
-MapperGLCanvas::MapperGLCanvas(MainWindow* mainWindow, QWidget* parent, const QGLWidget * shareWidget, QGraphicsScene* scene)
+MapperGLCanvas::MapperGLCanvas(MainWindow* mainWindow, bool isOutput, QWidget* parent, const QGLWidget * shareWidget, QGraphicsScene* scene)
: QGraphicsView(parent),
_mainWindow(mainWindow),
+ _isOutput(isOutput),
_vertexGrabbed(false),
_activeVertex(NO_VERTEX),
_shapeGrabbed(false), // comment out?
@@ -67,6 +68,16 @@ MapperGLCanvas::MapperGLCanvas(MainWindow* mainWindow, QWidget* parent, const QG
this->scene()->setBackgroundBrush(Qt::black);
}
+MShape::ptr MapperGLCanvas::getShapeFromMapping(Mapping::ptr mapping)
+{
+ if (mapping.isNull())
+ return MShape::ptr();
+ else
+ {
+ return (isOutput() ? mapping->getShape() : mapping->getInputShape());
+ }
+}
+
MShape::ptr MapperGLCanvas::getCurrentShape()
{
return getShapeFromMapping(MainWindow::instance()->getCurrentMapping());
@@ -74,7 +85,14 @@ MShape::ptr MapperGLCanvas::getCurrentShape()
QSharedPointer MapperGLCanvas::getCurrentShapeGraphicsItem()
{
- return getShapeGraphicsItemFromMapping(MainWindow::instance()->getCurrentMapping());
+ Mapping::ptr mapping = MainWindow::instance()->getCurrentMapping();
+ if (mapping.isNull())
+ return QSharedPointer();
+ else
+ {
+ MappingGui::ptr mappingGui = MainWindow::instance()->getMappingGuiByMappingId(mapping->getId());
+ return (isOutput() ? mappingGui->getGraphicsItem() : mappingGui->getInputGraphicsItem());
+ }
}
// Draws foreground (displays crosshair if needed).
diff --git a/MapperGLCanvas.h b/MapperGLCanvas.h
index 2738e21..168c137 100644
--- a/MapperGLCanvas.h
+++ b/MapperGLCanvas.h
@@ -49,14 +49,13 @@ class MapperGLCanvas: public QGraphicsView
Q_OBJECT
public:
/// Constructor.
- MapperGLCanvas(MainWindow* mainWindow, QWidget* parent = 0, const QGLWidget* shareWidget = 0, QGraphicsScene* scene = 0);
+ MapperGLCanvas(MainWindow* mainWindow, bool isOutput, QWidget* parent = 0, const QGLWidget* shareWidget = 0, QGraphicsScene* scene = 0);
virtual ~MapperGLCanvas() {}
/// Returns shape associated with mapping id.
- virtual bool isOutput() const = 0;
- virtual MShape::ptr getShapeFromMapping(const Mapping::ptr& mapping) const = 0;
- virtual QSharedPointer getShapeGraphicsItemFromMapping(const Mapping::ptr& mapping) const = 0;
+ virtual bool isOutput() const { return _isOutput; }
+ MShape::ptr getShapeFromMapping(Mapping::ptr mapping);
MShape::ptr getCurrentShape();
QSharedPointer getCurrentShapeGraphicsItem();
@@ -134,6 +133,9 @@ private:
// Pointer to main window.
MainWindow* _mainWindow;
+ // Is this a destination (output) or source (input) canvas.
+ bool _isOutput;
+
// Last point pressed (in mouse/window coordinates).
QPoint _mousePressedPosition;
diff --git a/OutputGLCanvas.cpp b/OutputGLCanvas.cpp
index 8bd8236..ee9fd91 100644
--- a/OutputGLCanvas.cpp
+++ b/OutputGLCanvas.cpp
@@ -22,7 +22,7 @@
#include "MainWindow.h"
OutputGLCanvas::OutputGLCanvas(MainWindow* mainWindow, QWidget* parent, const QGLWidget* shareWidget, QGraphicsScene* scene)
-: DestinationGLCanvas(mainWindow, parent, shareWidget, scene),
+: MapperGLCanvas(mainWindow, true, parent, shareWidget, scene),
_displayCrosshair(false),
_svg_test_signal(":/test-signal"),
_brush_test_signal(_svg_test_signal)
@@ -128,6 +128,6 @@ void OutputGLCanvas::mouseMoveEvent(QMouseEvent *event)
}
else
{
- DestinationGLCanvas::mouseMoveEvent(event);
+ MapperGLCanvas::mouseMoveEvent(event);
}
}
diff --git a/OutputGLCanvas.h b/OutputGLCanvas.h
index 85d5e6e..e121c55 100644
--- a/OutputGLCanvas.h
+++ b/OutputGLCanvas.h
@@ -21,9 +21,9 @@
#ifndef OUTPUTGLCANVAS_H_
#define OUTPUTGLCANVAS_H_
-#include "DestinationGLCanvas.h"
+#include "MapperGLCanvas.h"
-class OutputGLCanvas: public DestinationGLCanvas
+class OutputGLCanvas: public MapperGLCanvas
{
Q_OBJECT
diff --git a/OutputGLWindow.cpp b/OutputGLWindow.cpp
index 7681983..3bd6cb0 100644
--- a/OutputGLWindow.cpp
+++ b/OutputGLWindow.cpp
@@ -23,7 +23,7 @@
#include "MainWindow.h"
-OutputGLWindow:: OutputGLWindow(QWidget* parent, const DestinationGLCanvas* canvas_) : QDialog(parent)
+OutputGLWindow:: OutputGLWindow(QWidget* parent, const MapperGLCanvas* canvas_) : QDialog(parent)
{
resize(MainWindow::OUTPUT_WINDOW_MINIMUM_WIDTH, MainWindow::OUTPUT_WINDOW_MINIMUM_HEIGHT);
diff --git a/OutputGLWindow.h b/OutputGLWindow.h
index 50dd624..4290c96 100644
--- a/OutputGLWindow.h
+++ b/OutputGLWindow.h
@@ -39,7 +39,7 @@ class OutputGLWindow : public QDialog
Q_OBJECT
public:
- OutputGLWindow(QWidget* parent, const DestinationGLCanvas* canvas_);
+ OutputGLWindow(QWidget* parent, const MapperGLCanvas* canvas_);
//OutputGLWindow(MainWindow* mainWindow, QWidget* parent = 0, const QGLWidget * shareWidget = 0);
public slots:
@@ -52,7 +52,7 @@ signals:
void closed();
public:
- DestinationGLCanvas* getCanvas() const { return canvas; }
+ MapperGLCanvas* getCanvas() const { return canvas; }
void setPointerHasMoved();
void setCursorVisible(bool visible);
diff --git a/SourceGLCanvas.cpp b/SourceGLCanvas.cpp
deleted file mode 100644
index 3f244a6..0000000
--- a/SourceGLCanvas.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * SourceGLCanvas.cpp
- *
- * (c) 2013 Sofian Audry -- info(@)sofianaudry(.)com
- * (c) 2013 Alexandre Quessy -- alexandre(@)quessy(.)net
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include "SourceGLCanvas.h"
-
-#include "MainWindow.h"
-
-
-SourceGLCanvas::SourceGLCanvas(MainWindow* mainWindow, QWidget* parent)
- : MapperGLCanvas(mainWindow, parent)
-{
-}
-
-MShape::ptr SourceGLCanvas::getShapeFromMapping(const Mapping::ptr& mapping) const
-{
- return (mapping.isNull() ? MShape::ptr() : mapping->getInputShape());
-}
-
-QSharedPointer SourceGLCanvas::getShapeGraphicsItemFromMapping(const Mapping::ptr& mapping) const
-{
- return (mapping.isNull() ? QSharedPointer() : MainWindow::instance()->getMappingGuiByMappingId(mapping->getId())->getInputGraphicsItem());
-}
-
-//
-
-//void SourceGLCanvas::doDraw(QPainter* painter)
-//{
-// if (getMainWindow()->hasCurrentMapping())
-// {
-// uint mappingId = getMainWindow()->getCurrentMappingId();
-// const MappingGui::ptr& mapper = getMainWindow()->getMappingGuiByMappingId(mappingId);
-// painter->save();
-// mapper->drawInput(painter);
-// painter->restore();
-// if (displayControls())
-// {
-// painter->save();
-// if (hasActiveVertex()) {
-// QList selectedVertices;
-// selectedVertices.append(getActiveVertexIndex());
-// mapper->drawInputControls(painter, &selectedVertices);
-// }
-// else
-// mapper->drawInputControls(painter);
-// painter->restore();
-// }
-// }
-//}
-
diff --git a/SourceGLCanvas.h b/SourceGLCanvas.h
deleted file mode 100644
index 77a2cf0..0000000
--- a/SourceGLCanvas.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * SourceGLCanvas.h
- *
- * (c) 2013 Sofian Audry -- info(@)sofianaudry(.)com
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#ifndef SOURCEGLCANVAS_H_
-#define SOURCEGLCANVAS_H_
-
-#include
-
-#include "MapperGLCanvas.h"
-#include "DestinationGLCanvas.h"
-
-#include "Util.h"
-
-class SourceGLCanvas: public MapperGLCanvas
-{
- Q_OBJECT
-
-public:
- SourceGLCanvas(MainWindow* mainWindow, QWidget* parent = 0);
- virtual ~SourceGLCanvas() {}
-
- virtual bool isOutput() const { return false; }
- virtual MShape::ptr getShapeFromMapping(const Mapping::ptr& mapping) const;
- virtual QSharedPointer getShapeGraphicsItemFromMapping(const Mapping::ptr& mapping) const;
-
-private:
-// virtual void doDraw(QPainter* painter);
-};
-
-
-#endif /* DESTINATIONGLCANVAS_H_ */
diff --git a/mapmap.pro b/mapmap.pro
index ef07215..d1da342 100644
--- a/mapmap.pro
+++ b/mapmap.pro
@@ -10,7 +10,6 @@ HEADERS = \
Commands.h \
ConcurrentQueue.h \
ConsoleWindow.h \
- DestinationGLCanvas.h \
Element.h \
Ellipse.h \
MM.h \
@@ -43,7 +42,6 @@ HEADERS = \
Shapes.h \
ShapeControlPainter.h \
ShapeGraphicsItem.h \
- SourceGLCanvas.h \
Triangle.h \
UidAllocator.h \
Util.h
@@ -51,7 +49,6 @@ HEADERS = \
SOURCES = \
Commands.cpp \
ConsoleWindow.cpp \
- DestinationGLCanvas.cpp \
Element.cpp \
Ellipse.cpp \
MM.cpp \
@@ -81,7 +78,6 @@ SOURCES = \
Shape.cpp \
ShapeControlPainter.cpp \
ShapeGraphicsItem.cpp \
- SourceGLCanvas.cpp \
UidAllocator.cpp \
Util.cpp \
main.cpp