当前位置: 首页>>代码示例>>C++>>正文


C++ DrawPage::getPageHeight方法代码示例

本文整理汇总了C++中techdraw::DrawPage::getPageHeight方法的典型用法代码示例。如果您正苦于以下问题:C++ DrawPage::getPageHeight方法的具体用法?C++ DrawPage::getPageHeight怎么用?C++ DrawPage::getPageHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在techdraw::DrawPage的用法示例。


在下文中一共展示了DrawPage::getPageHeight方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: calculateAutomaticScale

// Function provided by Joe Dowsett, 2014
double DrawProjGroup::calculateAutomaticScale() const
{
    TechDraw::DrawPage *page = getPage();

    if (page == NULL)
      throw Base::Exception("No page is assigned to this feature");

    if(!page->hasValidTemplate())
        throw Base::Exception("Page template isn't valid");

    DrawProjGroupItem *viewPtrs[10];

    arrangeViewPointers(viewPtrs);
    double width, height;
    minimumBbViews(viewPtrs, width, height);

    // C++ Standard says casting bool to int gives 0 or 1
    int numVertSpaces = (viewPtrs[0] || viewPtrs[3] || viewPtrs[7]) +
                        (viewPtrs[2] || viewPtrs[5] || viewPtrs[9]) +
                        (viewPtrs[6] != NULL);
    int numHorizSpaces = (viewPtrs[0] || viewPtrs[1] || viewPtrs[2]) +
                         (viewPtrs[7] || viewPtrs[8] || viewPtrs[9]);

    double availableX = page->getPageWidth() - spacingX.getValue() * (numVertSpaces + 1);
    double availableY = page->getPageHeight() - spacingY.getValue() * (numHorizSpaces + 1);

    double scale_x = availableX / width;
    double scale_y = availableY / height;

    float working_scale = std::min(scale_x, scale_y);

    //which gives the largest scale for which the min_space requirements can be met, but we want a 'sensible' scale, rather than 0.28457239...
    //eg if working_scale = 0.115, then we want to use 0.1, similarly 7.65 -> 5, and 76.5 -> 50

    float exponent = std::floor(std::log10(working_scale));                  //if working_scale = a * 10^b, what is b?
    working_scale *= std::pow(10, -exponent);                                //now find what 'a' is.

    float valid_scales[2][8] = {{1.0, 1.25, 2.0, 2.5, 3.75, 5.0, 7.5, 10.0},   //equate to 1:10, 1:8, 1:5, 1:4, 3:8, 1:2, 3:4, 1:1
                                {1.0, 1.5 , 2.0, 3.0, 4.0 , 5.0, 8.0, 10.0}};  //equate to 1:1, 3:2, 2:1, 3:1, 4:1, 5:1, 8:1, 10:1

    int i = 7;
    while (valid_scales[(exponent >= 0)][i] > working_scale)                 //choose closest value smaller than 'a' from list.
        i -= 1;                                                              //choosing top list if exponent -ve, bottom list for +ve exponent

    //now have the appropriate scale, reapply the *10^b
    return valid_scales[(exponent >= 0)][i] * pow(10, exponent);
}
开发者ID:Suprnovae,项目名称:FreeCAD,代码行数:48,代码来源:DrawProjGroup.cpp

示例2: findParentPage

App::DocumentObjectExecReturn *DrawView::execute(void)
{
    TechDraw::DrawPage *page = findParentPage();
    if(page) {
        if (ScaleType.isValue("Document")) {
            if(std::abs(page->Scale.getValue() - Scale.getValue()) > FLT_EPSILON) {
                Scale.setValue(page->Scale.getValue());
            }
        } else if (ScaleType.isValue("Automatic")) {
            //check fit. if too big, rescale
            if (!checkFit(page)) {
                double newScale = autoScale(page->getPageWidth(),page->getPageHeight());
                if(std::abs(newScale - Scale.getValue()) > FLT_EPSILON) {           //stops onChanged/execute loop
                    Scale.setValue(newScale);
                }
            }
        }
    }
    return App::DocumentObject::execute();
}
开发者ID:davidlni,项目名称:FreeCAD,代码行数:20,代码来源:DrawView.cpp


注:本文中的techdraw::DrawPage::getPageHeight方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。