歼20学生军迷吧 关注:12贴子:654
  • 4回复贴,共1

iLayoutNum:本表格经过拆分检测后,被拆分

只看楼主收藏回复

//iLayoutNum:本表格经过拆分检测后,被拆分为iLayoutNum个。如果iLayoutNum为1,意味本表格没有被拆分。
int iLayoutNum = SplitOutOfRangeLayout(arypLayout, i, g_layInfoMainFrame.GetWidth(), g_layInfoMainFrame.GetHeight());
if (0 == iLayoutNum)
{
for (int j = 0; j < arypLayout.length(); j++)
{
arypLayout[j]->close();
}
return false;
}
//iLayoutNum如果大于1,说明arypLayout[i]表格因为长或高大于图框,被拆分为iLayoutNum个。
for (int j = i; j < i+iLayoutNum; j++)
{
vpKsjLayoutTable.push_back(arypLayout[j]);
vdLayoutWidth.push_back(arypLayout[j]->GetWidth());
if ((float)arypLayout[j]->GetWidth() < g_fMinLayoutWidth)
{
g_fMinLayoutWidth = (float)arypLayout[j]->GetWidth();
}
if ((float)arypLayout[j]->GetHeight() < g_fMinLayoutHeight)
{
g_fMinLayoutHeight = (float)arypLayout[j]->GetHeight();
}
if ((arypLayout[j]->GetWidth() / arypLayout[j]->GetHeight()) > 2.0)
{//本layout宽高比大于2
iOnlyReduceHeightLoopTime = 2;
}
}//for (j)
//提示: for(i)计数可能变化
i += iLayoutNum - 1;


1楼2023-05-28 19:02回复
    D:\MyProjects\BridgeMaster\2019\BMCAD\BMLOAD\BMLOAD.cpp
    CreateToolbars();


    2楼2023-05-30 10:57
    回复
      void CBmDrawDT::MoveTableLayout(CKsjLayout * pLayout, bool bClose)


      3楼2023-05-30 18:40
      回复
        可以考虑使用STL中的std::set容器进行去重,这样可以大大简化代码,并且提高效率,因为std::set底层是通过红黑树实现的,可以在插入元素时自动排列并去除重复元素。优化后的代码如下:
        c++Copy Codefor (int i = 0; i < g_iNumLayCombinationRectGroup; i++){ std::set<std::vector<std::vector<int>>> unique_combinations; // 使用set容器去重 for (int j = 0; j < g_pLayCombinationRectGroup[i].vvviIntegerPartitionCombination.size(); j++) { unique_combinations.insert(g_pLayCombinationRectGroup[i].vvviIntegerPartitionCombination[j]); } // 将去重后的向量赋值回原向量 g_pLayCombinationRectGroup[i].vvviIntegerPartitionCombination.clear(); for (auto it = unique_combinations.begin(); it != unique_combinations.end(); ++it) { g_pLayCombinationRectGroup[i].vvviIntegerPartitionCombination.push_back(*it); }}
        这段代码中,首先遍历第一重向量,然后对第二重向量中的每个组合放入std::set容器中,这里会自动去除重复元素。最后,将去重后的组合集合重新赋值回原向量中。


        4楼2023-06-01 18:20
        回复
          for (int i = 0; i < g_iNumLayCombinationRectGroup; i++){ std::set<std::vector<std::vector<int>>> unique_combinations; // 使用set容器去重 for (int j = 0; j < g_pLayCombinationRectGroup[i].vvviIntegerPartitionCombination.size(); j++) { unique_combinations.insert(g_pLayCombinationRectGroup[i].vvviIntegerPartitionCombination[j]); } // 将去重后的向量赋值回原向量 g_pLayCombinationRectGroup[i].vvviIntegerPartitionCombination.clear(); for (auto it = unique_combinations.begin(); it != unique_combinations.end(); ++it) { g_pLayCombinationRectGroup[i].vvviIntegerPartitionCombination.push_back(*it); }}


          5楼2023-06-01 18:21
          回复