src/canvas.h

Fri, 10 Feb 2017 23:06:24 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Fri, 10 Feb 2017 23:06:24 +0200
changeset 1122
795d1c3554b9
parent 1110
ec3ee7da7806
child 1129
2b20261dc511
permissions
-rw-r--r--

Added the RingAdapter class and interfacing ring() function and simplified some math in GLCompiler with it

/*
 *  LDForge: LDraw parts authoring CAD
 *  Copyright (C) 2013 - 2017 Teemu Piippo
 *
 *  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/>.
 */

#pragma once
#include "glRenderer.h"
#include "editmodes/abstractEditMode.h"

class Canvas : public GLRenderer
{
public:
	Canvas(LDDocument* document, QWidget* parent = nullptr);
	~Canvas();

	Vertex convert2dTo3d(const QPoint& pos2d, bool snap) const;
	QPoint convert3dTo2d(const Vertex& pos3d) const;
	EditModeType currentEditModeType() const;
	int depthNegateFactor() const;
	LDDocument* document() const;
	void drawPoint(QPainter& painter, QPointF pos, QColor color = QColor (64, 192, 0)) const;
	void drawBlipCoordinates(QPainter& painter, const Vertex& pos3d) const;
	void drawBlipCoordinates(QPainter& painter, const Vertex& pos3d, QPointF pos) const;
	double getDepthValue() const;
	void getRelativeAxes(Axis& relX, Axis& relY) const;
	Axis getRelativeZ() const;
	QPen linePen() const;
	const Vertex& position3D() const;
	void setDepthValue(double depth);
	void setEditMode(EditModeType type);

protected:
	void contextMenuEvent(QContextMenuEvent* event) override;
	void dragEnterEvent(QDragEnterEvent* event) override;
	void dropEvent(QDropEvent* event) override;
	bool freeCameraAllowed() const override;
	void keyReleaseEvent(QKeyEvent* event) override;
	void mouseDoubleClickEvent(QMouseEvent* event) override;
	void mouseMoveEvent(QMouseEvent* event) override;
	void mousePressEvent(QMouseEvent *event) override;
	void mouseReleaseEvent(QMouseEvent* event) override;
	void overpaint(QPainter& painter) override;

private:
	LDDocument& m_document;
	AbstractEditMode* m_currentEditMode = nullptr;
	Vertex m_position3D;
	double m_depthValues[6] = {0};
};

mercurial