Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
joern274 committed Oct 2, 2023
1 parent 6ca908a commit 152cc46
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 62 deletions.
2 changes: 1 addition & 1 deletion include/hal_core/netlist/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ namespace hal
*
* @param[in] pin_group - The pin group to be moved.
* @param[in] new_index - The index to which the pin group is moved.
* @returns Ok on success, an error message otherwise.
* @returns true on success, false message otherwise.
*/
bool move_pin_group(PinGroup<ModulePin>* pin_group, u32 new_index);

Expand Down
11 changes: 0 additions & 11 deletions include/hal_core/netlist/pins/base_pin.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,6 @@ namespace hal
m_name = name;
}

int get_pos() const
{
auto g = get_group();
int i = 0;
for (auto p : g.first->get_pins())
{
if (p == this) return i;
++i;
}
return -1;
}
/**
* Get the name of the pin.
*
Expand Down
25 changes: 12 additions & 13 deletions plugins/gui/include/gui/user_action/action_pingroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ namespace hal
{
Q_OBJECT
public:
enum Type { None, GroupCreate, GroupDelete, GroupMove, GroupRename, GroupTypechange, GroupDirection,
PinAsignGroup, PinRename, PinTypechange, PinDirection, PinSetindex, MaxAction };
enum Type { None, GroupCreate, GroupDelete, GroupMoveToRow, GroupRename, GroupTypeChange, GroupDirChange,
PinAsignToGroup, PinRename, PinTypeChange, PinDirChange, PinMoveToRow, MaxAction };
Q_ENUM(Type);

public:
Expand Down Expand Up @@ -67,47 +67,46 @@ namespace hal
* ID will be used internally for subsequent commands related to crated group
* name : name of group
* value : start index, assume ascending
* negative value: descending order starting with (-value)
* negative value: descending order starting with (-value-1)
*
* GroupDelete
* ID : ID of group to delete
*
* GroupMove
* GroupMoveToRow
* ID : ID of group to move
* value : new position in vector of pin groups
* value : row to which group get moved within vector of pin groups
*
* GroupRename
* ID : ID of group to rename
* name : new name
*
* GroupTypechange
* GroupTypeChange
* ID : ID of group to modifiy
* value : (int) PinType as of hal_core/netlist/gate_library/enums/pin_type.h
*
* GroupDirection
* GroupDirChange
* ID : ID of group to modifiy
* value : (int) PinDirection as of hal_core/netlist/gate_library/enums/pin_direction.h
*
* PinAsignGroup
* PinAsignToGroup
* ID : ID of pin
* value : ID of group, might be negative if group recently created
*
* PinRename
* ID : ID of pin to rename
* name : new name
*
* PinTypechange
* PinTypeChange
* ID : ID of pin to modify
* value : (int) PinType
*
* PinDirection
* PinDirChange
* ID : ID of pin to modify
* value : (int) PinDirection
*
* PinSetindex
* PinMoveToRow
* ID : ID of pin
* value : new index in pingroup. Calculated from row by
* index = startindex + a * row with a=1 for ascending, a=-1 for descending
* value : row to which pin gets moved in pingroup
*/
class ActionPingroup : public UserAction
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ namespace hal
{
PinType ptype = enum_from_string<PinType>(cbd.textValue().toStdString(),PinType::none);

ActionPingroup* act = new ActionPingroup(PinActionType::PinTypechange,pin->get_id(),"",(int)ptype);
ActionPingroup* act = new ActionPingroup(PinActionType::PinTypeChange,pin->get_id(),"",(int)ptype);
act->setObject(UserActionObject(mod->get_id(), UserActionObjectType::Module));
act->exec();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -695,14 +695,14 @@ namespace hal
bool bottomEdge = row == mRootItem->getChildCount();
auto desiredIdx = bottomEdge ? row-1 : row;
if(ownRow < row && !bottomEdge) desiredIdx--;
ActionPingroup* act = new ActionPingroup(PinActionType::GroupMove,droppedGroup->id(),"",desiredIdx);
ActionPingroup* act = new ActionPingroup(PinActionType::GroupMoveToRow,droppedGroup->id(),"",desiredIdx);
act->setObject(UserActionObject(mModuleId,UserActionObjectType::Module));
act->exec();
}

