// hmmm... copied from PPlot.cpp
void PZoomInteraction::DoZoomIn (float inX1, float inX2, float inY1, float inY2) {
    if (!CheckRange (inX1, inX2)) {
        return;
    }
    if (!CheckRange (inY1, inY2)) {
        return;
    }
    // also use the following criterium that is used in PPlot::CalculateTickInfo to 
    // avoid strange zoom in / zoom out behaviour
    float theYRange = fabs (inY1 - inY2);
    float theYMax = (inY1 > inY2) ? inY1 : inY2;
    if (fabs (theYRange / theYMax) < PPlot::kRangeVerySmall) {
        return;
    }

    StoreCurrentAxisSetup ();

    if (mZoomHistory.size()==1)
      mOriginalAxis = mZoomHistory.top();

    if (IsZoomRegion () || IsZoomX ()) {
      mPPlot.mXAxisSetup.SetAutoScale (false);
      mPPlot.mXAxisSetup.mMin = pmin (inX1, inX2);
      mPPlot.mXAxisSetup.mMax = pmax (inX1, inX2);
    }
    if (IsZoomRegion () || IsZoomY ()) {
      mPPlot.mYAxisSetup.SetAutoScale (false);
      mPPlot.mYAxisSetup.mMin = pmin (inY1, inY2);
      mPPlot.mYAxisSetup.mMax = pmax (inY1, inY2);
    }

    mLastZoomIn = true;
    return;
}
Example #2
0
int XML4NLP::GetParse(ParseResult & relation, int pid, int sid, int wid) const {
  if (0 != CheckRange(pid, sid, wid)) return -1;
  const char * head = document.paragraphs[pid].sentences[sid].words[wid].wordPtr->Attribute(TAG_PSR_PARENT);
  relation.first  = (head == NULL ? 0 : atoi(head));
  relation.second = document.paragraphs[pid].sentences[sid].words[wid].wordPtr->Attribute(TAG_PSR_RELATE);
  return 0;
}
Example #3
0
int XML4NLP::SetPredArgToWord(int pid,
                              int sid,
                              int wid,
                              const std::vector<std::string> & role,
                              const std::vector< std::pair<int, int> > & range) {
  if (0 != CheckRange(pid, sid, wid)) return -1;

  TiXmlElement *wordPtr = document.paragraphs[pid].sentences[sid].words[wid].wordPtr;

  if (wordPtr->FirstChildElement(TAG_SRL_ARG) != NULL) {
    std::cerr << "\""
              << TAG_SRL_ARG
              << "\" already exists in word "
              << wid
              << " of sentence "
              << sid
              << " of paragraph "
              << pid << std::endl;
    return -1;
  }

  for (int i = 0; i < role.size(); ++ i) {
    TiXmlElement *argPtr = new TiXmlElement(TAG_SRL_ARG);
    argPtr->SetAttribute(TAG_ID, i);
    argPtr->SetAttribute(TAG_SRL_TYPE, role[i].c_str());
    argPtr->SetAttribute(TAG_BEGIN, range[i].first);
    argPtr->SetAttribute(TAG_END, range[i].second);
    wordPtr->LinkEndChild(argPtr);
  }

  return 0;
}
Example #4
0
int XML4NLP::SetSentencesToParagraph(const vector<string> &vecSentence, int paragraphIdx) {
  if (0 != CheckRange(paragraphIdx)) {
    return -1;
  }

  if (!document.paragraphs[paragraphIdx].sentences.empty()) {
    return -1;
  }

  Paragraph & paragraph     = document.paragraphs[paragraphIdx];
  TiXmlElement * paragraphPtr   = paragraph.paragraphPtr;
  vector<Sentence> &sentences   = paragraph.sentences;

  TiXmlText *textPtr = paragraphPtr->FirstChild()->ToText();
  if (textPtr == NULL) {
    return -1;
  } else {
    paragraphPtr->RemoveChild(textPtr);
  }

  for (int i = 0; i < vecSentence.size(); ++i) {
    TiXmlElement *sentencePtr = new TiXmlElement(TAG_SENT);
    sentencePtr->SetAttribute(TAG_ID, static_cast<int>(i));
    sentencePtr->SetAttribute(TAG_CONT, vecSentence[i].c_str());
    paragraphPtr->LinkEndChild(sentencePtr);

    sentences.push_back( Sentence() );
    sentences[sentences.size()-1].sentencePtr = sentencePtr;
  }

  return 0;
}
Example #5
0
const char * XML4NLP::GetParagraph(int pid) const {
  if (0 != CheckRange(pid)) return NULL;
  if (QueryNote(NOTE_SENT)) return NULL;

  TiXmlElement *paraPtr = document.paragraphs[pid].paragraphPtr;
  return paraPtr->GetText();
}
Example #6
0
long ConfigTag::getInt(const std::string &key, long def, long min, long max)
{
	std::string result;
	if(!readString(key, result))
		return def;

	const char* res_cstr = result.c_str();
	char* res_tail = NULL;
	long res = strtol(res_cstr, &res_tail, 0);
	if (res_tail == res_cstr)
		return def;
	switch (toupper(*res_tail))
	{
		case 'K':
			res = res * 1024;
			break;
		case 'M':
			res = res * 1024 * 1024;
			break;
		case 'G':
			res = res * 1024 * 1024 * 1024;
			break;
	}

	CheckRange(key, res, def, min, max);
	return res;
}
Example #7
0
void ProgressBar::SetRange(int nMin, int nMax)
{
	m_nMin = nMin;
	m_nMax = nMax;
	CheckRange();
	RequestRepaint();
}
Example #8
0
int XML4NLP::GetPredArgToWord(int pid,
                              int sid,
                              int wid,
                              std::vector<const char *> & role,
                              std::vector< std::pair<int, int> > & range) const {
  if (0 != CheckRange(pid, sid, wid)) return -1;

  TiXmlElement *wordPtr = document.paragraphs[pid].sentences[sid].words[wid].wordPtr;
  TiXmlElement *argPtr = wordPtr->FirstChildElement(TAG_SRL_ARG);

  if (argPtr == NULL) {
    std::cerr << "\""
              << TAG_SRL_ARG
              << "\" does not exists in word "
              << wid
              << " of sentence "
              << sid
              << " of paragraph "
              << pid << std::endl;
    return -1;
  }

  if (role.size() != range.size()) {
    std::cerr << "role's size() != range.size(), should resize() first." << std::endl;
    return -1;
  }

  if (role.empty()) {
    cerr << "role is empty" << endl;
    return -1;
  }

  int i = 0;

  do {
    const char *cszType = argPtr->Attribute(TAG_SRL_TYPE);
    const char *cszBeg = argPtr->Attribute(TAG_BEGIN);
    const char *cszEnd = argPtr->Attribute(TAG_END);
    role[i] = cszType;
    int uiBeg = static_cast<int>(cszBeg != NULL ? atoi(cszBeg) : 0);
    int uiEnd = static_cast<int>(cszEnd != NULL ? atoi(cszEnd) : 0);
    range[i].first = uiBeg;
    range[i].second = uiEnd;

    argPtr = argPtr->NextSiblingElement(TAG_SRL_ARG);
    ++i;
  } while (argPtr != NULL && i < role.size());

  if ( ! (argPtr == NULL && i == role.size()) ) {
    if (argPtr == NULL) {
      cerr << "role.size() is too large" << endl;
    } else {
      cerr << "role.size() is too small" << endl;
    }

    return -1;
  }

  return 0;
}
Example #9
0
CGnomonEngine::CGnomonEngine(CConstRef<CHMMParameters> hmm_params, const CResidueVec& sequence, TSignedSeqRange range)
    : m_data(new SGnomonEngineImplData(hmm_params,sequence,range))
{
    CheckRange();
    Convert(m_data->m_seq,m_data->m_ds);
    
    ResetRange(m_data->m_range);
}
Example #10
0
int BrigadeClass::CheckTactic (int tid)
	{
	Objective	o;

	if (tid < 1)
		return 0;
	if (haveWeaps < 0)
		{
		FalconEntity	*e;
		GridIndex		x,y,dx,dy;

		e = GetTarget();
		if (Engaged() && !e)
			SetEngaged(0);
		if (GetUnitSupply() > 20)
			haveWeaps = 1;
		else
			haveWeaps = 0;
		GetLocation(&x,&y);
		o = GetUnitObjective();
		ourObjOwner = 0;
		if (o && o->GetTeam() == GetTeam())
			ourObjOwner = 1;
		if (o)
			o->GetLocation(&dx,&dy);
		else
			GetUnitDestination(&dx,&dy);
		ourObjDist = FloatToInt32(Distance(x,y,dx,dy));
		}
	if (!CheckUnitType(tid, GetDomain(), GetType()))
		return 0;
	if (!CheckTeam(tid,GetTeam()))
		return 0;
	if (!CheckEngaged(tid,Engaged()))
		return 0;
	if (!CheckCombat(tid,Combat()))
		return 0;
	if (!CheckLosses(tid,Losses()))
		return 0;
	if (!CheckRetreating(tid,Retreating()))
		return 0;
	if (!CheckAction(tid,GetUnitOrders()))
		return 0;
	if (!CheckOwned(tid,ourObjOwner))
		return 0;
	if (TeamInfo[GetTeam()]->GetGroundAction()->actionType != GACTION_OFFENSIVE && !CheckRole(tid,0))
		return 0;
	if (!CheckRange(tid,ourObjDist))
		return 0;
//	if (!CheckDistToFront(tid,ourFrontDist))
//		return 0;
	if (!CheckStatus(tid,Broken()))
		return 0;
//	if (!CheckOdds(tid,odds))
//		return 0;
	return GetTacticPriority(tid);
	}
