void AdvancedCalwidget::radBoxStatusChanged(int State)
{
    if(State==Qt::Checked)
        expression.isRad=false;
    else
        expression.isRad=true;
    QString t=this->resultDisplay->text();
    bool ok;
    double tn=t.toDouble(&ok);
    if(ok)
    {
        switch(expression.isRad)
        {
        case true:
        {
            double t=fmod(tn/180*PAI,2*PAI);
            if(t<0)
                t+=2*PAI;
            formatOutput(formatState,t);
            break;
        }
        case false:
        {
            double t=fmod(tn/PAI*180,360);
            if(t<0)
                t+=360;
            formatOutput(formatState,t);
            break;
        }
        }
    }
}
Exemplo n.º 2
0
static void readBody(HttpConn *conn, MprFile *outFile)
{
    char        buf[BIT_MAX_BUFFER];
    cchar       *result;
    ssize       bytes;

    while (!conn->error && conn->sock && (bytes = httpRead(conn, buf, sizeof(buf))) > 0) {
        if (!app->noout) {
            result = formatOutput(conn, buf, &bytes);
            if (result) {
                mprWriteFile(outFile, result, bytes);
            }
        }
#if FUTURE
        //  This should be pushed into a range filter.
        //  Buffer all output and then parsing can work
        type = httpGetHeader(conn, "Content-Type");
        if (scontains(type, "multipart/byteranges")) {
            if ((boundary = scontains(type, "boundary=")) != 0) {
                boundary += 9;
                if (*boundary) {
                    boundary = sfmt("--%s\r\n", boundary);
                }
            }
        }
#endif
    }
}
void AdvancedCalwidget::doInputMannual()
{
    EqualState=true;
    bool ok;
    QString text=QInputDialog::getText(this,tr("手动输入"),tr("表达式(格式请查看“帮助”)"),
                                       QLineEdit::Normal,tr("例:-1+sin(sqrt(2)+1)"),&ok);
    if(ok&&!text.isEmpty())
    {
    expression.SetExpression(text);
    if(expression.LegalAndCal())
    {
        double tresult=expression.GetResult();
        if(tresult!=tresult||tresult+1==tresult)
            showError();
        else
        {
            memory.input(text,tresult);
            display->setText(text);
            formatOutput(formatState,expression.GetResult());
        }
    }
    else
    {
       showError();
    }
    }
}
Exemplo n.º 4
0
void MSOptionMenu::drawFieldValue(void)
{
  if (frozen()==MSFalse&&owner()->mapped()==MSTrue&&mapped()==MSTrue)
   {
     int sht=fieldValue()->shadowThickness();
     XFillRectangle(display(),window(),backgroundShadowGC(),
		    fieldValue()->x()+sht,fieldValue()->y()+sht,
		    fieldValue()->width()-(sht<<1),fieldValue()->height()-(sht<<1));

     MSString buffer;
     const char *pString=formatOutput(buffer);
     if (pString!=0&&buffer.length()>0)
      {   
	int len=buffer.length();
	if (len>0)
	 {
	   int xx=fieldValue()->x()+fieldValue()->offset();
	   int offset=fieldValue()->highlightThickness()+fieldValue()->shadowThickness();
	   int margin=(fieldValue()->height()-(2*offset+fieldValue()->textHeight()))>>1;
	   int yy=offset+((margin>0)?margin:0)+fieldValue()->textAscent();
	   
	   int vw=fieldValue()->width()-2*fieldValue()->offset()-
	          2*MSOptionMenuDefaultMargin-MSOptionMenuSymbolWidth;
           int tw=fieldValue()->textWidth(pString,len);
           int delta=(vw>tw)?((vw-tw)>>1):0;
	   
	   fieldValue()->foreground(itemForeground(selectedItem()));
	   XDrawString(display(),window(),fieldValue()->textGC(),fieldValue()->textFontStruct(),
		       xx+delta,fieldValue()->y()+yy,pString,len);
	 }
Exemplo n.º 5
0
void CalWidget::EqualClicked()
{
    if(EqualState)
        return;
    QString t=display->text();
    EqualState=true;
    //if(t[0].isNumber()||t[0]=='('||t[0]==' '||t[0]=='-'||t[0]=='.')
   // {
    expression.SetExpression(display->text());
    if(expression.LegalAndCal())
    {
        double tresult=expression.GetResult();
        if(tresult!=tresult||tresult+1==tresult)
            display->setText("表达式错误或数值溢出!");
        else
        {
            memory.input(t,tresult);
            formatOutput(formatState,expression.GetResult());
        }
        //display->setText(QString::number(expression.GetResult(),'e',floatNumber));

    }
    else
    {
        display->setText("表达式错误或数值溢出!");
    }
    //}
    //else
    //{
    //    display->setText("表达式错误或数值溢出!");
    //}
}
Exemplo n.º 6
0
	DataRetrieval :: DataRetrieval(string file, vector<SumPIDCalculation>& pidPart)
	{
		vector<string>  lines = dataExtraction(file);
		//particle = new ArrayList<ParticleInformation>();
		pidParticle = pidPart;
		//System.out.println(pidParticle.size());
		formatOutput(lines);
	}
void AdvancedCalwidget::downClicked()
{
    QString exptemp;
    double restemp;
    memory.down(exptemp,restemp);
    display->setText(exptemp);
    formatOutput(formatState,restemp);
    EqualState=false;
}
void AdvancedCalwidget::formatEditChanged(int val)
{
    floatNumber=val;
    QString t=resultDisplay->text();
    bool ok;
    double tn=t.toDouble(&ok);
    if(ok)
    {
        formatOutput(formatState,tn);
    }
}
Exemplo n.º 9
0
static void readBody(HttpConn *conn, MprFile *outFile)
{
    char        buf[ME_MAX_BUFFER];
    cchar       *result;
    ssize       bytes;

    while (!conn->error && (bytes = httpRead(conn, buf, sizeof(buf))) > 0) {
        if (!app->noout) {
            result = formatOutput(conn, buf, &bytes);
            if (result) {
                mprWriteFile(outFile, result, bytes);
            }
        }
    }
}
Exemplo n.º 10
0
void AdvancedCalwidget::doFormatCheckBoxChanged(int State)
{
    if(State==Qt::Checked)
        formatState=FORMAT_SCIENCE;
    else if(State==Qt::Unchecked)
        formatState=FORMAT_FLOAT;
    else
        formatState=FORMAT_MIXED;
    QString t=resultDisplay->text();
    bool ok;
    double tn=t.toDouble(&ok);
    if(ok)
    {
        formatOutput(formatState,tn);
    }
}