src/canvas.h

Mon, 02 Apr 2018 13:21:15 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Mon, 02 Apr 2018 13:21:15 +0300
changeset 1371
b8df4748d04e
parent 1369
1e2391b78d17
child 1385
2f18c0da749d
child 1390
3eace926af7f
permissions
-rw-r--r--

automatically center the model in the renderer

/*
 *  LDForge: LDraw parts authoring CAD
 *  Copyright (C) 2013 - 2018 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();

	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;
	void clearCurrentCullValue();
	double currentCullValue() 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 setCullValue(double value);
	void setEditMode(EditModeType type);

protected:
	void contextMenuEvent(QContextMenuEvent* event) override;
	void dragEnterEvent(QDragEnterEvent* event) override;
	void drawFixedCameraBackdrop() 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};
	double cullValues[6] = {0};
};

mercurial