void ModulePinsTreeModel::dndPinOnGroup(PortTreeItem *droppedPin, BaseTreeItem *onDroppedGroup)
{
ActionPingroup* act = new ActionPingroup(PinActionType::PinAsignGroup,droppedPin->id(),"",static_cast<PortTreeItem*>(onDroppedGroup)->id());
ActionPingroup* act = new ActionPingroup(PinActionType::PinAsignToGroup,droppedPin->id(),"",static_cast<PortTreeItem*>(onDroppedGroup)->id());
act->setObject(UserActionObject(mModuleId,UserActionObjectType::Module));
act->exec();
}
Expand All @@ -717,7 +717,7 @@ namespace hal
bool bottomEdge = row == onDroppedParent->getChildCount();
desiredIdx = bottomEdge ? row-1 : row;
if(ownRow < row && !bottomEdge) desiredIdx--; // insert item here
act = new ActionPingroup(PinActionType::PinSetindex,droppedPin->id(),"",desiredIdx); // TODO : start_index, descending
act = new ActionPingroup(PinActionType::PinMoveToRow,droppedPin->id(),"",desiredIdx); // TODO : start_index, descending
}
else
{
Expand Down
66 changes: 33 additions & 33 deletions plugins/gui/src/user_action/action_pingroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace hal
std::cerr << " grp: " << pg->get_id() << (pg->is_ascending()?" asc ": " des ") << pg->get_start_index()
<< " <" << pg->get_name() << ">\n";
for (ModulePin* pin : pg->get_pins())
std::cerr << " pin: " << pin->get_id() << " inx:" << pin->get_group().second << " pos:" << pin->get_pos() << " row:"
std::cerr << " pin: " << pin->get_id() << " inx:" << pin->get_group().second << " row:"
<< pinIndex2Row(pin,pin->get_group().second) << " <" << pin->get_name() << ">\n";
}
std::cerr << "-------------" << std::endl;
Expand Down Expand Up @@ -89,13 +89,13 @@ namespace hal

bool PinActionType::useExistingGroup(PinActionType::Type tp)
{
static const QSet<Type> types = {GroupDelete, GroupMove, GroupRename, GroupTypechange, GroupDirection};
static const QSet<Type> types = {GroupDelete, GroupMoveToRow, GroupRename, GroupTypeChange, GroupDirChange};
return types.contains(tp);
}

bool PinActionType::useExistingPin(PinActionType::Type tp)
{
static const QSet<Type> types = {PinAsignGroup, PinRename, PinTypechange, PinDirection, PinSetindex};
static const QSet<Type> types = {PinAsignToGroup, PinRename, PinTypeChange, PinDirChange, PinMoveToRow};
return types.contains(tp);
}

