Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions include/hal_core/netlist/netlist_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,6 @@ namespace hal
const std::function<bool(const Gate*)>& filter = nullptr);

/**
* \deprecated
* Find the shortest path (i.e., theresult set with the lowest number of gates) that connects the start gate with the end gate.
* The gate where the search started from will be the first in the result vector, the end gate will be the last.
* If there is no such path an empty vector is returned. If there is more than one path with the same length only the first one is returned.
Expand All @@ -347,7 +346,18 @@ namespace hal
* @param[in] search_both_directions - True to additionally check whether a shorter path from end to start exists, false otherwise.
* @return A vector of gates that connect the start with end gate (possibly in reverse order).
*/
[[deprecated("Will be removed in a future version, use NetlistTraversalDecorator::get_shortest_path instead.")]] CORE_API std::vector<Gate*>
get_shortest_path(Gate* start_gate, Gate* end_gate, bool search_both_directions = false);
CORE_API std::vector<Gate*> get_shortest_path(Gate* start_gate, Gate* end_gate, bool search_both_directions = false);

/**
* Find the shortest path (i.e., theresult set with the lowest number of gates) that connects the start gate with any gate from the given module.
* The gate where the search started from will be the first in the result vector, the end gate will be the last.
* If there is no such path an empty vector is returned. If there is more than one path with the same length only the first one is returned.
*
* @param[in] start_gate - The gate to start from.
* @param[in] end_gate - The gate to connect to.
* @param[in] search_both_directions - True to additionally check whether a shorter path from end to start exists, false otherwise.
* @return A vector of gates that connect the start with end gate (possibly in reverse order).
*/
CORE_API std::vector<Gate*> get_shortest_path(Gate* start_gate, Module* end_module);
} // namespace netlist_utils
} // namespace hal
} // namespace hal
10 changes: 7 additions & 3 deletions plugins/gui/include/gui/graph_widget/contexts/graph_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ namespace hal
*/
bool isModuleUnfolded(const u32 moduleId) const;


void refreshModule(const u32 moduleId);

/**
* Unfold a specific module. The specified module is removed from the context and replaced by its Gate%s and
* submodules.
Expand Down Expand Up @@ -322,9 +325,10 @@ namespace hal
}

/**
* Move node to antother grid location
*/
void moveNodeAction(const QPoint& from, const QPoint& to);
* Update placement of nodes already existing in view
* @param plc - the placement hash (Node -> QPoint)
*/
void updatePlacement(const GridPlacement& plc);

/**
* Returns whether the scene is in an updating process (i.e. layouter process) or not.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,8 @@ namespace hal
static SettingsItemCheckbox* sSettingNetGroupingToPins;

static SettingsItemCheckbox* sSettingPanOnMiddleButton;

static SettingsItemCheckbox* sSettingLayoutOnEveryChange;
Q_SIGNALS:
/**
* Q_SIGNAL that notifies about the creation of a new context by the context manager.
Expand Down
10 changes: 7 additions & 3 deletions plugins/gui/include/gui/graph_widget/graph_graphics_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@ namespace hal

public Q_SLOTS:
/**
* highlight shortest path between two gates by putting the items on path into a new group
* highlight shortest path between source gate and target node by putting the items on path into a new group
*
* @param idFrom - id of gate where path starts
* @param idTo - id of gate where path ends
*/
void handleShortestPath(u32 idFrom, u32 idTo);
void handleShortestPath(u32 idFrom, Node nodeTo);

/**
* remove selected nodes from view
Expand All @@ -146,7 +146,9 @@ namespace hal
void handleUnfoldAllAction();

void handleShortestPathToView();
void handleQueryShortestPath();
void handleShortestModulePathToView();
void handleQueryShortestPathGate();
void handleQueryShortestPathModule();
void handleSelectOutputs();
void handleSelectInputs();

Expand Down Expand Up @@ -182,6 +184,8 @@ namespace hal
void resizeEvent(QResizeEvent* event) override;

private:

enum SearchAction {PredecessorGate, SuccessorGate, SuccessorModule};
void mousePressEventNotItemDrag(QMouseEvent* event);
void showContextMenu(const QPoint& pos);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ namespace hal {
* @brief A standard net that has parts of a separated net.
*
* The GraphicsNet that can be used to display nets in the scene.
* Currently only used in GraphLayouter::alternateLayout().
*/
class StandardArrowNet : public StandardGraphicsNet
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,8 @@ namespace hal

static QPen sPen;

