Removed DestinationGLCanvas and SourceGLCanvas which were not doing much: integrated them directly in MapperGLCanvas.

This commit is contained in:
Tats
2016-03-06 00:43:01 -05:00
parent 35cbe281c0
commit 28261033c6
13 changed files with 38 additions and 215 deletions
-37
View File
@@ -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 <http://www.gnu.org/licenses/>.
*/
#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<ShapeGraphicsItem> DestinationGLCanvas::getShapeGraphicsItemFromMapping(const Mapping::ptr& mapping) const
{
return (mapping.isNull() ? QSharedPointer<ShapeGraphicsItem>() : MainWindow::instance()->getMappingGuiByMappingId(mapping->getId())->getGraphicsItem());
}
-42
View File
@@ -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 <http://www.gnu.org/licenses/>.
*/
#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<ShapeGraphicsItem> getShapeGraphicsItemFromMapping(const Mapping::ptr& mapping) const;
};
#endif /* DESTINATIONGLCANVAS_H_ */
+2 -2
View File
@@ -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);
+3 -4
View File
@@ -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;
+20 -2
View File
@@ -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<ShapeGraphicsItem> MapperGLCanvas::getCurrentShapeGraphicsItem()
{
return getShapeGraphicsItemFromMapping(MainWindow::instance()->getCurrentMapping());
Mapping::ptr mapping = MainWindow::instance()->getCurrentMapping();
if (mapping.isNull())
return QSharedPointer<ShapeGraphicsItem>();
else
{
MappingGui::ptr mappingGui = MainWindow::instance()->getMappingGuiByMappingId(mapping->getId());
return (isOutput() ? mappingGui->getGraphicsItem() : mappingGui->getInputGraphicsItem());
}
}
// Draws foreground (displays crosshair if needed).
+6 -4
View File
@@ -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<ShapeGraphicsItem> getShapeGraphicsItemFromMapping(const Mapping::ptr& mapping) const = 0;
virtual bool isOutput() const { return _isOutput; }
MShape::ptr getShapeFromMapping(Mapping::ptr mapping);
MShape::ptr getCurrentShape();
QSharedPointer<ShapeGraphicsItem> 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;
+2 -2
View File
@@ -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);
}
}
+2 -2
View File
@@ -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
+1 -1
View File
@@ -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);
+2 -2
View File
@@ -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);
-66
View File
@@ -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 <http://www.gnu.org/licenses/>.
*/
#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<ShapeGraphicsItem> SourceGLCanvas::getShapeGraphicsItemFromMapping(const Mapping::ptr& mapping) const
{
return (mapping.isNull() ? QSharedPointer<ShapeGraphicsItem>() : 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<int> selectedVertices;
// selectedVertices.append(getActiveVertexIndex());
// mapper->drawInputControls(painter, &selectedVertices);
// }
// else
// mapper->drawInputControls(painter);
// painter->restore();
// }
// }
//}
-47
View File
@@ -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 <http://www.gnu.org/licenses/>.
*/
#ifndef SOURCEGLCANVAS_H_
#define SOURCEGLCANVAS_H_
#include <QGLWidget>
#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<ShapeGraphicsItem> getShapeGraphicsItemFromMapping(const Mapping::ptr& mapping) const;
private:
// virtual void doDraw(QPainter* painter);
};
#endif /* DESTINATIONGLCANVAS_H_ */
-4
View File
@@ -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