55 std::vector<Gate*> gates;
63 std::vector<Net*> nets;
71 std::vector<Module*> modules;
87 if(clear_current_selection)
94 if(navigate_to_selection)
103 void GuiApi::selectGate(
const std::vector<Gate*>& gates,
bool clear_current_selection,
bool navigate_to_selection)
107 for(
auto gate : gates)
112 gate_ids.
insert(gate->get_id());
115 if(clear_current_selection)
122 if(navigate_to_selection)
126 void GuiApi::selectGate(
const std::vector<u32>& gate_ids,
bool clear_current_selection,
bool navigate_to_selection)
128 std::vector<Gate*> gates(gate_ids.size());
129 std::transform(gate_ids.begin(), gate_ids.end(), gates.begin(), [](
u32 gate_id){return gNetlist->get_gate_by_id(gate_id);});
130 selectGate(gates, clear_current_selection, navigate_to_selection);
138 if(clear_current_selection)
145 if(navigate_to_selection)
154 void GuiApi::selectNet(
const std::vector<Net*>& nets,
bool clear_current_selection,
bool navigate_to_selection)
166 if(clear_current_selection)
173 if(navigate_to_selection)
177 void GuiApi::selectNet(
const std::vector<u32>& net_ids,
bool clear_current_selection,
bool navigate_to_selection)
179 std::vector<Net*> nets(net_ids.size());
180 std::transform(net_ids.begin(), net_ids.end(), nets.begin(), [](
u32 mNetId){return gNetlist->get_net_by_id(mNetId);});
181 selectNet(nets, clear_current_selection, navigate_to_selection);
189 if(clear_current_selection)
196 if(navigate_to_selection)
205 void GuiApi::selectModule(
const std::vector<Module*>& modules,
bool clear_current_selection,
bool navigate_to_selection)
209 for(
auto module : modules)
217 if(clear_current_selection)
224 if(navigate_to_selection)
228 void GuiApi::selectModule(
const std::vector<u32>& module_ids,
bool clear_current_selection,
bool navigate_to_selection)
230 std::vector<Module*> modules(module_ids.size());
231 std::transform(module_ids.begin(), module_ids.end(), modules.begin(), [](
u32 g_id){return gNetlist->get_module_by_id(g_id);});
232 selectModule(modules, clear_current_selection, navigate_to_selection);
237 selectGate(gate, clear_current_selection, navigate_to_selection);
242 selectNet(
net, clear_current_selection, navigate_to_selection);
249 void GuiApi::select(
const std::vector<Gate*>& gates,
bool clear_current_selection,
bool navigate_to_selection)
251 selectGate(gates, clear_current_selection, navigate_to_selection);
253 void GuiApi::select(
const std::vector<Net*>& nets,
bool clear_current_selection,
bool navigate_to_selection)
255 selectNet(nets, clear_current_selection, navigate_to_selection);
258 void GuiApi::select(
const std::vector<Module*>& modules,
bool clear_current_selection,
bool navigate_to_selection)
260 selectModule(modules, clear_current_selection, navigate_to_selection);
263 void GuiApi::select(
const std::vector<u32>& gate_ids,
const std::vector<u32>& net_ids,
const std::vector<u32>& module_ids,
bool clear_current_selection,
bool navigate_to_selection)
265 if(clear_current_selection)
272 if(navigate_to_selection)
276 void GuiApi::select(
const std::vector<Gate*>& gates,
const std::vector<Net*>& nets,
const std::vector<Module*>& modules,
bool clear_current_selection,
bool navigate_to_selection)
278 if(clear_current_selection)
285 if(navigate_to_selection)
307 for(
Gate* gate : gates)
312 auto it = gate_ids.
find(gate->get_id());
313 if (it != gate_ids.
end()) gate_ids.
erase(it);
322 std::vector<Gate*> gates(gate_ids.size());
323 std::transform(gate_ids.begin(), gate_ids.end(), gates.begin(), [](
u32 gate_id){return gNetlist->get_gate_by_id(gate_id);});
350 auto it = net_ids.
find(
net->get_id());
351 if (it != net_ids.
end()) net_ids.
erase(it);
360 std::vector<Net*> nets(net_ids.size());
361 std::transform(net_ids.begin(), net_ids.end(), nets.begin(), [](
u32 mNetId){return gNetlist->get_net_by_id(mNetId);});
388 if (it != module_ids.
end()) module_ids.
erase(it);
397 std::vector<Module*> modules(module_ids.size());
398 std::transform(module_ids.begin(), module_ids.end(), modules.begin(), [](
u32 module_id){return gNetlist->get_module_by_id(module_id);});
430 void GuiApi::deselect(
const std::vector<u32>& gate_ids,
const std::vector<u32>& net_ids,
const std::vector<u32>& module_ids)
437 void GuiApi::deselect(
const std::vector<Gate*>& gates,
const std::vector<Net*>& nets,
const std::vector<Module*>& modules)
451 if (!fromModId || !toModId || fromModId == toModId)
453 log_warning(
"gui",
"Isolate path from module to module called with faulty parameters");
459 log_warning(
"gui",
"Module ID={} to start path from not found.", fromModId);
465 log_warning(
"gui",
"Module ID={} to start path from not found.", toModId);
470 if (pathRows.empty())
472 log_warning(
"gui",
"No path found from module ID={} to module ID={}.", fromModId, toModId);
478 QSet<u32> moduleIds = {fromModId, toModId};
480 int nrows = pathRows.
size();
481 int ncols = pathRows.at(0).size();
485 for (
int icol = 1; icol < ncols-1; icol++)
488 for (
int irow = 0; irow < nrows; irow++)
490 u32 gateId = pathRows.at(irow).at(icol)->get_id();
491 if (gateIds.
contains(gateId))
continue;
512 for(
Module* mod : modules)
516 log_warning(
"gui",
"Null values not allowed in module argument");
521 for(
Gate* gate : gates)
525 log_warning(
"gui",
"Null values not allowed in gate argument");
531 bool isModuleExclusive =
false;
534 if(modules.empty() && gates.empty())
538 if(modules.size() == 1 && gates.empty() && modules[0]){
540 isModuleExclusive =
true;
544 if(ctx->name() ==
name){
571 if (isModuleExclusive){
597 for(
Module* mod : modules)
601 log_warning(
"gui",
"Null values not allowed in module argument");
606 for(
Gate* gate : gates)
610 log_warning(
"gui",
"Null values not allowed in gate argument");
636 for(
Module* mod : modules)
640 log_warning(
"gui",
"Null values not allowed in module argument");
645 for(
Gate* gate : gates)
649 log_warning(
"gui",
"Null values not allowed in gate argument");
661 for(
Gate* gate : gates)
662 gateIds.
insert(gate->get_id());
717 std::vector<Module*> modules;
730 std::vector<Gate*> gates;
742 for(
Module* mod : modules)
746 log_warning(
"gui",
"Null values not allowed in module argument");
751 for(
Gate* gate : gates)
755 log_warning(
"gui",
"Null values not allowed in gate argument");
760 std::vector<u32> ids;
771 for(
Gate* gate : gates)
774 gateIds.
insert(gate->get_id());
779 bool isCandidate =
true;
782 for(
u32 moduleId : moduleIds){
783 if(ctx->modules().contains(moduleId))
790 for(
u32 gateId : gateIds){
791 if(ctx->gates().contains(gateId))
800 ids.push_back(ctx->id());
815 if(context ==
nullptr)
return false;
834 if(context ==
nullptr)
return false;
840 bool isValidToFold =
false;
842 for(
Gate* gate : gates)
843 if(context->
gates().
contains(gate->get_id())) {isValidToFold =
true;
break;}
844 for(
Module* submodule : submodules)
845 if(context->
modules().
contains(submodule->get_id())) {isValidToFold =
true;
break;}
859 std::vector<Module*> modules = mods;
860 std::vector<Gate*> gates = gats;
874 std::vector<Module*> validMods;
878 existingModules.
insert(mod->get_id());
879 validMods.push_back(mod);
881 while (itr !=
nullptr)
893 existingGates.
insert(gate->get_id());
894 Module* itr = gate->get_module();
895 while (itr !=
nullptr)
904 for (
Module* mod : modules)
906 if (Parents.
contains(mod->get_id()))
908 validMods.push_back(mod);
913 for (
Module* mod : modules)
915 modIds.
insert(mod->get_id());
918 std::sort(modules.begin(), modules.end(), [](
const Module* a,
const Module* b) ->
bool
921 return a->get_submodule_depth() > b->get_submodule_depth();
925 for(
Module* mod : modules){
927 if(mod == topModule){
936 while(iterator !=
nullptr){
940 modIds.
remove(mod->get_id());
948 for (
Gate* gate : gates)
950 Module* itr = gate->get_module();
951 bool shouldInsert =
true;
952 while (itr !=
nullptr)
956 gatIds.
remove(gate->get_id());
957 shouldInsert =
false;
963 gatIds.
insert(gate->get_id());
969 modIds -= existingModules;
970 gatIds -= existingGates;
998 if(currentDirectory ==
nullptr)
1002 if(currentDirectory->directory() ==
nullptr)
1046 act =
new ActionMoveItem(destinationDirectoryId.value_or(getCurrentDirectory()), parentId, row.value());
1048 act =
new ActionMoveItem(destinationDirectoryId.value_or(getCurrentDirectory()), parentId);
1064 u32 destId = destinationDirectoryId.value_or(getCurrentDirectory());
1066 while (destAnchestor)
1068 if (destAnchestor == directoryItem)
1070 log_warning(
"gui",
"Invalid attempt to move directory ID={} into dependend directory.", directoryId);
1073 destAnchestor = destAnchestor->
getParent();
1091 if(!directoryItem && directoryId != 0)
1092 return std::nullopt;
1100 if(!directoryItem && directoryId != 0)
1101 return std::nullopt;
Adds an item to a module or grouping.
void setPlacementHint(PlacementHint hint)
Removes an item from a Module or Grouping.
(Future) Base class for all tree models related to the details widget.
virtual BaseTreeItem * getParent() const
BaseTreeItem * getRootItem() const
ContextDirectory * directory() const
std::vector< u32 > getChildDirectoriesOf(u32 directoryId)
void setCurrentDirectory(ContextTreeItem *currentItem)
std::vector< u32 > getChildContextsOf(u32 directoryId)
BaseTreeItem * getDirectory(u32 directoryId) const
ContextTreeItem * getCurrentDirectory()
BaseTreeItem * getContext(u32 contextId) const
Logical container for modules, gates, and nets.
u32 getExclusiveModuleId() const
bool isShowingModuleExclusively()
void setExclusiveModuleId(u32 id, bool emitSignal=true)
const QSet< u32 > & gates() const
const QSet< u32 > & modules() const
GraphLayouter * getLayouter() const
QString nextViewName(const QString &prefix) const
GraphContext * getContextById(u32 id) const
ContextTreeModel * getContextTreeModel() const
bool contextWithNameExists(const QString &name) const
QVector< GraphContext * > getContexts() const
GridPlacement * gridPlacementFactory() const
static bool foldModule(int view_id, Module *module)
static void deleteDirectory(u32 id)
static bool unfoldModule(int view_id, Module *module)
static void moveDirectory(u32 directoryId, std::optional< u32 > destinationDirectoryId, std::optional< int > row)
static int getId(const std::string &name)
static bool removeFrom(int id, const std::vector< Module * > modules, const std::vector< Gate * > gates)
static int isolateInNew(const std::vector< Module * > modules, const std::vector< Gate * > gates)
static bool setName(int id, const std::string &name)
static void moveView(u32 viewId, std::optional< u32 > destinationDirectoryId, std::optional< int > row)
static int isolateModuleToModulePathInNewView(u32 fromModId, u32 toModId)
static std::string getName(int id)
static GridPlacement * getGridPlacement(int viewId)
static bool setGridPlacement(int viewId, GridPlacement *gp)
static u32 createNewDirectory(const std::string &name)
static std::vector< Gate * > getGates(int id)
static std::optional< std::vector< u32 > > getChildDirectories(u32 directoryId)
static bool addTo(int id, const std::vector< Module * > modules, const std::vector< Gate * > gates)
static std::optional< std::vector< u32 > > getChildViews(u32 directoryId)
static bool deleteView(int id)
static std::vector< Module * > getModules(int id)
static void setCurrentDirectory(u32 id)
static std::vector< u32 > getIds(const std::vector< Module * > modules, const std::vector< Gate * > gates)
static u32 getCurrentDirectory()
static ModuleGateIdPair getValidObjects(int viewId, const std::vector< Module * >, const std::vector< Gate * >)
void deselectNet(u32 netId)
void deselectModule(u32 module_id)
std::vector< u32 > getSelectedNetIds()
std::tuple< std::vector< Gate * >, std::vector< Net * >, std::vector< Module * > > getSelectedItems()
std::vector< u32 > getSelectedModuleIds()
std::vector< Gate * > getSelectedGates()
std::vector< Net * > getSelectedNets()
void deselect(Gate *gate)
void selectNet(u32 netId, bool clear_current_selection=true, bool navigate_to_selection=true)
void navigationRequested()
void select(Gate *gate, bool clear_current_selection=true, bool navigate_to_selection=true)
std::vector< u32 > getSelectedGateIds()
std::vector< Module * > getSelectedModules()
std::tuple< std::vector< u32 >, std::vector< u32 >, std::vector< u32 > > getSelectedItemIds()
void selectModule(u32 module_id, bool clear_current_selection=true, bool navigate_to_selection=true)
void selectGate(u32 gate_id, bool clear_current_selection=true, bool navigate_to_selection=true)
void deselectGate(u32 gate_id)
Module * get_parent_module() const
const std::vector< Gate * > & get_gates() const
std::vector< Module * > get_submodules(const std::function< bool(Module *)> &filter=nullptr, bool recursive=false) const
Module * get_top_module() const
bool is_gate_in_netlist(const Gate *gate) const
Gate * get_gate_by_id(const u32 gate_id) const
bool is_module_in_netlist(const Module *module) const
bool is_net_in_netlist(const Net *net) const
Module * get_module_by_id(u32 module_id) const
Net * get_net_by_id(u32 net_id) const
The Node class object represents a module or a gate.
The PlacementHint class object provides hints for the layouter how new box objects are placed on a vi...
void setFocus(ItemType ftype, u32 fid, Subfocus sfoc=Subfocus::None, u32 sfinx=0)
const QSet< u32 > & selectedNets() const
void relaySelectionChanged(void *sender)
QList< u32 > selectedModulesList() const
const QSet< u32 > & selectedGates() const
void removeModule(u32 id)
QList< u32 > selectedNetsList() const
const QSet< u32 > & selectedModules() const
std::vector< u32 > selectedGatesVector() const
std::vector< u32 > selectedNetsVector() const
QList< u32 > selectedGatesList() const
void setSelectedGates(const QSet< u32 > &ids)
std::vector< u32 > selectedModulesVector() const
void setSelectedNets(const QSet< u32 > &ids)
void registerSender(void *sender, QString name)
void setSelectedModules(const QSet< u32 > &ids)
void addAction(UserAction *act)
void setUseCreatedObject()
virtual void setObject(const UserActionObject &obj)
virtual UserActionObject object() const
void executeActionBlockThread(UserAction *act)
static UserActionManager * instance()
The UserActionObject class represents a single object used in UserAction.
#define log_warning(channel,...)
const Module * module(const Gate *g, const NodeBoxes &boxes)
std::vector< Gate * > get_shortest_path(Gate *start_gate, Module *end_module, bool forward_direction)
GraphContextManager * gGraphContextManager
SelectionRelay * gSelectionRelay
bool contains(const T &value) const const
QSet::iterator erase(QSet::iterator pos)
QSet::iterator find(const T &value)
QSet::iterator insert(const T &value)
bool isEmpty() const const
bool remove(const T &value)
QSet< T > & unite(const QSet< T > &other)
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
QString fromStdString(const std::string &str)
std::string toStdString() const const