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


C++ ControlPoint::SetOpacity方法代码示例

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


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

示例1: RestoreControlPoints

void OpacityTransferFunctionWidget::RestoreControlPoints(int number,
                                                         float max,
                                                         float* scalar, 
                                                         float* opacity) {

  // Temporary control point
  ControlPoint tmp;

  // Set number of control points
  _numberOfControlPoints = number;

  // Set maximum scalar value
  _scalarMaximum = max;

  // Clear all control points
  _controlPoint.clear();

  // Set each control point from arrays
  for (int i = 0 ; i < number ; i++) {
    tmp.SetScalar(scalar[i]);
    tmp.SetOpacity(opacity[i]);
    _controlPoint.push_back(tmp);
  }

  // Set focus point
  _focusPoint = -1;

  return;

}
开发者ID:MattHung,项目名称:sage-graphics,代码行数:30,代码来源:OpacityTransferFunctionWidget.cpp

示例2:

OpacityTransferFunctionWidget::OpacityTransferFunctionWidget(int w, int h) {

  // Initialize background color
  _backgroundColor[0] = 0.0;
  _backgroundColor[1] = 0.0;
  _backgroundColor[2] = 0.0;
  _backgroundColor[3] = 0.0;

  // Initialize box bound
  _boxBound[0] = 0.0;
  _boxBound[1] = 0.0;
  _boxBound[2] = 0.0;
  _boxBound[3] = 0.0;

  // Initialize box color
  _boxColor[0] = 1.0;
  _boxColor[1] = 1.0;
  _boxColor[2] = 1.0;
  _boxColor[3] = 1.0;

  // Initialize control point color
  _controlPointColor[0] = 1.0;
  _controlPointColor[1] = 1.0;
  _controlPointColor[2] = 1.0;
  _controlPointColor[3] = 1.0;

  // Initialize control point size
  _controlPointSize = 8;

  // Initialize focus point index
  _focusPoint = -1;

  // Initialize focus point color
  _focusPointColor[0] = 0.0;
  _focusPointColor[1] = 0.0;
  _focusPointColor[2] = 0.0;
  _focusPointColor[3] = 1.0;

  // Initialize frustum
  _frustum[0] = 0.0;
  _frustum[1] = 1.0;
  _frustum[2] = 0.0;
  _frustum[3] = 1.0;
  _frustum[4] = -1.0;
  _frustum[5] = 1.0;

  // Initialize line color
  _lineColor[0] = 1.0;
  _lineColor[1] = 1.0;  
  _lineColor[2] = 1.0;
  _lineColor[3] = 1.0;

  // Initialize number of control points
  _numberOfControlPoints = 0;

  // Initialize opacity range
  _opacityMaximum = 1.0;
  _opacityMinimum = 0.0;

  // Initialize size of window
  _pixelDimensions[0] = w;
  _pixelDimensions[1] = h;

  // Initialize scalar range
  _scalarMaximum = 1.0;
  _scalarMinimum = 0.0;

  // Initialize text color
  _textColor[0] = 1.0;
  _textColor[1] = 1.0;
  _textColor[2] = 1.0;
  _textColor[3] = 1.0;

  // Initialize transfer function
  ControlPoint controlPoint;

  // First control point
  controlPoint.SetScalar(0.0);
  controlPoint.SetOpacity(0.0);
  _controlPoint.push_back(controlPoint);

  // Second control point
  controlPoint.SetScalar(1.0);
  controlPoint.SetOpacity(1.0);
  _controlPoint.push_back(controlPoint);

  // Increment number of control points
  _numberOfControlPoints = 2;

}
开发者ID:MattHung,项目名称:sage-graphics,代码行数:90,代码来源:OpacityTransferFunctionWidget.cpp

示例3: AddControlPoint

bool OpacityTransferFunctionWidget::AddControlPoint(int px, int py) {

  // Box coordinates
  float bx = 0.0;
  float by = 0.0;

  // Control point
  ControlPoint controlPoint;

  // Function coordinates
  float scalar = 0.0;
  float opacity = 0.0;

  // World coordinates
  float wx = 0.0;
  float wy = 0.0;

  // Check that pixel coordinates are within world space
  if (IsPixelInWorld(px, py) == true) {

    // Get corresponding world coordinates
    PixelToWorld(px, py, &wx, &wy);

    // Check that world coordinates are within box space
    if (IsWorldInBox(wx, wy) == true) {

      // Get corresponding box coordinates
      WorldToBox(wx, wy, &bx, &by);

      // Get corresponding function coordinates
      BoxToFunction(bx, by, &scalar, &opacity);

      // Set control point
      controlPoint.SetOpacity(opacity);
      controlPoint.SetScalar(scalar);

      // Add control point
      _controlPoint.push_back(controlPoint);

      // Sort control points
      sort(_controlPoint.begin(), _controlPoint.end());

      // Get index of newly added point
      _focusPoint = GetControlPointIndex(scalar, opacity);

      // Increment number of control points
      _numberOfControlPoints++;

      // Control point added
      return true;

    }

  }

  // Set focus point
  _focusPoint = -1;

  // Did not add control point
  return false;

}
开发者ID:MattHung,项目名称:sage-graphics,代码行数:62,代码来源:OpacityTransferFunctionWidget.cpp


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