void ConfigPanelWidget::posittionChanged()
{
    ScreenPosition sp = ui->comboBox_position->itemData(
                ui->comboBox_position->currentIndex()).value<ScreenPosition>();

    bool updateAlig = (sp.position == IRazorPanel::PositionTop ||
                       sp.position == IRazorPanel::PositionBottom) !=
                      (mPosition   == IRazorPanel::PositionTop ||
                       mPosition   == IRazorPanel::PositionBottom);

    int oldMax = getMaxLength();
    mPosition = sp.position;
    mScreenNum = sp.screen;
    int newMax = getMaxLength();

    if (ui->comboBox_lenghtType->currentIndex() == 1 &&
        oldMax != newMax)
    {
        // Pixels ...............................
        int v = ui->spinBox_length->value() * 1.0 * newMax / oldMax;
        ui->spinBox_length->setMaximum(newMax);
        ui->spinBox_length->setValue(v);
    }

    if (updateAlig)
        fillComboBox_alignment();

    editChanged();
}
Esempio n. 2
0
	void TextField::setText( const std::string &text )
	{
		//truncate string if it is too long
		if(isPassword())
		{
			
			int len = int(unicodeFunctions.length(text));
			int subLen = len;
			if( len > getMaxLength())
			{
				subLen = maxLength;
			}
			passText = "";
			for(int i = 0; i < subLen ; ++i)
			{
				passText += passwordChar;
			}
		

			if(getMaxLength() < len)
			{
				passwordText = unicodeFunctions.subStr(text,0,getMaxLength());
			}
			else
			{
				passwordText = text;
			}

				Widget::setText(passText);
		}
		else
		{
			if(getMaxLength() < (int) unicodeFunctions.length(text))
			{
				Widget::setText(unicodeFunctions.subStr(text,0,getMaxLength()));
			}
			else
			{
				Widget::setText(text);
			}
		}
	
		

		
		if(!selfSetText)
		{
			positionCaret(getTextLength());
			
		}

		setSelection(0,0);
	}
