Permalink
Browse files

Render of selected insert

  • Loading branch information...
feragon committed Jun 24, 2017
1 parent f70f61c commit 9868d991a129f6ab6fe582cded05c91625ef16cd
@@ -30,7 +30,8 @@ class LCVDrawItem {
bool selectable() const;
bool selected() const;
void selected(bool selected);
virtual void selected(bool selected);
private:
bool _selectable;
bool _selected;
@@ -1,5 +1,4 @@
#include "lcvinsert.h"
#include "../documentcanvas.h"
using namespace LCViewer;
@@ -29,25 +28,27 @@ void LCVInsert::append(lc::entity::CADEntity_CSPtr entity) {
return;
}
_entities.insert(std::dynamic_pointer_cast<const lc::entity::CADEntity>(drawable));
_entities.insert(std::make_pair(entity->id(), drawable));
}
void LCVInsert::draw(LCViewer::LcPainter& _painter, const LCViewer::LcDrawOptions& options,
const lc::geo::Area& updateRect) const {
for(auto entity : _entities) {
std::dynamic_pointer_cast<const LCVDrawItem>(entity)->draw(_painter, options, updateRect);
entity.second->draw(_painter, options, updateRect);
}
}
void LCVInsert::draw(DocumentCanvas_SPtr docCanvas) const {
auto shared = shared_from_this();
for(auto entity : _entities) {
docCanvas->drawEntity(std::dynamic_pointer_cast<const LCVDrawItem>(entity), shared_from_this());
docCanvas->drawEntity(entity.second, shared);
}
}
void LCVInsert::on_addEntityEvent(const lc::AddEntityEvent& event) {
auto entity = event.entity();
_entities.erase(entity);
_entities.erase(entity->id());
if(entity->block() == displayBlock()) {
append(entity);
@@ -61,5 +62,13 @@ void LCVInsert::on_removeEntityEvent(const lc::RemoveEntityEvent& event) {
return;
}
_entities.erase(entity);
}
_entities.erase(entity->id());
}
void LCVInsert::selected(bool selected) {
LCVDrawItem::selected(selected);
for(auto entity : _entities) {
entity.second->selected(selected);
}
}
@@ -13,6 +13,8 @@ namespace LCViewer {
LCVInsert(lc::entity::Insert_CSPtr insert);
virtual ~LCVInsert();
virtual void selected(bool selected) override;
void draw(LcPainter& _painter, const LcDrawOptions& options, const lc::geo::Area& updateRect) const override;
void draw(DocumentCanvas_SPtr docCanvas) const;
@@ -24,6 +26,6 @@ namespace LCViewer {
private:
lc::geo::Coordinate _offset;
std::unordered_set<lc::entity::CADEntity_CSPtr> _entities; //This should contains only instances of LCVDrawItem
std::map<ID_DATATYPE, LCVDrawItem_SPtr> _entities;
};
}

0 comments on commit 9868d99

Please sign in to comment.