<commit_before>// Begin CVS Header
//   $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/plot/CPlotItem.cpp,v $
//   $Revision: 1.17 $
//   $Name:  $
//   $Author: gauges $
//   $Date: 2007/02/12 20:54:09 $
// End CVS Header

// Copyright (C) 2007 by <NAME>, Virginia Tech Intellectual
// Properties, Inc. and EML Research, gGmbH.
// All rights reserved.

#include "CPlotItem.h"
#include "report/CKeyFactory.h"

const std::string CPlotItem::TypeName[] =
  {
    "Unset",
    "2D Curve",
    "Histogram",

    "2D Plot",
    "SimWiz",
    ""
  };

const char* CPlotItem::XMLType[] =
  {
    "Unset",
    "Curve2D",
    "Histogram1DItem",

    "Plot2D",
    "SimWiz",
    NULL
  };

const std::string CPlotItem::RecordingActivityName[] =
  {
    "",
    "Before",
    "During",
    "",
    "After"
  };

const char* CPlotItem::XMLRecordingActivity[] =
  {
    "NotSet",
    "before",
    "during",
    "before&during",
    "after",
    "before&after",
    "during&after",
    "before&during&after",
    NULL
  };

CPlotItem::Type CPlotItem::TypeNameToEnum(const std::string & typeName) //static
{
  unsigned C_INT32 i = 0;
  while (TypeName[i] != typeName && TypeName[i] != "") i++;

  if (CPlotItem::TypeName[i] != "") return (CPlotItem::Type) i;
  else return CPlotItem::unset;
}

CPlotItem::CPlotItem(const std::string & name,
                     const CCopasiContainer * pParent,
                     const CPlotItem::Type & type):
    CCopasiParameterGroup(TypeName[type], pParent, "PlotItem"),
    mType(unset),
    mActivity(),
    mpXMLActivity(NULL)
{
  //setObjectName(TypeName[mType]); //TODO
  setObjectName(name);
  setType(type); //to create the parameters
}

CPlotItem::CPlotItem(const CPlotItem & src,
                     const CCopasiContainer * pParent):
    CCopasiParameterGroup(src, pParent),
    mType(unset),
    mActivity(),
    mpXMLActivity(NULL),
    channels(src.getChannels())
{
  /*
  std::cout << "Creating new PlotItem from Template: " << this << std::endl;
  for(unsigned int counter=0; counter < src.getChannels().size(); counter++)
  {
     std::cout << "Channel " << counter << ": " << src.getChannels()[counter] << std::endl;
  }
  for(unsigned int counter=0; counter < this->getChannels().size(); counter++)
  {
     std::cout << "New Channel " << counter << ": " << this->getChannels()[counter] << std::endl;
  }
  */
  setType(src.mType);
}

void CPlotItem::setType(CPlotItem::Type type)
{
  if (type == mType) return;
  if (mType != unset) clear();

  mType = type;

  //create parameters
  if (type == curve2d)
    {
      assertParameter("Line type", CCopasiParameter::UINT, (unsigned C_INT32) 0);
    }

  if (type == histoItem1d)
    {
      assertParameter("increment", CCopasiParameter::DOUBLE, (C_FLOAT64) 0.1);
    }

  if (type == curve2d || type == histoItem1d)
    {
      mpXMLActivity =<commit_msg>fixed #834. Default bin size for histogram is now 1.0<commit_after>// Begin CVS Header
//   $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/plot/CPlotItem.cpp,v $
//   $Revision: 1.18 $
//   $Name:  $
//   $Author: ssahle $
//   $Date: 2007/07/10 08:54:07 $
// End CVS Header

// Copyright (C) 2007 by <NAME>, Virginia Tech Intellectual
// Properties, Inc. and EML Research, gGmbH.
// All rights reserved.

#include "CPlotItem.h"
#include "report/CKeyFactory.h"

const std::string CPlotItem::TypeName[] =
  {
    "Unset",
    "2D Curve",
    "Histogram",

    "2D Plot",
    "SimWiz",
    ""
  };

const char* CPlotItem::XMLType[] =
  {
    "Unset",
    "Curve2D",
    "Histogram1DItem",

    "Plot2D",
    "SimWiz",
    NULL
  };

const std::string CPlotItem::RecordingActivityName[] =
  {
    "",
    "Before",
    "During",
    "",
    "After"
  };

const char* CPlotItem::XMLRecordingActivity[] =
  {
    "NotSet",
    "before",
    "during",
    "before&during",
    "after",
    "before&after",
    "during&after",
    "before&during&after",
    NULL
  };

CPlotItem::Type CPlotItem::TypeNameToEnum(const std::string & typeName) //static
{
  unsigned C_INT32 i = 0;
  while (TypeName[i] != typeName && TypeName[i] != "") i++;

  if (CPlotItem::TypeName[i] != "") return (CPlotItem::Type) i;
  else return CPlotItem::unset;
}

CPlotItem::CPlotItem(const std::string & name,
                     const CCopasiContainer * pParent,
                     const CPlotItem::Type & type):
    CCopasiParameterGroup(TypeName[type], pParent, "PlotItem"),
    mType(unset),
    mActivity(),
    mpXMLActivity(NULL)
{
  //setObjectName(TypeName[mType]); //TODO
  setObjectName(name);
  setType(type); //to create the parameters
}

CPlotItem::CPlotItem(const CPlotItem & src,
                     const CCopasiContainer * pParent):
    CCopasiParameterGroup(src, pParent),
    mType(unset),
    mActivity(),
    mpXMLActivity(NULL),
    channels(src.getChannels())
{
  /*
  std::cout << "Creating new PlotItem from Template: " << this << std::endl;
  for(unsigned int counter=0; counter < src.getChannels().size(); counter++)
  {
     std::cout << "Channel " << counter << ": " << src.getChannels()[counter] << std::endl;
  }
  for(unsigned int counter=0; counter < this->getChannels().size(); counter++)
  {
     std::cout << "New Channel " << counter << ": " << this->getChannels()[counter] << std::endl;
  }
  */
  setType(src.mType);
}

void CPlotItem::setType(CPlotItem::Type type)
{
  if (type == mType) return;
  if (mType != unset) clear();

  mType = type;

  //create parameters
  if (type == curve2d)
    {
      assertParameter("Line type", CCopasiParameter::UINT, (unsigned C_INT32) 0);
    }

  if (type == histoItem1d)
    {
      assertParameter("increment", CCopasiParameter::DOUBLE, (C_FLOAT64) 1.0);
    }

  if (type == curve2d || type == histoItem1d)
    {
      mpXMLActivity =
{'fraction_non_alphanumeric': 0.16990628254078444, 'fraction_numerical': 0.015446025685525859, 'mean_word_length': 3.1164285714285715, 'pattern_counts': {'":': 4, '<': 61, '<?xml version=': 0, '>': 9, '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': '630427', 'n_tokens_mistral': 2151, 'n_tokens_neox': 2035, 'n_words': 411}