34 #include <wx/splitter.h>
35 #include <wx/progdlg.h>
71 wxPanel(parent,
id), manager_(NULL) {
73 wxSplitterWindow* splitter =
new wxSplitterWindow(
this, wxVERTICAL);
75 wxBoxSizer* sizer =
new wxBoxSizer(wxVERTICAL);
76 tree_ =
new wxTreeCtrl(splitter, ID_TREE_VIEW);
78 splitter->SetMinimumPaneSize(150);
79 splitter->SplitVertically(tree_, infoPanel_);
80 sizer->Add(splitter, 1, wxGROW);
101 infoPanel_->setHDB(manager);
111 fuArchitectures_.clear();
112 rfArchitectures_.clear();
113 fuImplementations_.clear();
114 rfImplementations_.clear();
118 socketEntries_.clear();
119 costPlugins_.clear();
121 tree_->DeleteAllItems();
122 wxTreeItemId root = tree_->AddRoot(_T(
"HDB"));
124 wxTreeItemId fus = tree_->AppendItem(
127 wxTreeItemId rfs = tree_->AppendItem(
130 wxTreeItemId fuEntries = tree_->AppendItem(
133 wxTreeItemId rfEntries = tree_->AppendItem(
136 wxTreeItemId busEntries = tree_->AppendItem(
139 wxTreeItemId socketEntries = tree_->AppendItem(
142 wxTreeItemId costPlugins = tree_->AppendItem(
145 wxTreeItemId operationImplementations = tree_->AppendItem(
148 wxTreeItemId operationImplementationResources = tree_->AppendItem(
151 std::set<RowID>::iterator iter;
154 std::set<RowID> fuArchIds = manager_->fuArchitectureIDs();
155 std::set<RowID> rfArchIds = manager_->rfArchitectureIDs();
156 std::set<RowID> fuIDs = manager_->fuEntryIDs();
157 std::set<RowID> rfIDs = manager_->rfEntryIDs();
158 std::set<RowID> busIDs = manager_->busEntryIDs();
159 std::set<RowID> socketIDs = manager_->socketEntryIDs();
160 std::set<RowID> pluginIDs = manager_->costFunctionPluginIDs();
161 std::set<RowID> operationImplementationIDs = manager_->OperationImplementationIDs();
162 std::set<RowID> operationImplementationResourceIDs = manager_->OperationImplementationResourceIDs();
164 int entries = fuArchIds.size() + rfArchIds.size() + fuIDs.size() +
165 rfIDs.size() + busIDs.size() + socketIDs.size() + pluginIDs.size();
169 wxProgressDialog dialog(
170 _T(
"Loading HDB"), _T(
"Loading HDB"), entries,
this,
171 wxPD_APP_MODAL|wxPD_AUTO_HIDE);
173 dialog.SetSize(300,100);
175 int ids = fuArchIds.size();
180 for (iter = fuArchIds.begin(); iter != fuArchIds.end(); iter++) {
182 const FUArchitecture& arch = manager_->fuArchitectureByIDConst(*iter);
185 wxTreeItemId
id = tree_->AppendItem(fus, fuArchLabel(fu));
186 fuArchitectures_[*iter] = id;
189 message.Printf(wxT(
"Loading FU Architectures... (%04d / %04d)"),cur,ids);
190 dialog.Update(c, message);
191 dialog.SetSize(300,100);
193 tree_->SortChildren(fus);
196 ids = rfArchIds.size();
198 for (iter = rfArchIds.begin(); iter != rfArchIds.end(); iter++) {
200 wxTreeItemId
id = tree_->AppendItem(rfs, archLabel);
201 rfArchitectures_[*iter] = id;
204 message.Printf(wxT(
"Loading RF Architectures... (%04d / %04d)"),cur,ids);
205 dialog.Update(c, message);
206 dialog.SetSize(300,100);
212 for (iter = fuIDs.begin(); iter != fuIDs.end(); iter++) {
213 const FUEntry* fuEntry = manager_->fuByEntryID(*iter);
215 wxTreeItemId entryTreeID = tree_->AppendItem(fuEntries, fuEntryLabel);
216 fuEntries_[*iter] = entryTreeID;
221 int archID = arch.
id();
222 wxTreeItemId archTreeID = fuArchitectures_[archID];
227 wxTreeItemId
id = tree_->AppendItem(archTreeID, impName);
228 fuImplementations_[imp.
id()] = id;
235 message.Printf(wxT(
"Loading FU entries... (%04d / %04d)"),cur,ids);
236 dialog.Update(c, message);
237 dialog.SetSize(300,100);
243 for (iter = rfIDs.begin(); iter != rfIDs.end(); iter++) {
244 const RFEntry* rfEntry = manager_->rfByEntryID(*iter);
246 wxTreeItemId entryTreeID = tree_->AppendItem(rfEntries, rfEntryLabel);
247 rfEntries_[*iter] = entryTreeID;
251 int archID = arch.
id();
252 wxTreeItemId archTreeID = rfArchitectures_[archID];
257 wxTreeItemId
id = tree_->AppendItem(archTreeID, impName);
258 rfImplementations_[imp.
id()] = id;
264 message.Printf(wxT(
"Loading RF entries... (%04d / %04d)"),cur,ids);
265 dialog.Update(c, message);
266 dialog.SetSize(300,100);
272 for (iter = busIDs.begin(); iter != busIDs.end(); iter++) {
274 wxTreeItemId entryTreeID =
275 tree_->AppendItem(busEntries, busEntryLabel);
277 busEntries_[*iter] = entryTreeID;
280 message.Printf(wxT(
"Loading bus entries... (%04d / %04d)"),cur,ids);
281 dialog.Update(c, message);
282 dialog.SetSize(300,100);
287 ids = socketIDs.size();
288 for (iter = socketIDs.begin(); iter != socketIDs.end(); iter++) {
290 wxTreeItemId entryTreeID =
291 tree_->AppendItem(socketEntries, socketEntryLabel);
293 socketEntries_[*iter] = entryTreeID;
295 message.Printf(wxT(
"Loading socket entries... (%04d / %04d)"),cur,ids);
296 dialog.Update(c, message);
297 dialog.SetSize(300,100);
302 ids = pluginIDs.size();
303 for (iter = pluginIDs.begin(); iter != pluginIDs.end(); iter++) {
306 manager_->costFunctionPluginByID(*iter);
309 wxTreeItemId
id = tree_->AppendItem(costPlugins, pluginName);
310 costPlugins_[*iter] = id;
314 message.Printf(wxT(
"Loading cost estimation plugins... (%04d / %04d)"),cur,ids);
315 dialog.Update(c, message);
316 dialog.SetSize(300,100);
320 for (
auto &
id : operationImplementationIDs) {
321 auto op = manager_->OperationImplementationByID(
id);
322 std::string label = std::to_string(
id) +
" : " + op.
name;
323 tree_->AppendItem(operationImplementations, label);
327 for (
auto &
id : operationImplementationResourceIDs) {
328 auto res = manager_->OperationImplementationResourceByID(
id);
329 std::string label = std::to_string(
id) +
" : " + res.name;
330 tree_->AppendItem(operationImplementationResources, label);
366 fuImplementations_, tree_->GetSelection());
378 rfImplementations_, tree_->GetSelection());
440 std::string parent = tree_->GetItemParent(tree_->GetSelection()).IsOk() ?
441 tree_->GetItemText(tree_->GetItemParent(tree_->GetSelection()))
442 .ToStdString() :
"none";
443 return parent ==
"Operation Implementation Resources";
454 std::string parent = tree_->GetItemParent(tree_->GetSelection()).IsOk() ?
455 tree_->GetItemText(tree_->GetItemParent(tree_->GetSelection()))
456 .ToStdString() :
"none";
457 return parent ==
"Operation Implementations";
467 if (!isFUArchitectureSelected()) {
471 RowID id = MapTools::keyForValue<RowID>(
472 fuArchitectures_, tree_->GetSelection());
484 if (!isRFArchitectureSelected()) {
487 RowID id = MapTools::keyForValue<RowID>(
488 rfArchitectures_, tree_->GetSelection());
501 if (!isFUImplementationSelected()) {
504 RowID id = MapTools::keyForValue<RowID>(
505 fuImplementations_, tree_->GetSelection());
518 if (!isRFImplementationSelected()) {
521 RowID id = MapTools::keyForValue<RowID>(
522 rfImplementations_, tree_->GetSelection());
534 if (!isFUEntrySelected()) {
537 RowID id = MapTools::keyForValue<RowID>(
538 fuEntries_, tree_->GetSelection());
550 if (!isRFEntrySelected()) {
553 RowID id = MapTools::keyForValue<RowID>(
554 rfEntries_, tree_->GetSelection());
566 if (!isBusEntrySelected()) {
569 RowID id = MapTools::keyForValue<RowID>(
570 busEntries_, tree_->GetSelection());
582 if (!isSocketEntrySelected()) {
585 RowID id = MapTools::keyForValue<RowID>(
586 socketEntries_, tree_->GetSelection());
599 if (!isCostFunctionPluginSelected()) {
602 RowID id = MapTools::keyForValue<RowID>(
603 costPlugins_, tree_->GetSelection());
615 if (!isOperationImplementationSelected()) {
618 std::istringstream iss(tree_->GetItemText(tree_->GetSelection())
633 if (!isOperationImplementationResourceSelected()) {
636 std::istringstream iss(tree_->GetItemText(tree_->GetSelection())
655 tree_->SelectItem(fuEntries_[
id]);
670 tree_->SelectItem(rfEntries_[
id]);
685 tree_->SelectItem(busEntries_[
id]);
700 tree_->SelectItem(socketEntries_[
id]);
715 tree_->SelectItem(fuArchitectures_[
id]);
730 tree_->SelectItem(rfArchitectures_[
id]);
745 tree_->SelectItem(fuImplementations_[
id]);
760 tree_->SelectItem(rfImplementations_[
id]);
775 tree_->SelectItem(costPlugins_[
id]);
784 wxTreeCtrl* ctrl =
new wxTreeCtrl();
785 std::string current = ctrl->GetItemText(e.GetItem().GetID()).ToStdString();
786 std::string parent = ctrl->GetItemParent(e.GetItem().GetID()).IsOk() ?
787 ctrl->GetItemText(ctrl->GetItemParent(e.GetItem().GetID())).ToStdString() :
792 if (isFUArchitectureSelected()) {
793 infoPanel_->displayFUArchitecture(selectedFUArchitecture());
794 }
else if (isRFArchitectureSelected()) {
795 infoPanel_->displayRFArchitecture(selectedRFArchitecture());
796 }
else if (isFUImplementationSelected()) {
797 infoPanel_->displayFUImplementation(selectedFUImplementation());
798 }
else if (isRFImplementationSelected()) {
799 infoPanel_->displayRFImplementation(selectedRFImplementation());
800 }
else if (isFUEntrySelected()) {
801 infoPanel_->displayFUEntry(selectedFUEntry());
802 }
else if (isRFEntrySelected()) {
803 infoPanel_->displayRFEntry(selectedRFEntry());
804 }
else if (isBusEntrySelected()) {
805 infoPanel_->displayBusEntry(selectedBusEntry());
806 }
else if (isSocketEntrySelected()) {
807 infoPanel_->displaySocketEntry(selectedSocketEntry());
808 }
else if (isCostFunctionPluginSelected()) {
809 infoPanel_->displayCostFunctionPlugin(selectedCostFunctionPlugin());
811 std::istringstream iss(current);
814 infoPanel_->displayOperationImplementation(
id);
816 std::istringstream iss(current);
819 infoPanel_->displayOperationImplementationResource(
id);
833 tree_->SelectItem(event.GetItem());
834 wxMenu* popupMenu =
new wxMenu();
835 if (isFUArchitectureSelected()) {
838 _T(
"Add &Implementation..."));
840 if (isRFArchitectureSelected()) {
843 _T(
"Add &Implementation..."));
845 if (isFUEntrySelected() || isRFEntrySelected()) {
848 _T(
"Set Cost Function Plugin"));
851 popupMenu->AppendSeparator();
854 PopupMenu(popupMenu, event.GetPoint());
867 std::set<std::string> opNames;
873 opNames.insert(opName);
877 std::set<std::string>::const_iterator oIter = opNames.begin();
878 for (; oIter != opNames.end(); oIter++) {
880 archName.Append(_T(
" "));
894 const wxString fuArchPrefix =
898 const wxString rfArchPrefix =
902 const wxString fuEntryPrefix =
905 const wxString rfEntryPrefix =
908 const wxString busEntryPrefix =
911 const wxString socketEntryPrefix =
915 const wxString fuImplPrefix =
919 const wxString rfImplPrefix =
923 const wxString costPluginPrefix =
927 if (link.StartsWith(fuArchPrefix, &rest)) {
929 selectFUArchitecture(
id);
930 }
else if (link.StartsWith(rfArchPrefix, &rest)) {
932 selectRFArchitecture(
id);
933 }
else if (link.StartsWith(fuEntryPrefix, &rest)) {
936 }
else if (link.StartsWith(rfEntryPrefix, &rest)) {
939 }
else if (link.StartsWith(busEntryPrefix, &rest)) {
942 }
else if (link.StartsWith(socketEntryPrefix, &rest)) {
944 selectSocketEntry(
id);
945 }
else if (link.StartsWith(fuImplPrefix, &rest)) {
947 selectFUImplementation(
id);
948 }
else if (link.StartsWith(rfImplPrefix, &rest)) {
950 selectRFImplementation(
id);
951 }
else if (link.StartsWith(costPluginPrefix, &rest)) {
953 selectCostFunctionPlugin(
id);