Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement facelist property #237

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
d2ef593
implement FaceProperty
Mar 29, 2022
955b285
Add FaceList type
Mar 11, 2022
062d558
Implement FaceListProperty
Mar 11, 2022
e94742b
add FaceListPropertyWidget skeleton
Mar 11, 2022
54e1586
StyleTag has face list property
Mar 11, 2022
8c48b95
minor style fixes
Mar 11, 2022
8a69d7c
Throw instead of assert-fail in a rare condition
Mar 11, 2022
d54edb1
More consistent property widgets code style
Mar 11, 2022
930b414
Move joint-point aware PathPoint-equality to PathPoint class
Mar 12, 2022
bf795be
Delay conversion of faces to QPainterPath
Mar 12, 2022
e2ea135
simplify FaceListWidget
Mar 13, 2022
0621b50
Face selection mode
Mar 13, 2022
8dbe5d0
remove no longer required code
Mar 13, 2022
319bd04
hover faces
Mar 14, 2022
c53cce5
Merge branch 'implement-faces-property' into implement-facelist-property
Apr 1, 2022
30da911
fix Face list type label confusion
Apr 2, 2022
1ae4ef6
don't overwrite old scene file if serialization fails (only JSON)
Apr 2, 2022
54cd3aa
guard ::contains function with requires-expression
Apr 3, 2022
a501209
fix PathPoint::is_dangling implementation
Apr 3, 2022
6e7a664
add compile option DRAW_POINT_IDS
Apr 7, 2022
edcf5cf
rename PathVector::outline to to_painter_path
Apr 7, 2022
133e298
add Path::to_painter_path method
Apr 7, 2022
9cc12cb
add PathVector::draw_point_ids(QPainter&)
Apr 7, 2022
4a40b28
simplify testutil::Application
Apr 7, 2022
fb15a8c
Graph::faces returns a set instead of a vector
Apr 7, 2022
d5b4234
fix missing const
Apr 7, 2022
96bbb27
provide another (failing) face detection test case
Apr 7, 2022
41487f7
fix Face::contains
Apr 7, 2022
1b33f3b
improve face selection
Apr 7, 2022
789fe54
remove ambiguous Face operator== and operator<
Apr 8, 2022
3661fb6
disable FaceDetection tests because they are known to be broken
Apr 11, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
improve face selection
Pascal Bies committed Apr 7, 2022
commit 1b33f3b3ac0701868f0d4b2a8bc6b8fd8a104520
31 changes: 27 additions & 4 deletions src/scene/faceselection.cpp
Original file line number Diff line number Diff line change
@@ -4,15 +4,38 @@
namespace omm
{

FaceSelection::FaceSelection(Scene& scene)
: m_scene(scene)
FaceSelection::FaceSelection(Scene&)
{

}

::transparent_set<Face> FaceSelection::faces() const
void FaceSelection::set_selected(const Face& face, bool is_selected)
{
return {};
if (is_selected) {
select(face);
} else {
deselect(face);
}
}

void FaceSelection::select(const Face& face)
{
m_selection.insert(face);
}

void FaceSelection::deselect(const Face& face)
{
m_selection.erase(face);
}

bool FaceSelection::is_selected(const Face& face)
{
return m_selection.contains(face);
}

void FaceSelection::clear()
{
m_selection.clear();
}

} // namespace omm
8 changes: 6 additions & 2 deletions src/scene/faceselection.h
Original file line number Diff line number Diff line change
@@ -13,10 +13,14 @@ class FaceSelection
{
public:
FaceSelection(Scene& scene);
[[nodiscard]] ::transparent_set<Face> faces() const;
void set_selected(const Face& face, bool is_selected);
void select(const Face& face);
void deselect(const Face& face);
[[nodiscard]] bool is_selected(const Face& face);
void clear();

private:
Scene& m_scene;
::transparent_set<Face> m_selection;
};

} // namespace omm
14 changes: 12 additions & 2 deletions src/tools/handles/facehandle.cpp
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ namespace omm
{

FaceHandle::FaceHandle(Tool& tool, PathObject& path_object, const Face& face)
: Handle(tool)
: AbstractSelectHandle(tool)
, m_path_object(path_object)
, m_face(face)
, m_path(face.to_painter_path())
@@ -39,7 +39,17 @@ ObjectTransformation FaceHandle::transformation() const

bool FaceHandle::is_selected() const
{
return tool.scene()->face_selection->faces().contains(m_face);
return tool.scene()->face_selection->is_selected(m_face);
}

void FaceHandle::set_selected(bool selected)
{
tool.scene()->face_selection->set_selected(m_face, selected);
}

void FaceHandle::clear()
{
return tool.scene()->face_selection->clear();
}

} // namespace omm
7 changes: 5 additions & 2 deletions src/tools/handles/facehandle.h
Original file line number Diff line number Diff line change
@@ -2,24 +2,27 @@

#include "geometry/vec2.h"
#include "tools/handles/handle.h"
#include "tools/handles/abstractselecthandle.h"
#include "tools/tool.h"
#include "path/face.h"
#include <QPainterPath>

namespace omm
{
class FaceHandle : public Handle
class FaceHandle : public AbstractSelectHandle
{
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{};
bool is_selected() const override;
void set_selected(bool selected) override;
void clear() override;

private:
PathObject& m_path_object;