54 std::vector<Gate*> gates;
62 std::vector<Net*> nets;
70 std::vector<Module*> modules;
86 if(clear_current_selection)
93 if(navigate_to_selection)
102 void GuiApi::selectGate(
const std::vector<Gate*>& gates,
bool clear_current_selection,
bool navigate_to_selection)
106 for(
auto gate : gates)
111 gate_ids.
insert(gate->get_id());
114 if(clear_current_selection)
121 if(navigate_to_selection)
125 void GuiApi::selectGate(
const std::vector<u32>& gate_ids,
bool clear_current_selection,
bool navigate_to_selection)
127 std::vector<Gate*> gates(gate_ids.size());
128 std::transform(gate_ids.begin(), gate_ids.end(), gates.begin(), [](
u32 gate_id){return gNetlist->get_gate_by_id(gate_id);});
129 selectGate(gates, clear_current_selection, navigate_to_selection);
137 if(clear_current_selection)
144 if(navigate_to_selection)
153 void GuiApi::selectNet(
const std::vector<Net*>& nets,
bool clear_current_selection,
bool navigate_to_selection)
165 if(clear_current_selection)
172 if(navigate_to_selection)
176 void GuiApi::selectNet(
const std::vector<u32>& net_ids,
bool clear_current_selection,
bool navigate_to_selection)
178 std::vector<Net*> nets(net_ids.size());
179 std::transform(net_ids.begin(), net_ids.end(), nets.begin(), [](
u32 mNetId){return gNetlist->get_net_by_id(mNetId);});
180 selectNet(nets, clear_current_selection, navigate_to_selection);
188 if(clear_current_selection)
195 if(navigate_to_selection)
204 void GuiApi::selectModule(
const std::vector<Module*>& modules,
bool clear_current_selection,
bool navigate_to_selection)
208 for(
auto module : modules)
216 if(clear_current_selection)
223 if(navigate_to_selection)
227 void GuiApi::selectModule(
const std::vector<u32>& module_ids,
bool clear_current_selection,
bool navigate_to_selection)
229 std::vector<Module*> modules(module_ids.size());
230 std::transform(module_ids.begin(), module_ids.end(), modules.begin(), [](
u32 g_id){return gNetlist->get_module_by_id(g_id);});
231 selectModule(modules, clear_current_selection, navigate_to_selection);
236 selectGate(gate, clear_current_selection, navigate_to_selection);
241 selectNet(
net, clear_current_selection, navigate_to_selection);
248 void GuiApi::select(
const std::vector<Gate*>& gates,
bool clear_current_selection,
bool navigate_to_selection)
250 selectGate(gates, clear_current_selection, navigate_to_selection);
252 void GuiApi::select(
const std::vector<Net*>& nets,
bool clear_current_selection,
bool navigate_to_selection)
254 selectNet(nets, clear_current_selection, navigate_to_selection);
257 void GuiApi::select(
const std::vector<Module*>& modules,
bool clear_current_selection,
bool navigate_to_selection)
259 selectModule(modules, clear_current_selection, navigate_to_selection);
262 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)
264 if(clear_current_selection)
271 if(navigate_to_selection)
275 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)
277 if(clear_current_selection)
284 if(navigate_to_selection)
306 for(
Gate* gate : gates)
311 auto it = gate_ids.
find(gate->get_id());
312 if (it != gate_ids.
end()) gate_ids.
erase(it);
321 std::vector<Gate*> gates(gate_ids.size());
322 std::transform(gate_ids.begin(), gate_ids.end(), gates.begin(), [](
u32 gate_id){return gNetlist->get_gate_by_id(gate_id);});
349 auto it = net_ids.
find(
net->get_id());
350 if (it != net_ids.
end()) net_ids.
erase(it);
359 std::vector<Net*> nets(net_ids.size());
360 std::transform(net_ids.begin(), net_ids.end(), nets.begin(), [](
u32 mNetId){return gNetlist->get_net_by_id(mNetId);});
387 if (it != module_ids.
end()) module_ids.
erase(it);
396 std::vector<Module*> modules(module_ids.size());
397 std::transform(module_ids.begin(), module_ids.end(), modules.begin(), [](
u32 module_id){return gNetlist->get_module_by_id(module_id);});
429 void GuiApi::deselect(
const std::vector<u32>& gate_ids,
const std::vector<u32>& net_ids,
const std::vector<u32>& module_ids)
436 void GuiApi::deselect(
const std::vector<Gate*>& gates,
const std::vector<Net*>& nets,
const std::vector<Module*>& modules)
452 for(
Module* mod : modules)
456 log_warning(
"gui",
"Null values not allowed in module argument");
461 for(
Gate* gate : gates)
465 log_warning(
"gui",
"Null values not allowed in gate argument");
471 bool isModuleExclusive =
false;
474 if(modules.empty() && gates.empty())
478 if(modules.size() == 1 && gates.empty() && modules[0]){
480 isModuleExclusive =
true;
484 if(ctx->name() ==
name){
511 if (isModuleExclusive){
537 for(
Module* mod : modules)
541 log_warning(
"gui",
"Null values not allowed in module argument");
546 for(
Gate* gate : gates)
550 log_warning(
"gui",
"Null values not allowed in gate argument");
576 for(
Module* mod : modules)
580 log_warning(
"gui",
"Null values not allowed in module argument");
585 for(
Gate* gate : gates)
589 log_warning(
"gui",
"Null values not allowed in gate argument");
601 for(
Gate* gate : gates)
602 gateIds.
insert(gate->get_id());
657 std::vector<Module*> modules;
670 std::vector<Gate*> gates;
682 for(
Module* mod : modules)
686 log_warning(
"gui",
"Null values not allowed in module argument");
691 for(
Gate* gate : gates)
695 log_warning(
"gui",
"Null values not allowed in gate argument");
700 std::vector<u32> ids;
711 for(
Gate* gate : gates)
714 gateIds.
insert(gate->get_id());
719 bool isCandidate =
true;
722 for(
u32 moduleId : moduleIds){
723 if(ctx->modules().contains(moduleId))
730 for(
u32 gateId : gateIds){
731 if(ctx->gates().contains(gateId))
740 ids.push_back(ctx->id());
755 if(context ==
nullptr)
return false;
774 if(context ==
nullptr)
return false;
780 bool isValidToFold =
false;
782 for(
Gate* gate : gates)
783 if(context->
gates().
contains(gate->get_id())) {isValidToFold =
true;
break;}
784 for(
Module* submodule : submodules)
785 if(context->
modules().
contains(submodule->get_id())) {isValidToFold =
true;
break;}
799 std::vector<Module*> modules = mods;
800 std::vector<Gate*> gates = gats;
814 std::vector<Module*> validMods;
818 existingModules.
insert(mod->get_id());
819 validMods.push_back(mod);
821 while (itr !=
nullptr)
833 existingGates.
insert(gate->get_id());
834 Module* itr = gate->get_module();
835 while (itr !=
nullptr)
844 for (
Module* mod : modules)
846 if (Parents.
contains(mod->get_id()))
848 validMods.push_back(mod);
853 for (
Module* mod : modules)
855 modIds.
insert(mod->get_id());
858 std::sort(modules.begin(), modules.end(), [](
const Module* a,
const Module* b) ->
bool
861 return a->get_submodule_depth() > b->get_submodule_depth();
865 for(
Module* mod : modules){
867 if(mod == topModule){
876 while(iterator !=
nullptr){
880 modIds.
remove(mod->get_id());
888 for (
Gate* gate : gates)
890 Module* itr = gate->get_module();
891 bool shouldInsert =
true;
892 while (itr !=
nullptr)
896 gatIds.
remove(gate->get_id());
897 shouldInsert =
false;
903 gatIds.
insert(gate->get_id());
909 modIds -= existingModules;
910 gatIds -= existingGates;
938 if(currentDirectory ==
nullptr)
942 if(currentDirectory->directory() ==
nullptr)
986 act =
new ActionMoveItem(destinationDirectoryId.value_or(getCurrentDirectory()), parentId, row.value());
988 act =
new ActionMoveItem(destinationDirectoryId.value_or(getCurrentDirectory()), parentId);
1004 u32 destId = destinationDirectoryId.value_or(getCurrentDirectory());
1006 while (destAnchestor)
1008 if (destAnchestor == directoryItem)
1010 log_warning(
"gui",
"Invalid attempt to move directory ID={} into dependend directory.", directoryId);
1013 destAnchestor = destAnchestor->
getParent();
1031 if(!directoryItem && directoryId != 0)
1032 return std::nullopt;
1040 if(!directoryItem && directoryId != 0)
1041 return std::nullopt;
Adds an item to a module or grouping.
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 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
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)
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