-
Notifications
You must be signed in to change notification settings - Fork 2
/
qtconceptmapcommandtogglearrowhead.cpp
63 lines (56 loc) · 1.66 KB
/
qtconceptmapcommandtogglearrowhead.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "qtconceptmapcommandtogglearrowhead.h"
#include <cassert>
#include <sstream>
#include "conceptmap.h"
#include "conceptmapedgefactory.h"
#include "conceptmapnode.h"
#include "get_my_custom_edge.h"
#include "set_my_custom_edge.h"
#include "qtconceptmap.h"
#include "qtconceptmapqtnode.h"
#include "count_vertices_with_selectedness.h"
#include "add_edge_between_selected_vertices.h"
#include "find_first_custom_edge.h"
#include <boost/algorithm/string/trim.hpp>
#include "find_first_custom_edge_with_my_edge.h"
#include "qtconceptmap.h"
#include "qtconceptmaptoolsitem.h"
#include "qtconceptmaphelper.h"
#include "qtconceptmapqtedge.h"
#include "qtconceptmapqtnode.h"
ribi::cmap::CommandToggleArrowHead::CommandToggleArrowHead(
QtConceptMap& qtconceptmap
) : Command(qtconceptmap)
{
{
std::stringstream msg;
msg << "Toggle arrow head";
this->setText(msg.str().c_str());
}
}
ribi::cmap::CommandToggleArrowHead * ribi::cmap::ParseCommandToggleArrowHead(
QtConceptMap& qtconceptmap, std::string s)
{
boost::algorithm::trim(s);
if (s == "toggle_head()" || s == "toggle_arrow_head()")
{
return new CommandToggleHead(qtconceptmap);
}
return nullptr;
}
void ribi::cmap::CommandToggleArrowHead::Redo()
{
const int n_selected_qtedges{CountSelectedQtEdges(GetQtConceptMap())};
if (n_selected_qtedges != 1)
{
std::stringstream msg;
msg << "Cannot toggle arrow head of " << n_selected_qtedges << " edges";
throw std::invalid_argument(msg.str());
}
QtEdge * const m_qtedge = ExtractTheOneSelectedQtEdge(GetQtConceptMap());
m_qtedge->SetHasHeadArrow(!HasHeadArrow(*m_qtedge));
}
void ribi::cmap::CommandToggleArrowHead::Undo()
{
Redo();
}