static QFont sTextFont[2];
static QFont sPinFont;

static qreal sTextFontHeight[2];

static qreal sColorBarHeight;

Expand All @@ -144,8 +142,6 @@ namespace hal

void format(const bool& adjust_size_to_grid);

QPointF mTextPosition[2];

QVector<float> mInputPinTextWidth;
QVector<float> mOutputPinTextWidth;
static const int sIconPadding;
Expand All @@ -155,7 +151,5 @@ namespace hal
static const QPixmap& iconPixmap();
static QColor legibleColor(const QColor& bgColor);

public:
static QColor sTextColor;
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "gui/graph_widget/items/graphics_item.h"

#include <QString>
#include <QFont>

namespace hal
{
Expand Down Expand Up @@ -63,9 +64,8 @@ namespace hal
*
* @param type - The type of the GraphicsItem (i.e. module, gate or net)
* @param id - The id of the underlying object (e.g. the module id if ItemType::Module)
* @param name - The name of the node
*/
GraphicsNode(const ItemType type, const u32 id, const QString& name);
GraphicsNode(const ItemType type, const u32 id);

/**
* Get the bounding rectangle of the GrahpicsNode that represent its size. Therefore the returned rectangle is
Expand Down Expand Up @@ -200,16 +200,48 @@ namespace hal
*/
void set_name(const QString& name);

/**
* Loads the cosmetic setting that will be applied to all GraphicsModules.
*/
static void loadSettings();

/**
* Pen color for text lines
*/
static QColor sTextColor;


// qreal xOffset() const;
// qreal yOffset() const;

protected:
/**
* The text font for node name and type. Consider to change it to non-static in case derived class wants to overwrite
*/
static QFont sTextFont[3];

/**
* Height of selected font
*/
static qreal sTextFontHeight[3];


/**
* The text in the center of the GraphicsNode. Each index stores one line of text. Therefore there is a maximum
* of 3 lines in total.
*/
QString mNodeText[3];

/**
* Text position in box.
*/
QPointF mTextPosition[3];

/**
* Maximum text width, used to determine box width
*/
qreal mMaxTextWidth;

/**
* The <b>width</b> of the GraphicsNode
*/
Expand All @@ -233,5 +265,15 @@ namespace hal
* netId=0 implies that no net is connected to the output pin at pinIdx.
*/
QMultiHash<u32,int> mOutputByNet;

/**
* Set text lines, on init adjust width, else truncate lines
*/
void setNodeText(const QString* lines, bool init);

/**
* Init text position after box width has been calculated
*/
void initTextPosition(qreal y0, qreal spacing);
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ namespace hal
*/
explicit GraphicsModule(Module* m);

/**
* Set the text label for module box.
*
* @param m - The underlying module of this GraphicsModule
*/
void setModuleLabel(const Module* m, bool init=false);

protected:
/**
* Represents one pin (both input or output) of a module. It stores the pin type name and the id of the net
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,8 @@ namespace hal

static QPen sPen;

static QFont sTextFont[3];
static QFont sPinFont;

static qreal sTextFontHeight[3];

static qreal sColorBarHeight;

static qreal sPinInnerHorizontalSpacing;
Expand All @@ -142,15 +139,11 @@ namespace hal

void format(const bool& adjust_size_to_grid);

QPointF mTextPosition[3];

QVector<QPointF> mOutputPinPositions;
static const int sIconPadding;
static const QSize sIconSize;

static QPixmap* sIconInstance;
static const QPixmap& iconPixmap();
public:
static QColor sTextColor;
};
} // namespace hal
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ namespace hal
* Does the actual layout process.
*/
void layout();
void alternateLayout();

/**
* Gets the GraphicsScene the layouter works on.
Expand All @@ -285,6 +284,8 @@ namespace hal

void dumpNodePositions(const QPoint& search) const;

void updatePlacement(const GridPlacement& plc);

void setNodePosition(const Node& n, const QPoint& p);
void swapNodePositions(const Node& n1, const Node& n2);
void removeNodeFromMaps(const Node& n);
Expand Down
19 changes: 17 additions & 2 deletions plugins/gui/include/gui/gui_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,13 @@ namespace hal
GridPlacement(const QHash<hal::Node,QPoint>& data) : QHash<hal::Node,QPoint>(data) {;}

void setGatePosition(u32 gateId, std::pair<int,int>p, bool swap = false) {
QPoint pos = QPoint(gatePosition(gateId)->first, gatePosition(gateId)->second); //position of current gate to move
std::pair<int,int>* posPtr = gatePosition(gateId);
if (!posPtr)
{
log_warning("gui", "Gate id {} cannot be moved, not found in current placement", gateId);
return;
}
QPoint pos = QPoint(posPtr->first, posPtr->second); //position of current gate to move
hal::Node nd = key(QPoint(p.first, p.second)); //find the node in the destination

if(!nd.isNull() && !swap) //if the destination placement is not available
Expand All @@ -159,8 +165,15 @@ namespace hal
else
operator[](hal::Node(gateId,hal::Node::Gate)) = QPoint(p.first,p.second);
}

void setModulePosition(u32 moduleId, std::pair<int,int>p, bool swap = false){
QPoint pos = QPoint(modulePosition(moduleId)->first, modulePosition(moduleId)->second);
std::pair<int,int>* posPtr = modulePosition(moduleId);
if (!posPtr)
{
log_warning("gui", "Module id {} cannot be moved, not found in current placement", moduleId);
return;
}
QPoint pos = QPoint(posPtr->first, posPtr->second); //position of current module to move
hal::Node nd = key(QPoint(p.first, p.second));

if(!nd.isNull() && !swap)
Expand All @@ -174,11 +187,13 @@ namespace hal
}
else
operator[](hal::Node(moduleId,hal::Node::Module)) = QPoint(p.first,p.second);};

std::pair<int,int>* gatePosition(u32 gateId) const
{
auto it = constFind(hal::Node(gateId,hal::Node::Gate));
return (it == constEnd() ? nullptr : new std::pair<int,int>(it->x(),it->y()));
}

std::pair<int,int>* modulePosition(u32 moduleId) const
{
auto it = constFind(hal::Node(moduleId,hal::Node::Module));
Expand Down
11 changes: 10 additions & 1 deletion plugins/gui/include/gui/module_model/module_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,19 @@ namespace hal
void updateModuleParent(const Module* module);

/**
* Updates the ModuleItems for the specified module. The specified module MUST be contained in the item model.
* Updates the ModuleItems name for the specified module. The specified module MUST be contained in the item model.
*
* @param id - The id of the module to update
*/
void updateModuleName(const u32 id);

/**
* Updates the ModuleItems type for the specified module. The specified module MUST be contained in the item model.
*
* @param id - The id of the module to update
*/
void updateModuleType(const u32 id);

/**
* Updates the ModuleItems for the specified gate. The specified gate MUST be contained in the item model.
*
Expand All @@ -284,6 +291,8 @@ namespace hal
private Q_SLOTS:
void handleModuleNameChanged(Module* mod);

void handleModuleTypeChanged(Module* mod);

void handleModuleRemoved(Module* mod);

void handleModuleCreated(Module* mod);
Expand Down
20 changes: 15 additions & 5 deletions plugins/gui/src/graph_widget/contexts/graph_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "gui/graph_widget/layout_locker.h"
#include "gui/graph_widget/graphics_scene.h"
#include "gui/graph_widget/graph_widget.h"
#include "gui/graph_widget/items/nodes/modules/standard_graphics_module.h"
#include "gui/context_manager_widget/context_manager_widget.h"
#include "gui/gui_globals.h"
#include "gui/gui_def.h"
Expand Down Expand Up @@ -481,6 +482,18 @@ namespace hal
update();
}

void GraphContext::refreshModule(const u32 moduleId)
{
NodeBox* box = getLayouter()->boxes().boxForNode(Node(moduleId,Node::Module));
if (!box) return;
Module* m = gNetlist->get_module_by_id(moduleId);
if (!m) return;
GraphicsModule* gm = dynamic_cast<GraphicsModule*>(box->item());
if (!gm) return;
gm->setModuleLabel(m);
gm->update();
}

Node GraphContext::nodeForGate(const u32 id) const
{
if (mGates.contains(id))
Expand Down Expand Up @@ -520,12 +533,9 @@ namespace hal
if (mParentWidget) mParentWidget->storeViewport();
}

void GraphContext::moveNodeAction(const QPoint& from, const QPoint& to)
void GraphContext::updatePlacement(const GridPlacement& plc)
{
const QMap<QPoint,Node> nodeMap = mLayouter->positionToNodeMap();
auto it = nodeMap.find(from);
if (it==nodeMap.constEnd()) return;
mLayouter->setNodePosition(it.value(),to);
mLayouter->updatePlacement(plc);
scheduleSceneUpdate();
}

Expand Down
Loading
Loading