...
|
...
|
@@ -10,8 +10,8 @@ import ( |
|
|
"strings"
|
|
|
)
|
|
|
|
|
|
const DefaultExpandNum = 10000
|
|
|
const MaxExpandNum = 50000
|
|
|
const DefaultExpandNum = 1000
|
|
|
const MaxExpandNum = 5000
|
|
|
|
|
|
func (ptr *QuerySetService) LoadCalculateSetData(ctx *domain.Context, qs *domain.QuerySet, queryComponents []*domain.QueryComponent) (*domain.DataTable, error) {
|
|
|
var (
|
...
|
...
|
@@ -41,7 +41,7 @@ func (ptr *QuerySetService) LoadCalculateSetData(ctx *domain.Context, qs *domain |
|
|
// 根据数据修改便宜
|
|
|
CellsLocationAdjust(cells)
|
|
|
// 数据布局
|
|
|
res, err = DataLayout(res, dataTables, cells)
|
|
|
res, err = DataLayout(res, cells)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
...
|
...
|
@@ -60,18 +60,6 @@ func CellsLocationAdjust(cells []*domain.LayoutCell) { |
|
|
yMin = cells[0].Y
|
|
|
yMax = cells[0].Y
|
|
|
}
|
|
|
min := func(a, b int) int {
|
|
|
if a > b {
|
|
|
return b
|
|
|
}
|
|
|
return a
|
|
|
}
|
|
|
max := func(a, b int) int {
|
|
|
if a < b {
|
|
|
return b
|
|
|
}
|
|
|
return a
|
|
|
}
|
|
|
for i := 1; i <= len(cells)-1; i++ {
|
|
|
cell := cells[i]
|
|
|
xMin = min(xMin, cell.X)
|
...
|
...
|
@@ -205,7 +193,7 @@ func (ptr *QuerySetService) LoadDataTables(ctx *domain.Context, cells []*domain. |
|
|
return dataTables
|
|
|
}
|
|
|
|
|
|
func DataLayout(res *domain.DataTable, dataTables map[int]*domain.DataTable, cells []*domain.LayoutCell) (*domain.DataTable, error) {
|
|
|
func DataLayout(res *domain.DataTable, cells []*domain.LayoutCell) (*domain.DataTable, error) {
|
|
|
dt := &DataLayoutDataTable{
|
|
|
DataTable: res,
|
|
|
//MapDataTables: dataTables,
|
...
|
...
|
@@ -273,10 +261,19 @@ func (l *Location) UpdateY(y int) { |
|
|
}
|
|
|
}
|
|
|
|
|
|
func (d *DataLayoutDataTable) StartCell() {
|
|
|
|
|
|
func (l *Location) Update(x int, y int, compare func(int, int) int) {
|
|
|
if x != 0 {
|
|
|
l.X = compare(l.X, x)
|
|
|
}
|
|
|
if y != 0 {
|
|
|
l.Y = compare(l.Y, y)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//func (d *DataLayoutDataTable) StartCell() {
|
|
|
//
|
|
|
//}
|
|
|
|
|
|
func (d *DataLayoutDataTable) addByLocation(cell *domain.LayoutCell, blockData []string) {
|
|
|
if d.PointBegin == nil {
|
|
|
d.PointBegin = NewLocation(cell.X, cell.Y)
|
...
|
...
|
@@ -287,18 +284,21 @@ func (d *DataLayoutDataTable) addByLocation(cell *domain.LayoutCell, blockData [ |
|
|
for i := range blockData {
|
|
|
d.DataTable.Data[cell.X][cell.Y+i] = blockData[i]
|
|
|
}
|
|
|
d.PointEnd.UpdateX(cell.X)
|
|
|
d.PointEnd.UpdateY(cell.Y + len(blockData) - 1)
|
|
|
//d.PointEnd.UpdateX(cell.X)
|
|
|
//d.PointEnd.UpdateY(cell.Y + len(blockData) - 1)
|
|
|
d.PointEnd.Update(cell.X, cell.Y+len(blockData)-1, max)
|
|
|
case domain.DirectionDown:
|
|
|
for i := range blockData {
|
|
|
d.DataTable.Data[cell.X+i][cell.Y] = blockData[i]
|
|
|
}
|
|
|
d.PointEnd.UpdateX(cell.X + len(blockData) - 1)
|
|
|
d.PointEnd.UpdateY(cell.Y)
|
|
|
//d.PointEnd.UpdateX(cell.X + len(blockData) - 1)
|
|
|
//d.PointEnd.UpdateY(cell.Y)
|
|
|
d.PointEnd.Update(cell.X+len(blockData)-1, cell.Y, max)
|
|
|
case domain.DirectionNone:
|
|
|
d.DataTable.Data[cell.X][cell.Y] = blockData[0]
|
|
|
d.PointEnd.UpdateX(cell.X)
|
|
|
d.PointEnd.UpdateY(cell.Y)
|
|
|
//d.PointEnd.UpdateX(cell.X)
|
|
|
//d.PointEnd.UpdateY(cell.Y)
|
|
|
d.PointEnd.Update(cell.X, cell.Y, max)
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -411,3 +411,16 @@ func (d *DataLayoutDataTable) CellOutRange(cell *domain.LayoutCell, length int) |
|
|
}
|
|
|
return false
|
|
|
}
|
|
|
|
|
|
func min(a, b int) int {
|
|
|
if a > b {
|
|
|
return b
|
|
|
}
|
|
|
return a
|
|
|
}
|
|
|
func max(a, b int) int {
|
|
|
if a < b {
|
|
|
return b
|
|
|
}
|
|
|
return a
|
|
|
} |
...
|
...
|
|