fixed trans modify
This commit is contained in:
parent
89ebbb315d
commit
b089163f32
|
|
@ -121,6 +121,13 @@ struct DiagramEditorComponentInfo //组态设备信息
|
|||
}
|
||||
};
|
||||
|
||||
enum class Direction : int {
|
||||
Right = 1,
|
||||
Left = 2,
|
||||
Down = 4,
|
||||
Up = 8
|
||||
};
|
||||
|
||||
inline uint qHash(const DiagramEditorComponentInfo &key, uint seed = 0) {
|
||||
return qHash(key.uid, seed);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,6 +88,9 @@ set(DIAGRAMCAVAS_HEADER_FILES
|
|||
include/diagramEditor/transformerBuilder.h
|
||||
include/diagramEditor/layoutData.h
|
||||
include/diagramEditor/layoutCalculator.h
|
||||
include/diagramEditor/editorLayoutConfig.h
|
||||
include/diagramEditor/editorDirectionManager.h
|
||||
include/diagramEditor/editorDiagramLayoutEngine.h
|
||||
include/graphicsDataModel/baseModel.h
|
||||
include/graphicsDataModel/fixedPortsModel.h
|
||||
include/graphicsDataModel/diagramEditorModel.h
|
||||
|
|
|
|||
|
|
@ -0,0 +1,58 @@
|
|||
#include "common/core_model/diagram.h"
|
||||
#include "diagramEditor/editorLayoutConfig.h"
|
||||
#include <QStandardItem>
|
||||
// layout_engine.h
|
||||
/********editor布局生成核心类**********/
|
||||
|
||||
class DiagramLayoutEngine {
|
||||
public:
|
||||
struct LayoutResult {
|
||||
QRectF boundingRect;
|
||||
bool success = true;
|
||||
QString errorMessage;
|
||||
};
|
||||
|
||||
LayoutResult layoutRoutes(QMap<QString, DiagramEditorRouteInfo>& routes,
|
||||
QMap<QString, DiagramEditorComponentInfo>& components,
|
||||
const LayoutConfig& config,
|
||||
int nSource,
|
||||
bool saveToModel);
|
||||
|
||||
private:
|
||||
// 主线布局
|
||||
void layoutMainRoute(DiagramEditorRouteInfo& route,
|
||||
const LayoutConfig& config,
|
||||
bool saveToModel,
|
||||
int nSource);
|
||||
|
||||
// 支线布局
|
||||
void layoutBranchRoute(DiagramEditorRouteInfo& route,
|
||||
const LayoutConfig& config,
|
||||
bool saveToModel,
|
||||
int nSource);
|
||||
|
||||
// 更新元件信息
|
||||
void updateComponentInfo(DiagramEditorComponentInfo& compo,
|
||||
Direction dir,
|
||||
const QPoint& delta,
|
||||
int rotate,
|
||||
bool saveToModel,
|
||||
int nSource);
|
||||
|
||||
// 拆分支线
|
||||
void splitBranchRoute(DiagramEditorRouteInfo& route,
|
||||
bool saveToModel,
|
||||
int nSource);
|
||||
|
||||
// 计算边界
|
||||
QRectF calculateBoundingRect(const QMap<QString, DiagramEditorComponentInfo>& components);
|
||||
|
||||
// 辅助方法
|
||||
QString findMainRoute(const QMap<QString, DiagramEditorRouteInfo>& routes);
|
||||
QStandardItem* getNameItem(const QString& name, int nSource);
|
||||
|
||||
private:
|
||||
QMap<QString, QStandardItem*> m_itemCache;
|
||||
int m_compoWidth = 50; // 可配置
|
||||
int m_compoHeight = 30; // 可配置
|
||||
};
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
#include "common/core_model/diagram.h"
|
||||
|
||||
// direction_manager.h
|
||||
/**********editor方向管理***********/
|
||||
class DirectionManager {
|
||||
public:
|
||||
static bool isHorizontal(Direction dir) {
|
||||
return dir == Direction::Right || dir == Direction::Left;
|
||||
}
|
||||
|
||||
static bool isVertical(Direction dir) {
|
||||
return dir == Direction::Down || dir == Direction::Up;
|
||||
}
|
||||
|
||||
static Direction getOpposite(Direction dir) {
|
||||
switch (dir) {
|
||||
case Direction::Right: return Direction::Left;
|
||||
case Direction::Left: return Direction::Right;
|
||||
case Direction::Down: return Direction::Up;
|
||||
case Direction::Up: return Direction::Down;
|
||||
default: return dir;
|
||||
}
|
||||
}
|
||||
|
||||
static int getRotationAngle(Direction dir) {
|
||||
switch (dir) {
|
||||
case Direction::Right: return -90;
|
||||
case Direction::Left: return 90;
|
||||
case Direction::Down: return 0;
|
||||
case Direction::Up: return 180;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static QPoint getIncrement(Direction dir, int hSpacing, int vSpacing) {
|
||||
if (dir == Direction::Right) return QPoint(hSpacing, 0);
|
||||
if (dir == Direction::Left) return QPoint(-hSpacing, 0);
|
||||
if (dir == Direction::Down) return QPoint(0, vSpacing);
|
||||
if (dir == Direction::Up) return QPoint(0, -vSpacing);
|
||||
return QPoint(0, 0);
|
||||
}
|
||||
|
||||
static bool isDirectionOccupied(int usedDirections, Direction dir) {
|
||||
return (usedDirections & static_cast<int>(dir)) != 0;
|
||||
}
|
||||
|
||||
static int markDirectionOccupied(int usedDirections, Direction dir) {
|
||||
return usedDirections | static_cast<int>(dir);
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
#include "common/core_model/diagram.h"
|
||||
|
||||
// layout_config.h
|
||||
/********editor布局配置*******/
|
||||
class LayoutConfig {
|
||||
public:
|
||||
LayoutConfig(int layoutCode = 41) {
|
||||
parseLayoutCode(layoutCode);
|
||||
}
|
||||
|
||||
Direction mainDirection() const { return m_mainDir; }
|
||||
Direction subDirection() const { return m_subDir; }
|
||||
|
||||
int verticalSpacing() const { return m_verticalSpacing; }
|
||||
int horizontalSpacing() const { return m_horizontalSpacing; }
|
||||
|
||||
void setSpacing(int vertical, int horizontal) {
|
||||
m_verticalSpacing = vertical;
|
||||
m_horizontalSpacing = horizontal;
|
||||
}
|
||||
|
||||
private:
|
||||
void parseLayoutCode(int code) {
|
||||
m_mainDir = static_cast<Direction>(code / 10);
|
||||
m_subDir = static_cast<Direction>(code % 10);
|
||||
}
|
||||
|
||||
Direction m_mainDir = Direction::Down;
|
||||
Direction m_subDir = Direction::Right;
|
||||
int m_verticalSpacing = 50; // 默认值
|
||||
int m_horizontalSpacing = 50; // 默认值
|
||||
};
|
||||
|
|
@ -1012,8 +1012,13 @@ void DiagramEditorWizard::onTransModifyClicked()
|
|||
DiagramEditorBaseBlock* pBlock = getBlockByName(Constants::TRANSFORMER_LEVEL,3,sName);
|
||||
if(pBlock){
|
||||
auto pTran = dynamic_cast<DiagramEditorTransformerBlock*>(pBlock);
|
||||
if(pTran)
|
||||
if(pTran){
|
||||
if(_transSettingDlg == nullptr){
|
||||
_transSettingDlg = new DiagramEditorTransSettingDlg(this);
|
||||
_transSettingDlg->setParent(this);
|
||||
}
|
||||
_transSettingDlg->showDlg(pTran);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>521</width>
|
||||
<height>425</height>
|
||||
<width>605</width>
|
||||
<height>580</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>650</width>
|
||||
<height>460</height>
|
||||
<width>605</width>
|
||||
<height>580</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>521</width>
|
||||
<height>425</height>
|
||||
<width>605</width>
|
||||
<height>580</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ public slots:
|
|||
void onOkClicked();
|
||||
void onCancelClicked();
|
||||
void onItemChanged(const QModelIndex& current);
|
||||
void onItemDoubleClicked(const QModelIndex &index);
|
||||
private:
|
||||
Ui::loadPageDlg *ui;
|
||||
QStandardItemModel* m_standardItemModel;
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ void LoadPageDlg::initial()
|
|||
// 展开数据
|
||||
ui->treeView->expandAll();
|
||||
connect(ui->treeView, &QTreeView::activated, this,&LoadPageDlg::onItemChanged);
|
||||
connect(ui->treeView, &QTreeView::doubleClicked, this,&LoadPageDlg::onItemDoubleClicked);
|
||||
}
|
||||
|
||||
void LoadPageDlg::updateList()
|
||||
|
|
@ -84,3 +85,16 @@ void LoadPageDlg::onItemChanged(const QModelIndex& current)
|
|||
_pageName = item->text();
|
||||
}
|
||||
}
|
||||
|
||||
void LoadPageDlg::onItemDoubleClicked(const QModelIndex &index)
|
||||
{
|
||||
QModelIndex selected = ui->treeView->currentIndex();
|
||||
QStandardItem* item = m_standardItemModel->itemFromIndex(selected); // 根据index获取当前item
|
||||
if(item)
|
||||
{
|
||||
_pageName = item->text();
|
||||
QUuid uid = item->data().toUuid();
|
||||
Q_EMIT selectedProject(_pageName,uid);
|
||||
hide();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue