-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Pascal Bies
committed
Mar 14, 2022
1 parent
4e8cb3a
commit 4c3284c
Showing
11 changed files
with
114 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#include "tools/handles/facehandle.h" | ||
#include "path/edge.h" | ||
#include <QPainter> | ||
#include "objects/pathobject.h" | ||
#include "scene/faceselection.h" | ||
#include "scene/scene.h" | ||
|
||
namespace omm | ||
{ | ||
|
||
FaceHandle::FaceHandle(Tool& tool, PathObject& path_object, const Face& face) | ||
: Handle(tool) | ||
, m_path_object(path_object) | ||
, m_face(face) | ||
, m_path(face.to_painter_path()) | ||
{ | ||
} | ||
|
||
bool FaceHandle::contains_global(const Vec2f& point) const | ||
{ | ||
const auto p = transformation().inverted().apply_to_position(point); | ||
return m_face.contains(p); | ||
} | ||
|
||
void FaceHandle::draw(QPainter& painter) const | ||
{ | ||
painter.save(); | ||
painter.setTransform(transformation().to_qtransform()); | ||
const auto status = is_selected() ? HandleStatus::Active : this->status(); | ||
painter.setBrush(ui_color(status, "face")); | ||
painter.drawPath(m_path); | ||
painter.restore(); | ||
} | ||
|
||
ObjectTransformation FaceHandle::transformation() const | ||
{ | ||
return m_path_object.global_transformation(Space::Viewport); | ||
} | ||
|
||
bool FaceHandle::is_selected() const | ||
{ | ||
return tool.scene()->face_selection->faces().contains(m_face); | ||
} | ||
|
||
} // namespace omm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#pragma once | ||
|
||
#include "geometry/vec2.h" | ||
#include "tools/handles/handle.h" | ||
#include "tools/tool.h" | ||
#include "path/face.h" | ||
#include <QPainterPath> | ||
|
||
namespace omm | ||
{ | ||
class FaceHandle : public Handle | ||
{ | ||
public: | ||
explicit FaceHandle(Tool& tool, PathObject& path_object, const Face& face); | ||
[[nodiscard]] bool contains_global(const Vec2f& point) const override; | ||
void draw(QPainter& painter) const override; | ||
Vec2f position = Vec2f::o(); | ||
ObjectTransformation transformation() const; | ||
bool is_selected() const; | ||
|
||
protected: | ||
bool transform_in_tool_space{}; | ||
|
||
private: | ||
PathObject& m_path_object; | ||
const Face m_face; | ||
const QPainterPath m_path; | ||
}; | ||
|
||
} // namespace omm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters