ofRectangle ofxGenericBarGraphView::calculateBarFrame()
{
    float percent = calculatePercent();
    
    ofRectangle frame = getFrame( ofPoint( 0, 0 ) );
    
    float newWidth, newHeight;
    switch( _expand )
    {
        case ofxGenericBarGraphViewExpandHorizontalLeft:
            newWidth = frame.width * percent;
            frame.x += frame.width - newWidth;
            frame.width = newWidth;
            break;
            
        case ofxGenericBarGraphViewExpandHorizontalRight:
            newWidth = frame.width * percent;
            frame.width = newWidth;
            break;
            
        case ofxGenericBarGraphViewExpandVerticalUp:
            newHeight = frame.height * percent;
            frame.y -= frame.height - newHeight;
            frame.height = newHeight;
            break;
            
        case ofxGenericBarGraphViewExpandVerticalDown:
            newHeight = frame.height * percent;
            frame.height = newHeight;
            break;
    }
    return frame;
}
//--------------------------------------------------------------------------------
bool DaemonCommandsHandler::print_stat(const std::vector<std::string>& args) {
  uint32_t height = 0;
  uint32_t maxHeight = m_core.get_current_blockchain_height() - 1;
  if (args.empty()) {
    height = maxHeight;
  } else {
    try {
      height = boost::lexical_cast<uint32_t>(args.front());
    } catch (boost::bad_lexical_cast&) {
      Crypto::Hash block_hash;
      if (!parse_hash256(args.front(), block_hash) || !m_core.getBlockHeight(block_hash, height)) {
        return false;
      }
    }
    if (height > maxHeight) {
      std::cout << "printing for last available block: " << maxHeight << std::endl;
      height = maxHeight;
    }
  }

  uint64_t totalCoinsInNetwork = m_core.coinsEmittedAtHeight(height);
  uint64_t totalCoinsOnDeposits = m_core.depositAmountAtHeight(height);
  uint64_t amountOfActiveCoins = totalCoinsInNetwork - totalCoinsOnDeposits;

  const auto& currency = m_core.currency();
  std::cout << "Block height: " << height << std::endl;
  std::cout << "Block difficulty: " << m_core.difficultyAtHeight(height) << std::endl;
  std::cout << "Total coins in network:  " << currency.formatAmount(totalCoinsInNetwork) << std::endl;
  std::cout << "Total coins on deposits: " << currency.formatAmount(totalCoinsOnDeposits) <<
    " (" << currency.formatAmount(calculatePercent(currency, totalCoinsOnDeposits, totalCoinsInNetwork)) << "%)" << std::endl;
  std::cout << "Amount of active coins:  " << currency.formatAmount(amountOfActiveCoins) <<
    " (" << currency.formatAmount(calculatePercent(currency, amountOfActiveCoins, totalCoinsInNetwork)) << "%)" << std::endl;
  std::cout << "Total interest paid: " << currency.formatAmount(m_core.depositInterestAtHeight(height)) << std::endl;

  return true;
}
Exemple #3
0
void
MainWindow::binarize()
{
//    auto adaptiveMethod = _gaussian->isChecked() ?
//                cv::ADAPTIVE_THRESH_GAUSSIAN_C : cv::ADAPTIVE_THRESH_MEAN_C;

    cv::threshold(_src_gray, _dst, _cSlider->value(), 255, cv::THRESH_BINARY);
//    cv::adaptiveThreshold(_src_gray, _dst, 255,
//                          adaptiveMethod,
//                          cv::THRESH_BINARY,
//                          _blockSize->value(), _cSlider->value());

    deleteTooSmallClusters();

    displayMatrix(_dst);

    calculatePercent();
}