Example #11
0
int XML4NLP::CountWordInParagraph(int pid) const {
  if ( 0 != CheckRange(pid) ) return -1;
  int nr_words = 0;
  int nr_sents = document.paragraphs[pid].sentences.size();

  for (int i = 0; i < nr_sents; ++ i) {
    nr_words += document.paragraphs[pid].sentences[i].words.size();
  }
  return nr_words;
}
Example #12
0
long ConfigTag::getDuration(const std::string& key, long def, long min, long max)
{
	std::string duration;
	if (!readString(key, duration))
		return def;

	long ret = InspIRCd::Duration(duration);
	CheckRange(key, ret, def, min, max);
	return ret;
}
Example #13
0
std::string Dungeon::GetElement(const int X, const int Y)
{
    std::string MyElement = "";

    if(CheckRange(X,Y))
    {
        MyElement = DDungeon.at(Y).at(X);
    }

    return MyElement;
} // GetElement
Example #14
0
void EditGroup::okData()
{
  RDSqlQuery *q;
  QString sql;

  if(!CheckRange()) {
    return;
  }

  group_group->setDescription(group_description_edit->text());
  group_group->setDefaultTitle(group_title_edit->text());
  group_group->
    setDefaultCartType((RDCart::Type)(group_carttype_box->currentItem()+1));
  group_group->setDefaultLowCart(group_lowcart_box->value());
  group_group->setDefaultHighCart(group_highcart_box->value());
  if(group_lowcart_box->value()==0) {
    group_group->setEnforceCartRange(false);
  }
  else {
    group_group->setEnforceCartRange(group_enforcerange_box->isChecked());
  }
  group_group->
    setExportReport(RDGroup::Traffic,group_traffic_box->isChecked());
  group_group->setExportReport(RDGroup::Music,group_music_box->isChecked());
  if(group_shelflife_box->isChecked()) {
    group_group->setCutShelflife(group_shelflife_spin->value());
  }
  else {
    group_group->setCutShelflife(-1);
  }
  group_group->setEnableNowNext(group_nownext_box->isChecked());
  group_group->setColor(group_color_button->
			palette().color(QPalette::Active,
					QColorGroup::ButtonText));

  //
  // Add New Services
  //
  for(unsigned i=0;i<group_svcs_sel->destCount();i++) {
    sql=QString().sprintf("select SERVICE_NAME from AUDIO_PERMS \
where GROUP_NAME=\"%s\" && SERVICE_NAME=\"%s\"",
			  (const char *)group_group->name(),
			  (const char *)group_svcs_sel->destText(i));
    q=new RDSqlQuery(sql);
    if(q->size()==0) {
      delete q;
      sql=QString().sprintf("insert into AUDIO_PERMS (GROUP_NAME,SERVICE_NAME) \
values (\"%s\",\"%s\")",
			    (const char *)group_group->name(),
			    (const char *)group_svcs_sel->destText(i));
      q=new RDSqlQuery(sql);
    }
    delete q;
  }
Example #15
0
TMSubVec diag(const TSubMat &m, Int diagNum)
{
	CheckRange(diagNum, 1 - m.Rows(), m.Cols(), "(row(Mat)) illegal row index");

	if (diagNum == 0)
		return(TMSubVec(Min(m.rows, m.cols), m.span + 1, m.data));
	else if (diagNum < 0)
		return(TMSubVec(Min(m.rows + diagNum, m.cols), m.span + 1,
			m.data - diagNum * m.span));
	else
		return(TMSubVec(Min(m.cols - diagNum, m.rows), m.span + 1,
			m.data + diagNum));
}
Example #16
0
TMSubVec diag(const TMat &m, Int diagNum)
{
	CheckRange(diagNum, 1 - m.Rows(), m.Cols(), "(row(Mat)) illegal row index");

	if (diagNum == 0)
		return(TMSubVec(Min(m.Rows(), m.Cols()), m.Cols() + 1, m.Ref()));
	else if (diagNum < 0)
		return(TMSubVec(Min(m.Rows() + diagNum, m.Cols()), m.Cols() + 1,
			m.Ref() - diagNum * m.Cols()));
	else
		return(TMSubVec(Min(m.Cols() - diagNum, m.Rows()), m.Cols() + 1,
			m.Ref() + diagNum));
}
Example #17
0
/** An atom pair list consists of 2 values for each entry, a beginning
  * index and ending index. For molecules and residues this is the first
  * and just beyond the last atom; for atoms it is just the atom itself
  * twice.
  */
Image::PairType Image::CreatePairList(Topology const& Parm, Mode modeIn,
                                       std::string const& maskExpression)
{
  PairType atomPairs;
  // Set up mask based on desired imaging mode.
  if ( modeIn == BYMOL || modeIn == BYRES ) {
    CharMask cmask( maskExpression );
    if ( Parm.SetupCharMask( cmask ) ) return atomPairs;
    cmask.MaskInfo();
    if (cmask.None()) return atomPairs;
    // Set up atom range for each entity to be imaged.
    if (modeIn == BYMOL) {
      atomPairs.reserve( Parm.Nmol()*2 );
      for (Topology::mol_iterator mol = Parm.MolStart();
                                  mol != Parm.MolEnd(); ++mol)
        CheckRange( atomPairs, cmask, mol->BeginAtom(), mol->EndAtom());
    } else { // BYRES
      atomPairs.reserve( Parm.Nres()*2 );
      for (Topology::res_iterator residue = Parm.ResStart();
                                  residue != Parm.ResEnd(); ++residue)
        CheckRange( atomPairs, cmask, residue->FirstAtom(), residue->LastAtom() );
    }
  } else { // BYATOM
    AtomMask imask( maskExpression );
    if ( Parm.SetupIntegerMask( imask ) ) return atomPairs;
    imask.MaskInfo();
    if (imask.None()) return atomPairs;
    atomPairs.reserve( Parm.Natom()*2 );
    for (AtomMask::const_iterator atom = imask.begin(); atom != imask.end(); ++atom) {
      atomPairs.push_back(  *atom    );
      atomPairs.push_back( (*atom)+1 );
    }
  }
//  mprintf("\tNumber of %ss to be imaged is %zu based on mask '%s'\n",
//           ModeString[modeIn], atomPairs.size()/2, maskIn.MaskString());
  return atomPairs;
}
Example #18
0
int XML4NLP::GetSentencesFromParagraph(vector<string> &vecSentence,
    int paragraphIdx) const {
  if (0 != CheckRange(paragraphIdx)) return -1;

  if (document.paragraphs[paragraphIdx].sentences.empty()) {
    return -1;
  }

  vecSentence.clear();
  const vector<Sentence> &sentences = document.paragraphs[paragraphIdx].sentences;
  for (int i = 0; i < sentences.size(); ++ i) {
    vecSentence.push_back( sentences[i].sentencePtr->Attribute(TAG_CONT) );
  }
  return 0;
}
Example #19
0
int XML4NLP::GetInfoFromSentence(std::vector<const char *> & info,
                                 int pid,
                                 int sid,
                                 const char *attribute_name) const {
  if (0 != CheckRange(pid, sid)) return -1;

  const vector<Word> & words = document.paragraphs[pid].sentences[sid].words;
  if (words[0].wordPtr->Attribute(attribute_name) == NULL) {
    return -1;
  }

  info.resize(words.size());
  for (int i = 0; i < words.size(); ++ i) {
    info[i] = words[i].wordPtr->Attribute(attribute_name);
  }
  return 0;
}
Example #20
0
int XML4NLP::GetParagraph(int pid, string & str) const {
  if (0 != CheckRange(pid)) { return -1; }

  const Paragraph &paragraph = document.paragraphs[pid];

  if (paragraph.sentences.empty()) {
    str = paragraph.paragraphPtr->GetText() ;
  } else {
    str = "";
    const vector<Sentence> &sentences = paragraph.sentences;
    for (int i=0; i<sentences.size(); ++i) {
      str += sentences[i].sentencePtr->Attribute(TAG_CONT);
    }
  }

  return 0;
}
Example #21
0
int XML4NLP::GetSentencesFromParagraph(vector<const char *> &vecSentence,
    int paragraphIdx) const {
  if (0 != CheckRange(paragraphIdx)) return -1;
  if (document.paragraphs[paragraphIdx].sentences.empty()) {
    return -1;
  }

  const vector<Sentence> & sentences = document.paragraphs[paragraphIdx].sentences;
  if (vecSentence.size() != sentences.size()) {
    return -1;
  }

  for (int i=0; i < sentences.size(); ++i) {
    vecSentence[i] = sentences[i].sentencePtr->Attribute(TAG_CONT);
  }

  return 0;
}
Example #22
0
// ----------------------------------------------------------------for SRL
int XML4NLP::CountPredArgToWord(int pid, int sid, int wid) const {
  if (0 != CheckRange(pid, sid, wid)) return -1;

  TiXmlElement *wordPtr = document.paragraphs[pid].sentences[sid].words[wid].wordPtr;
  TiXmlElement *argPtr = wordPtr->FirstChildElement(TAG_SRL_ARG);

  if (argPtr == NULL) {
    return 0;
  }

  int nr_args = 0;

  do {
    ++ nr_args;
    argPtr = argPtr->NextSiblingElement(TAG_SRL_ARG);
  } while (argPtr != NULL);

  return nr_args;
}
Example #23
0
void CDownloadTransfer::CheckPart(QWORD* nPart, QWORD nPartBlock, QWORD* nRange, QWORD& nRangeBlock, QWORD* nBestRange) const
{
	if ( nPartBlock == nRangeBlock )
	{
		if ( nPart[1] < nRange[1] || ! nRange[1] )
		{
			nRange[0] = nPart[0];
			nRange[1] = nPart[1];
		}
		nRange[2] += nPart[1];
	}
	else
	{
		CheckRange( nRange, nBestRange );
		nRange[2] = nRange[1] = nPart[1];
		nRange[0] = nPart[0];
		nRangeBlock = nPartBlock;
	}
}
Example #24
0
int XML4NLP::GetInfoFromSentence(std::vector<std::string> &info,
                                 int pid,
                                 int sid,
                                 const char* attribute_name) const {
  if (0 != CheckRange(pid, sid)) return -1;

  const vector<Word> & words = document.paragraphs[pid].sentences[sid].words;

  if (words[0].wordPtr->Attribute(attribute_name) == NULL) {
    return -1;
  }

  info.clear();
  for (int i = 0; i < words.size(); ++ i) {
    const char * cszAttrValue = words[i].wordPtr->Attribute(attribute_name);
    info.push_back(cszAttrValue != NULL ? cszAttrValue : "");
  }
  return 0;
}
Example #25
0
int XML4NLP::SetParsesToSentence(const std::vector< std::pair<int, std::string> > & relation,
                                 int pid, int sid) {
  if (0 != CheckRange(pid, sid)) return -1;

  std::vector<Word> & words = document.paragraphs[pid].sentences[sid].words;

  if (words.size() != relation.size()) {
    std::cerr << "word number does not equal to vecInfo's size in paragraph"
              << pid
              << " sentence "
              << sid << std::endl;
    return -1;
  }

  if (words[0].wordPtr->Attribute(TAG_PSR_PARENT) != NULL) {
    std::cerr << "Attribute \""
              << TAG_PSR_PARENT
              << "\" already exists in paragraph"
              << pid
              << " sentence "
              << sid << std::endl;
    return -1;
  }

  if (words[0].wordPtr->Attribute(TAG_PSR_RELATE) != NULL) {
    std::cerr << "Attribute \""
              << TAG_PSR_RELATE
              << "\" already exists in paragraph"
              << pid
              << " sentence "
              << sid << endl;
    return -1;
  }

  for (int i = 0; i < words.size(); ++ i) {
    words[i].wordPtr->SetAttribute(TAG_PSR_PARENT, relation[i].first);
    words[i].wordPtr->SetAttribute(TAG_PSR_RELATE, relation[i].second.c_str());
  }

  return 0;
}
Example #26
0
int XML4NLP::SetWordsToSentence(const std::vector<std::string> & input,
                                int pid,
                                int sid) {
  if (0 != CheckRange(pid, sid)) return -1;

  Sentence &sentence = document.paragraphs[pid].sentences[sid];
  if (!sentence.words.empty()) {
    return -1;
  }

  for (int i = 0; i < input.size(); ++ i) {
    TiXmlElement *wordPtr = new TiXmlElement(TAG_WORD);
    wordPtr->SetAttribute(TAG_ID, i);
    wordPtr->SetAttribute(TAG_CONT, input[i].c_str());
    sentence.sentencePtr->LinkEndChild(wordPtr);

    sentence.words.push_back( Word() );
    sentence.words[sentence.words.size() - 1].wordPtr = wordPtr;
  }
  return 0;
}
Example #27
0
void CGnomonEngine::ResetRange(TSignedSeqRange range)
{
    m_data->m_range = range;
    CheckRange();
 
    // compute the GC content of the sequence
    m_data->m_gccontent = 0;

    TSignedSeqPos middle = (m_data->m_range.GetFrom()+m_data->m_range.GetTo())/2;
    const int GC_RANGE_SIZE = 200000;
    TSignedSeqRange gc_range(middle-GC_RANGE_SIZE/2, middle+GC_RANGE_SIZE/2);
    gc_range &= TSignedSeqRange(0,m_data->m_seq.size()-1);
    gc_range += m_data->m_range;

    for (TSignedSeqPos i = gc_range.GetFrom();i<=gc_range.GetTo(); ++i) {
        EResidue c = m_data->m_ds[ePlus][i];
        if (c == enC  ||  c == enG) {
            ++m_data->m_gccontent;
        }
    }
    m_data->m_gccontent = static_cast<int>
        (m_data->m_gccontent*100.0 / (gc_range.GetLength()) + 0.5);
    m_data->m_gccontent = max(1,m_data->m_gccontent);
    m_data->m_gccontent = min(99,m_data->m_gccontent);


    m_data->GetHMMParameter(m_data->m_donor);
    m_data->GetHMMParameter(m_data->m_acceptor);
    m_data->GetHMMParameter(m_data->m_start);
    m_data->GetHMMParameter(m_data->m_stop);
    m_data->GetHMMParameter(m_data->m_cdr);
    m_data->GetHMMParameter(m_data->m_ncdr);
    m_data->GetHMMParameter(m_data->m_intrg);

    m_data->GetHMMParameter(m_data->m_intron_params);
    m_data->m_intron_params->SetSeqLen( m_data->m_range.GetLength() );
    m_data->GetHMMParameter(m_data->m_intergenic_params);
    m_data->m_intergenic_params->SetSeqLen( m_data->m_range.GetLength() );
    m_data->GetHMMParameter(m_data->m_exon_params);
}
Example #28
0
int XML4NLP::SetInfoToSentence(const std::vector<int> & info,
                               int pid,
                               int sid,
                               const char * attribute_name) {
  if (0 != CheckRange(pid, sid)) return -1;

  std::vector<Word> & words = document.paragraphs[pid].sentences[sid].words;

  if (words.size() != info.size()) {
    return -1;
  }

  if (words[0].wordPtr->Attribute(attribute_name) != NULL) {
    return -1;
  }

  for (int i = 0; i < words.size(); ++ i) {
    // std::cout << attribute_name << " " << info[i] << std::endl;
    words[i].wordPtr->SetAttribute(attribute_name, info[i]);
  }
  return 0;
}
void CR823_TVolDetailQuery::AddItem(record_item arg)
{
    line = m_table_content.InsertItem(currentItem, ID_TABLE_EMPTY);
    CString str;
    int iItem = 0;
    str.Format(_T("%d"),currentItem);
    m_table_content.SetItemText(line, iItem++, str);
    str.Format(_T("%d"),arg.tiny_deficency);
    m_table_content.SetItemText(line, iItem++, str);
    str.Format(_T("%d"),arg.mid_deficency);
    m_table_content.SetItemText(line, iItem++, str);
    str.Format(_T("%d"),arg.huge_deficency);
    m_table_content.SetItemText(line, iItem++, str);
    str.Format(_T("%d"),arg.iron_tramp);
    m_table_content.SetItemText(line, iItem++, str);
    str.Format(_T("%s-%d"),arg.volume, arg.subVolum);
    m_table_content.SetItemText(line, ++iItem, str);
    //m_table_content.SetRowCount(1);
    m_table_content.AddRowCount();
    currentItem++;
    CheckRange(arg);
}
Example #30
0
bool iupPlot::Render(cdCanvas* canvas)
{
  if (!mRedraw)
    return true;

  // Shift the drawing area to the plot viewport
  cdCanvasOrigin(canvas, mViewport.mX, mViewport.mY);

  // There are no additional transformations set in the CD canvas,
  // all transformations are done here.

  cdCanvasClip(canvas, CD_CLIPAREA);

  // Draw the background, axis and grid restricted only by the viewport
  cdCanvasClipArea(canvas, 0, mViewport.mWidth - 1, 0, mViewport.mHeight - 1);

  // draw entire plot viewport
  DrawBackground(canvas);

  if (!mDataSetListCount)
    return true;

  cdCanvasNativeFont(canvas, IupGetAttribute(ih, "FONT"));

  ConfigureAxis();

  if (!CalculateAxisRange())
    return false;

  if (!CheckRange(mAxisX))
    return false;

  if (!CheckRange(mAxisY))
    return false;

  CalculateTitlePos();

  // Must be before calculate margins
  CalculateTickSize(canvas, mAxisX.mTick);
  CalculateTickSize(canvas, mAxisY.mTick);

  CalculateMargins(canvas);

  iupPlotRect theDatasetArea;
  theDatasetArea.mX = mBack.mMargin.mLeft;
  theDatasetArea.mY = mBack.mMargin.mBottom;
  theDatasetArea.mWidth = mViewport.mWidth - mBack.mMargin.mLeft - mBack.mMargin.mRight;
  theDatasetArea.mHeight = mViewport.mHeight - mBack.mMargin.mTop - mBack.mMargin.mBottom;

  if (!CalculateTickSpacing(theDatasetArea, canvas))
    return false;

  if (!CalculateXTransformation(theDatasetArea))
    return false;

  if (!CalculateYTransformation(theDatasetArea))
    return false;

  IFnC pre_cb = (IFnC)IupGetCallback(ih, "PREDRAW_CB");
  if (pre_cb)
    pre_cb(ih, canvas);

  if (mBack.GetImage())
    DrawBackgroundImage(canvas);

  if (!mGrid.DrawX(mAxisX.mTickIter, mAxisX.mTrafo, theDatasetArea, canvas))
    return false;

  if (mGrid.mShowX)
    mGridMinor.DrawX(mAxisX.mTickIter, mAxisX.mTrafo, theDatasetArea, canvas);

  if (!mGrid.DrawY(mAxisY.mTickIter, mAxisY.mTrafo, theDatasetArea, canvas))
    return false;

  if (mGrid.mShowY)
    mGridMinor.DrawY(mAxisY.mTickIter, mAxisY.mTrafo, theDatasetArea, canvas);

  if (!mAxisX.DrawX(theDatasetArea, canvas, mAxisY))
    return false;

  if (!mAxisY.DrawY(theDatasetArea, canvas, mAxisX))
    return false;

  if (mBox.mShow)
    mBox.Draw(theDatasetArea, canvas);

  // draw the datasets, legend, crosshair and selection restricted to the dataset area
  cdCanvasClipArea(canvas, theDatasetArea.mX, theDatasetArea.mX + theDatasetArea.mWidth - 1, theDatasetArea.mY, theDatasetArea.mY + theDatasetArea.mHeight - 1);

  IFniiddi drawsample_cb = (IFniiddi)IupGetCallback(ih, "DRAWSAMPLE_CB");

  for (int ds = 0; ds < mDataSetListCount; ds++) 
  {
    iupPlotDataSet* dataset = mDataSetList[ds];

    if (drawsample_cb)
    {
      iupPlotSampleNotify inNotify = { ih, ds, drawsample_cb };
      dataset->DrawData(mAxisX.mTrafo, mAxisY.mTrafo, canvas, &inNotify);
    }
    else
      dataset->DrawData(mAxisX.mTrafo, mAxisY.mTrafo, canvas, NULL);
  }

  if (mCrossHairH)
    DrawCrossHairH(theDatasetArea, canvas);
  else if (mCrossHairV)
    DrawCrossHairV(theDatasetArea, canvas);

  if (mShowSelectionBand)
  {
    if (mSelectionBand.mX < theDatasetArea.mX) 
    { 
      mSelectionBand.mWidth = mSelectionBand.mX + mSelectionBand.mWidth - theDatasetArea.mX; 
      mSelectionBand.mX = theDatasetArea.mX; 
    }
    if (mSelectionBand.mY < theDatasetArea.mY) 
    {
      mSelectionBand.mHeight = mSelectionBand.mY + mSelectionBand.mHeight - theDatasetArea.mY; 
      mSelectionBand.mY = theDatasetArea.mY;
    }
    if (mSelectionBand.mX + mSelectionBand.mWidth > theDatasetArea.mX + theDatasetArea.mWidth)
      mSelectionBand.mWidth = theDatasetArea.mX + theDatasetArea.mWidth - mSelectionBand.mX;
    if (mSelectionBand.mY + mSelectionBand.mHeight > theDatasetArea.mY + theDatasetArea.mHeight)
      mSelectionBand.mHeight = theDatasetArea.mY + theDatasetArea.mHeight - mSelectionBand.mY;

    mBox.Draw(mSelectionBand, canvas);
  }

  IFnC post_cb = (IFnC)IupGetCallback(ih, "POSTDRAW_CB");
  if (post_cb)
    post_cb(ih, canvas);

  if (!DrawLegend(theDatasetArea, canvas, mLegend.mPos))
    return false;

  // Draw title restricted only by the viewport
  cdCanvasClipArea(canvas, 0, mViewport.mWidth - 1, 0, mViewport.mHeight - 1);

  DrawTitle(canvas);

  if (!IupGetInt(ih, "ACTIVE"))
    DrawInactive(canvas);

  mRedraw = false;
  return true;
}