Esempio n. 3
0
void PPForest<L>::printDot(ostream &s) const
{
	size_type i,h;

	s << "digraph forest" << endl << "{" << endl;

	// edges
	for(i=0;i<m_size;i++)
	{
		s << i;
		if(m_noc[i])
		{
			s << " -> {";
			h=i+1;
			for(Uint r=0;r<getMaxLength(i+1);r++)
			{
				s << h << " ";
				h=m_rb[h];
			}
			s << "}";	  	     	    
		}
		s << endl;
	}

	// labels
	s << endl << endl;
	for(i=0;i<m_size;i++)
	{
		s << i << "[label=\"";
		showLabel(s,m_lb[i]);
		s << "\"]" << endl;
	}

	s << "}";
}
Esempio n. 4
0
//
// Check facet among self
//         check common facets
//         check Additional Facet Constraint
//
void AbstractStringValidator::inspectFacet(MemoryManager* const manager)
{

    int thisFacetsDefined = getFacetsDefined();

    if (!thisFacetsDefined)
        return;

    // check 4.3.1.c1 error: length & (maxLength | minLength)
    if ((thisFacetsDefined & DatatypeValidator::FACET_LENGTH) != 0)
    {
        if ((thisFacetsDefined & DatatypeValidator::FACET_MAXLENGTH) != 0)
            ThrowXMLwithMemMgr(InvalidDatatypeFacetException, XMLExcepts::FACET_Len_maxLen, manager);
        else if (((thisFacetsDefined & DatatypeValidator::FACET_MINLENGTH) != 0))
            ThrowXMLwithMemMgr(InvalidDatatypeFacetException, XMLExcepts::FACET_Len_minLen, manager);
    }

    // check 4.3.2.c1 must: minLength <= maxLength
    if ((thisFacetsDefined & (DatatypeValidator::FACET_MINLENGTH
        |DatatypeValidator::FACET_MAXLENGTH)) != 0)
    {
        int thisMinLength = getMinLength();
        int thisMaxLength = getMaxLength();
        if ( thisMinLength > thisMaxLength )
        {
            REPORT_FACET_ERROR(thisMaxLength
                             , thisMinLength
                             , XMLExcepts::FACET_maxLen_minLen
                             , manager)
        }
    }
Esempio n. 5
0
void RNAProfileAlignment::getStructureAlignment(double t,string &s, deque<double> &pairprob) const
{
	WATCH(DBG_GET_PROFILE_STRUCTURE,"Profile_RNA_Alignment_Forest::getStructureAlignment",size());

	s="";
	getStructureAlignmentFromCSF(s,pairprob,t,0,getMaxLength(0));
}
Esempio n. 6
0
	void TextField::addToNextCharacter( int unichar )
	{
		if(getTextLength() + 1 > getMaxLength())
		{
			return;
		}

		char buffer[8];
		for(int i = 0; i < 8; ++i)
		{
			buffer[i] = 0;
		}

		unicodeFunctions.encodeUtf8(buffer,unichar);
		std::string appendStr = buffer;
		
		std::string text;
		if(!isPassword())
			text = getText();
		else
			text = getPassword();

		unicodeFunctions.insert(text,getCaretPosition(),buffer);

		setThisText(text);
		positionCaret(getCaretPosition() + 1);

	}
Esempio n. 7
0
	void TextField::paste()
	{
		if(isReadOnly())
		{
			return;
		}


		std::string pasteResult = Clipboard::paste();

		if(pasteResult.length() == 0 || getTextLength() - getSelectionLength() == getMaxLength())
		{
			return;
		}

		deleteSelection();
		int start = getCaretPosition();
		
		std::string noNewLine;

		for(size_t i = 0; i < pasteResult.size(); ++i)
		{
			if(pasteResult[i] != '\n')
			{
				noNewLine += pasteResult[i];
			}
		}

		int length = int(unicodeFunctions.length(noNewLine));
		int numRemainingChar = getMaxLength() - getTextLength();
		if(numRemainingChar < length)
		{
			noNewLine = unicodeFunctions.subStr(noNewLine,0,numRemainingChar);
			length = numRemainingChar;
		}
		if(length > 0)
		{
			std::string* cText = (std::string*)&getText();
			unicodeFunctions.insert(*cText,start,noNewLine);
			setThisText(*cText);
			positionCaret(caretPosition + length);
		}
	}
Esempio n. 8
0
	void TextField::appendText( const std::string& text, bool atCurrentPosition /*= true*/ )
	{
		if(text.length() == 0 || getTextLength() - getSelectionLength() == getMaxLength())
		{
			return;
		}

		deleteSelection();
		if(!atCurrentPosition)
		{
			positionCaret(getTextLength());
		}
		int start = getCaretPosition();

		std::string noNewLine;

		for(size_t i = 0; i < text.size(); ++i)
		{
			if(text[i] != '\n')
			{
				noNewLine += text[i];
			}
		}

		int length = int(unicodeFunctions.length(noNewLine));
		int numRemainingChar = getMaxLength() - getTextLength();
		if(numRemainingChar < length)
		{
			noNewLine = unicodeFunctions.subStr(noNewLine,0,numRemainingChar);
			length = numRemainingChar;
		}
		if(length > 0)
		{
			std::string* cText = (std::string*)&getText();
			unicodeFunctions.insert(*cText,start,noNewLine);
			setThisText(*cText);
			positionCaret(caretPosition + length);
		}
	}
Esempio n. 9
0
void RNAProfileAlignment::printSeqAli() const
{
	Uint i,l;
	deque<string> seqs;
	string seq,info;

	// get alignment rows
	for(i=0;i<m_numStructures;i++)
	{
	  
		getSeqAli(seq,i,0,getMaxLength(0));
		seqs.push_back(seq);
	}

	l=seq.length();

	// sequence 
	//	if(hasSequence)
	//	{
		// calculate info line
		for(i=0;i<l;i++)
		{
				bool equal=true;
			
				for(Uint r=1;r<m_numStructures;r++)
			{
				if((seqs[r])[i]!=(seqs[r-1])[i])
				{
				equal=false;
				break;
				}
			}

			info += equal ? "*" : " ";		  
		}  

		// print it
		// sequences
		for(i=0;i<l;i+=55)
		{
			for(Uint r=0;r<m_numStructures;r++)
				cout << setw(20) << setfill(' ') << left << m_strNames[r].substr(0,20) << setw(5) << " " << seqs[r].substr(i,55) << endl;

			cout << setw(25) << " " << info.substr(i,55) << endl;
			cout << endl;
		}
		//	}
}
Esempio n. 10
0
void RNAProfileAlignment::printFastaAli(bool noStructure) const
{
	string str,seq;

	// get alignment rows
	for(Uint i=0;i<m_numStructures;i++)
	{
		getStructAli(str,i);	  
		getSeqAli(seq,i,0,getMaxLength(0));

		cout << ">" << m_strNames[i] << endl;
		cout << seq << endl;
		if(!noStructure)
		  cout << str << endl;
	}
Esempio n. 11
0
/** @inherit */
int PowerSamples::assign(buffer_ptr_t buffer, uint16_t size) {
	if (getMaxLength() > size) {
		LOGe(STR_ERR_BUFFER_NOT_LARGE_ENOUGH);
		return 1;
	}

#ifdef PRINT_POWERSAMPLES_VERBOSE
	LOGd(FMT_ASSIGN_BUFFER_LEN, buffer, size);
#endif

	_buffer = (power_samples_t*)buffer;

	_currentBuffer.assign((buffer_ptr_t)&_buffer->_currentSamples, sizeof(_buffer->_currentSamples));
	_voltageBuffer.assign((buffer_ptr_t)&_buffer->_voltageSamples, sizeof(_buffer->_voltageSamples));

	return 0;
}
Esempio n. 12
0
void TextField::setText(const std::string& text)
{
    std::string strText(text);
    if (isMaxLengthEnabled())
    {
        strText = strText.substr(0, getMaxLength());
    }
    const char* content = strText.c_str();
    if (isPasswordEnabled())
    {
        _textFieldRenderer->setPasswordText(content);
        _textFieldRenderer->insertText(content, static_cast<int>(strlen(content)));
    }
    else
    {
        _textFieldRenderer->setString(content);
    }
    textfieldRendererScaleChangedWithSize();
}
Esempio n. 13
0
void ConfigPanelWidget::widthTypeChanged()
{
    int max = getMaxLength();

    if (ui->comboBox_lenghtType->currentIndex() == 0)
    {
        // Percents .............................
        int v = ui->spinBox_length->value() * 100.0 / max;
        ui->spinBox_length->setMaximum(100);
        ui->spinBox_length->setValue(v);
    }
    else
    {
        // Pixels ...............................
        int v =  max / 100.0 * ui->spinBox_length->value();
        ui->spinBox_length->setMaximum(max);
        ui->spinBox_length->setValue(v);
    }
}
Esempio n. 14
0
void RNAProfileAlignment::getSeqAli(string &seq,Uint row, Uint i, Uint j) const
{
	if(i==0 && j==getMaxLength(0))
		seq="";

	if(j==0)
		return;

	// basepair=internal node
	if(isPair(i))
	{
		getSeqAli(seq,row,i+1,noc(i));
		getSeqAli(seq,row,rb(i),j-1);		
	}
	else
	{
		// base=leaf
		seq+=m_lb[i].columnStr[row];
		getSeqAli(seq,row,rb(i),j-1);
	}
}
Esempio n. 15
0
//
// here content is a list of items
//
void ListDatatypeValidator::checkContent(       BaseRefVectorOf<XMLCh>*       tokenVector
                                        , const XMLCh*                  const content
                                        ,       ValidationContext*      const context
                                        ,       bool                          asBase
                                        ,       MemoryManager*          const manager)
{
    DatatypeValidator* bv = getBaseValidator();

    if (bv->getType() == DatatypeValidator::List)
        ((ListDatatypeValidator*)bv)->checkContent(tokenVector, content, context, true, manager);
    else
    {   // the ultimate itemType DTV
        for (unsigned int i = 0; i < tokenVector->size(); i++)
            bv->validate(tokenVector->elementAt(i), context, manager);
    }

    int thisFacetsDefined = getFacetsDefined();

    // we check pattern first
    if ( (thisFacetsDefined & DatatypeValidator::FACET_PATTERN ) != 0 )
    {
        // lazy construction
        if (getRegex() == 0)
        {
            try {
                setRegex(new (fMemoryManager) RegularExpression(getPattern(), SchemaSymbols::fgRegEx_XOption, fMemoryManager));            	
            }
            catch (XMLException &e)
            {
                ThrowXMLwithMemMgr1(InvalidDatatypeValueException, XMLExcepts::RethrowError, e.getMessage(), manager);
            }
        }

        //check every item in the list as a whole
        if (getRegex()->matches(content, manager) == false)
        {
            ThrowXMLwithMemMgr2(InvalidDatatypeValueException
                    , XMLExcepts::VALUE_NotMatch_Pattern
                    , content
                    , getPattern()
                    , manager);
        }

    }

    // if this is a base validator, we only need to check pattern facet
    // all other facet were inherited by the derived type
    if (asBase)
        return;

    unsigned int tokenNumber = tokenVector->size();

    if (((thisFacetsDefined & DatatypeValidator::FACET_MAXLENGTH) != 0) &&
        (tokenNumber > getMaxLength()))
    {
        XMLCh value1[BUF_LEN+1];
        XMLCh value2[BUF_LEN+1];
        XMLString::binToText(tokenNumber, value1, BUF_LEN, 10, manager);
        XMLString::binToText(getMaxLength(), value2, BUF_LEN, 10, manager);

        ThrowXMLwithMemMgr3(InvalidDatatypeValueException
                , XMLExcepts::VALUE_GT_maxLen
                , getContent()
                , value1
                , value2
                , manager);
    }

    if (((thisFacetsDefined & DatatypeValidator::FACET_MINLENGTH) != 0) &&
        (tokenNumber < getMinLength()))
    {
        XMLCh value1[BUF_LEN+1];
        XMLCh value2[BUF_LEN+1];
        XMLString::binToText(tokenNumber, value1, BUF_LEN, 10, manager);
        XMLString::binToText(getMinLength(), value2, BUF_LEN, 10, manager);

        ThrowXMLwithMemMgr3(InvalidDatatypeValueException
                , XMLExcepts::VALUE_LT_minLen
                , getContent()
                , value1
                , value2
                , manager);
    }

    if (((thisFacetsDefined & DatatypeValidator::FACET_LENGTH) != 0) &&
        (tokenNumber != AbstractStringValidator::getLength()))
    {
        XMLCh value1[BUF_LEN+1];
        XMLCh value2[BUF_LEN+1];
        XMLString::binToText(tokenNumber, value1, BUF_LEN, 10, manager);
        XMLString::binToText(AbstractStringValidator::getLength(), value2, BUF_LEN, 10, manager);

        ThrowXMLwithMemMgr3(InvalidDatatypeValueException
                , XMLExcepts::VALUE_NE_Len
                , getContent()
                , value1
                , value2
                , manager);
    }

    if ((thisFacetsDefined & DatatypeValidator::FACET_ENUMERATION) != 0 &&
        (getEnumeration() != 0))
    {
        int i;
        int enumLength = getEnumeration()->size();

        for ( i = 0; i < enumLength; i++)
        {
            //optimization: we do a lexical comparision first
            // this may be faster for string and its derived
            if (XMLString::equals(getEnumeration()->elementAt(i), getContent()))
                break; // a match found

            // do a value space check
            // this is needed for decimal (and probably other types
            // such as datetime related)
            // eg.
            // tokenVector = "1 2 3.0 4" vs enumeration = "1 2 3 4.0"
            //
            if (valueSpaceCheck(tokenVector, getEnumeration()->elementAt(i), manager))
                break;
        }

        if (i == enumLength)
            ThrowXMLwithMemMgr1(InvalidDatatypeValueException, XMLExcepts::VALUE_NotIn_Enumeration, getContent(), manager);

    } // enumeration

}
Esempio n. 16
0
void RNAProfileAlignment::makePairTable(map<Uint,Uint> &pairs, Uint row) const
{
	pair<int,int> *baseIndex;		// left and right base
	RNA_Alphabet c;

	assert(row<m_numStructures);
	baseIndex=new pair<int,int>[m_size];

	// initialize pairs, all gaps
	for(int i=size()-1;i>=0;i--)
	  {
	    baseIndex[i].first=-1;
	    baseIndex[i].second=-1;
	  }

	for(int i=size()-1;i>=0;i--)
	{
	        c=m_lb[i].columnStr[row];

		if(isLeave(i))
		  {
			if(c!=ALPHA_GAP)
			{
			    baseIndex[i].first=i;
			    baseIndex[i].second=i;
			}
		  }
		else
		{
			// internal node
			// leftmost and rightmost base
			bool lmBaseFound=false;
			for(size_type r=0,h=i+1;r<getMaxLength(i+1);r++,h=rb(h))
			{					  
				// leftmost base
				if(!lmBaseFound && baseIndex[h].first != -1)
				{
					baseIndex[i].first=baseIndex[h].first;
					lmBaseFound=true;
				}

				// rightmost base
				if(baseIndex[h].second != -1)
				{
					baseIndex[i].second=baseIndex[h].second;
				}
			}

			// report pairing bases if P node
			if(c==ALPHA_BASEPAIR)
			{
			        assert(baseIndex[i].first != -1);
			        assert(baseIndex[i].second != -1);
				assert(baseIndex[i].first < baseIndex[i].second);

				pairs[baseIndex[i].first]=baseIndex[i].second;
				pairs[baseIndex[i].second]=baseIndex[i].first;
			}
		}
	}

	delete[] baseIndex;       
}