<commit_before>//
// RemotePhotoTool - remote camera control software
// Copyright (C) 2008-2013 <NAME>
//
//! \file ViewFinderImageWindow.cpp Viewfinder image window
//

// includes
#include "stdafx.h"
#include "ViewFinderImageWindow.hpp"
#include "Viewfinder.hpp"
#include "JpegMemoryReader.hpp"

const double c_dGoldenRatio = 0.618;

ViewFinderImageWindow::ViewFinderImageWindow()
:m_uiResX(0),
 m_uiResY(0),
 m_enLinesMode(linesModeNoLines)
{
}

void ViewFinderImageWindow::EnableUpdate(bool bEnable)
{
   if (bEnable)
   {
      if (m_spViewfinder != nullptr)
         m_spViewfinder->SetAvailImageHandler(
            std::bind(&ViewFinderImageWindow::OnAvailViewfinderImage, this, std::placeholders::_1));
   }
   else
      m_spViewfinder->SetAvailImageHandler();
}

void ViewFinderImageWindow::SetViewfinder(std::shared_ptr<Viewfinder> spViewfinder)
{
   if (spViewfinder == nullptr && m_spViewfinder != nullptr)
   {
      m_spViewfinder->SetAvailImageHandler();
      SetBitmap(NULL);
   }

   m_spViewfinder = spViewfinder;

   EnableUpdate(true);
}

void ViewFinderImageWindow::OnAvailViewfinderImage(const std::vector<BYTE>& vecImage)
{
   if (m_spViewfinder == nullptr)
      return;

   if (vecImage.empty())
      return;

   //{
   //   static DWORD s_dwLastCall = GetTickCount();
   //   DWORD dwNow = GetTickCount();
   //   ATLTRACE(_T("last view finder image was %u ms ago\n"), dwNow - s_dwLastCall);
   //
   //   s_dwLastCall = dwNow;
   //}

   DecodeJpegImage(vecImage);<commit_msg>only enable update when viewfinder is set, not cleared<commit_after>//
// RemotePhotoTool - remote camera control software
// Copyright (C) 2008-2013 <NAME>
//
//! \file ViewFinderImageWindow.cpp Viewfinder image window
//

// includes
#include "stdafx.h"
#include "ViewFinderImageWindow.hpp"
#include "Viewfinder.hpp"
#include "JpegMemoryReader.hpp"

const double c_dGoldenRatio = 0.618;

ViewFinderImageWindow::ViewFinderImageWindow()
:m_uiResX(0),
 m_uiResY(0),
 m_enLinesMode(linesModeNoLines)
{
}

void ViewFinderImageWindow::EnableUpdate(bool bEnable)
{
   if (bEnable)
   {
      if (m_spViewfinder != nullptr)
         m_spViewfinder->SetAvailImageHandler(
            std::bind(&ViewFinderImageWindow::OnAvailViewfinderImage, this, std::placeholders::_1));
   }
   else
      m_spViewfinder->SetAvailImageHandler();
}

void ViewFinderImageWindow::SetViewfinder(std::shared_ptr<Viewfinder> spViewfinder)
{
   if (spViewfinder == nullptr && m_spViewfinder != nullptr)
   {
      m_spViewfinder->SetAvailImageHandler();
      SetBitmap(NULL);
   }

   m_spViewfinder = spViewfinder;

   if (spViewfinder != nullptr)
      EnableUpdate(true);
}

void ViewFinderImageWindow::OnAvailViewfinderImage(const std::vector<BYTE>& vecImage)
{
   if (m_spViewfinder == nullptr)
      return;

   if (vecImage.empty())
      return;

   //{
   //   static DWORD s_dwLastCall = GetTickCount();
   //   DWORD dwNow = GetTickCount();
   //   ATLTRACE(_T("last view finder image was %u ms ago\n"), dwNow - s_dwLastCall);
   //
   //   s_dwLastCall = dwNow;
   //}

   DecodeJpegImage(vecImage);
{'fraction_non_alphanumeric': 0.12516170763260026, 'fraction_numerical': 0.009702457956015523, 'mean_word_length': 3.9488, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7311649', 'n_tokens_mistral': 1061, 'n_tokens_neox': 1040, 'n_words': 190}