Expand Down Expand Up @@ -206,7 +206,7 @@ namespace hal
QHash<PinGroup<ModulePin>*,int> remainingPins;
for (const AtomicAction& aa : mPinActions)
{
if (aa.mType != PinActionType::PinAsignGroup)
if (aa.mType != PinActionType::PinAsignToGroup)
continue;
ModulePin* pin = mParentModule->get_pin_by_id(aa.mId);
PinGroup<ModulePin>* pgroup = pin->get_group().first;
Expand All @@ -232,11 +232,11 @@ namespace hal
{
const GroupRestore& gr = it.value();
restoreActions.append(AtomicAction(PinActionType::GroupCreate,gr.mId,gr.mName,gr.mStartIndex));
restoreActions.append(AtomicAction(PinActionType::GroupMove,gr.mId,"",gr.mRow));
restoreActions.append(AtomicAction(PinActionType::GroupMoveToRow,gr.mId,"",gr.mRow));
if (gr.mType != PinType::none)
restoreActions.append(AtomicAction(PinActionType::GroupTypechange,gr.mId,"",(int)gr.mType));
restoreActions.append(AtomicAction(PinActionType::GroupTypeChange,gr.mId,"",(int)gr.mType));
if (gr.mDirection != PinDirection::none)
restoreActions.append(AtomicAction(PinActionType::GroupDirection,gr.mId,"",(int)gr.mDirection));
restoreActions.append(AtomicAction(PinActionType::GroupDirChange,gr.mId,"",(int)gr.mDirection));
}
if (!restoreActions.isEmpty())
{
Expand Down Expand Up @@ -324,7 +324,7 @@ namespace hal
if (aa.mValue < 0)
{
ascending = false;
startIndex = -aa.mValue;
startIndex = -aa.mValue-1;
}
if (aa.mId > 0)
{
Expand All @@ -350,23 +350,23 @@ namespace hal
case PinActionType::GroupDelete:
{
int v = pgroup->get_start_index();
if (!pgroup->is_ascending()) v = -v;
if (!pgroup->is_ascending()) v = -v-1;
u32 id = pgroup->get_id();
int ptype = (int) pgroup->get_type();
int pdir = (int) pgroup->get_direction();
QString name = QString::fromStdString(pgroup->get_name());
if (!mParentModule->delete_pin_group(pgroup))
return false;
addUndoAction(PinActionType::GroupCreate,id,name,v);
addUndoAction(PinActionType::GroupTypechange,id,"",ptype);
addUndoAction(PinActionType::GroupDirection,id,"",pdir);
addUndoAction(PinActionType::GroupTypeChange,id,"",ptype);
addUndoAction(PinActionType::GroupDirChange,id,"",pdir);
break;
}
case PinActionType::GroupMove:
case PinActionType::GroupMoveToRow:
{
int inx = pinGroupRow(mParentModule,pgroup);
if (inx < 0) return false;
addUndoAction(PinActionType::GroupMove,pgroup->get_id(),"",inx);
addUndoAction(PinActionType::GroupMoveToRow,pgroup->get_id(),"",inx);
if (!mParentModule->move_pin_group(pgroup,aa.mValue))
return false;
break;
Expand All @@ -376,19 +376,19 @@ namespace hal
if (!mParentModule->set_pin_group_name(pgroup,aa.mName.toStdString()))
return false;
break;
case PinActionType::GroupTypechange:
addUndoAction(PinActionType::GroupTypechange,pgroup->get_id(),"",(int)pgroup->get_type());
case PinActionType::GroupTypeChange:
addUndoAction(PinActionType::GroupTypeChange,pgroup->get_id(),"",(int)pgroup->get_type());
if (!mParentModule->set_pin_group_type(pgroup, (PinType) aa.mValue))
return false;
break;
case PinActionType::GroupDirection:
addUndoAction(PinActionType::GroupDirection,pgroup->get_id(),"",(int)pgroup->get_direction());
case PinActionType::GroupDirChange:
addUndoAction(PinActionType::GroupDirChange,pgroup->get_id(),"",(int)pgroup->get_direction());
if (!mParentModule->set_pin_group_direction(pgroup, (PinDirection) aa.mValue))
return false;
break;
case PinActionType::PinAsignGroup:
addUndoAction(PinActionType::PinAsignGroup,aa.mId,"",pin->get_group().first->get_id());
addUndoAction(PinActionType::PinSetindex,aa.mId,"",pinIndex2Row(pin,pin->get_group().second));
case PinActionType::PinAsignToGroup:
addUndoAction(PinActionType::PinAsignToGroup,aa.mId,"",pin->get_group().first->get_id());
addUndoAction(PinActionType::PinMoveToRow,aa.mId,"",pinIndex2Row(pin,pin->get_group().second));
mPinsMoved.insert(aa.mId);
pgroup = getGroup(aa.mValue);
if (!pgroup) return false;
Expand All @@ -404,14 +404,14 @@ namespace hal
if (!mParentModule->set_pin_name(pin, aa.mName.toStdString()))
return false;
break;
case PinActionType::PinTypechange:
addUndoAction(PinActionType::PinTypechange,aa.mId,"",(int)pin->get_type());
case PinActionType::PinTypeChange:
addUndoAction(PinActionType::PinTypeChange,aa.mId,"",(int)pin->get_type());
if (!mParentModule->set_pin_type(pin, (PinType) aa.mValue))
return false;
break;
case PinActionType::PinSetindex:
case PinActionType::PinMoveToRow:
if (!mPinsMoved.contains(aa.mId))
addUndoAction(PinActionType::PinSetindex,aa.mId,"",pinIndex2Row(pin,pin->get_group().second));
addUndoAction(PinActionType::PinMoveToRow,aa.mId,"",pinIndex2Row(pin,pin->get_group().second));
pgroup = pin->get_group().first;
if (!mParentModule->move_pin_within_group(pgroup,pin,pinRow2Index(pin,aa.mValue)))
{
Expand All @@ -436,11 +436,11 @@ namespace hal
for (u32 pinId : pinIds)
{
if (retval)
retval->mPinActions.append(AtomicAction(PinActionType::PinAsignGroup,pinId,"",grpId));
retval->mPinActions.append(AtomicAction(PinActionType::PinAsignToGroup,pinId,"",grpId));
else
retval = new ActionPingroup(PinActionType::PinAsignGroup,pinId,"",grpId);
retval = new ActionPingroup(PinActionType::PinAsignToGroup,pinId,"",grpId);
if (pinRow >= 0)
retval->mPinActions.append(AtomicAction(PinActionType::PinSetindex,pinId,"",pinRow++));
retval->mPinActions.append(AtomicAction(PinActionType::PinMoveToRow,pinId,"",pinRow++));
}
retval->setObject(UserActionObject(m->get_id(),UserActionObjectType::Module));
return retval;
Expand All @@ -462,15 +462,15 @@ namespace hal
ModulePin* pin = m->get_pin_by_id(pinIds.first());
if (pin)
{
retval->mPinActions.append(AtomicAction(PinActionType::GroupDirection,vid,"",(int)pin->get_direction()));
retval->mPinActions.append(AtomicAction(PinActionType::GroupTypechange,vid,"",(int)pin->get_type()));
retval->mPinActions.append(AtomicAction(PinActionType::GroupDirChange,vid,"",(int)pin->get_direction()));
retval->mPinActions.append(AtomicAction(PinActionType::GroupTypeChange,vid,"",(int)pin->get_type()));
}
}
for (u32 pinId : pinIds)
retval->mPinActions.append(AtomicAction(PinActionType::PinAsignGroup,pinId,"",vid));
retval->mPinActions.append(AtomicAction(PinActionType::PinAsignToGroup,pinId,"",vid));

if (grpRow >= 0)
retval->mPinActions.append(AtomicAction(PinActionType::GroupMove,vid,"",grpRow));
retval->mPinActions.append(AtomicAction(PinActionType::GroupMoveToRow,vid,"",grpRow));
retval->setObject(UserActionObject(m->get_id(),UserActionObjectType::Module));
return retval;
}
Expand Down Expand Up @@ -502,7 +502,7 @@ namespace hal
retval->mPinActions.append(AtomicAction(PinActionType::GroupCreate,vid,name));
else
retval = new ActionPingroup(PinActionType::GroupCreate,vid,name);
retval->mPinActions.append(AtomicAction(PinActionType::PinAsignGroup,pinId,"",vid));
retval->mPinActions.append(AtomicAction(PinActionType::PinAsignToGroup,pinId,"",vid));
--vid;
}
retval->setObject(UserActionObject(m->get_id(),UserActionObjectType::Module));
Expand All @@ -517,6 +517,6 @@ namespace hal
mDirection(pgroup->get_direction()),
mType(pgroup->get_type())
{
if (!pgroup->is_ascending()) mStartIndex = -mStartIndex;
if (!pgroup->is_ascending()) mStartIndex = -mStartIndex-1;
}
}

0 comments on commit 152cc46

Please sign in to comment.