Ejemplo n.º 1
0
 SplitEdgesCommand::SplitEdgesCommand(Model::MapDocument& document, const wxString& name, const Model::EdgeList& edges, const Vec3f& delta) :
 SnapshotCommand(Command::MoveVertices, document, name),
 m_delta(delta) {
     Model::EdgeList::const_iterator it, end;
     for (it = edges.begin(), end = edges.end(); it != end; ++it) {
         const Model::Edge& edge = **it;
         Model::EdgeInfo edgeInfo = edge.info();
         Model::Brush* brush = edge.left->face->brush();
         
         BrushEdgeMapInsertResult result = m_brushEdges.insert(BrushEdgeMapEntry(brush, edgeInfo));
         assert(result.second);
         m_brushes.push_back(brush);
     }
 }
        bool MoveEdgesCommand::performDo() {
            if (!canDo())
                return false;
            
            m_edges.clear();
            makeSnapshots(m_brushes);
            document().brushesWillChange(m_brushes);
            
            BrushEdgesMap::const_iterator it, end;
            for (it = m_brushEdges.begin(), end = m_brushEdges.end(); it != end; ++it) {
                Model::Brush* brush = it->first;
                const Model::EdgeList& edges = it->second;
                const Model::EdgeList newEdges = brush->moveEdges(edges, m_delta);
                m_edges.insert(m_edges.end(), newEdges.begin(), newEdges.end());
            }

            document().brushesDidChange(m_brushes);
            return true;
        }