Ejemplo n.º 1
0
/*****************************************************
**
**   MainWindowStatusbar   ---   OnPlanetTimer
**
******************************************************/
void MainWindowStatusbar::OnPlanetTimer( wxTimerEvent& )
{
	wxString t0, t1;
	double mlen, asclen, dummy, nakportion;
	Lang lang;
	Calculator *calculator = CalculatorFactory().getCalculator();
	DataSet d;
	SheetFormatter fmt;

	d.setCurrentDate();
	d.setLocation( *config->defaultLocation );
	asclen = calculator->calcAscendantAya( d.getJD(), d.getLocation()->getLatitude(),
		d.getLocation()->getLongitude(), config->preferVedic );

	calculator->calcPosition( &d, OMOON, mlen, dummy, true, config->preferVedic );

	t0 << fmt.fragment2PlainText( fmt.getObjectName( OASCENDANT, TF_MEDIUM ))
	 << SPACE
	 << fmt.fragment2PlainText( fmt.getPosFormatted( asclen ));
	SetStatusText( t0, 0 );

	t1 << fmt.fragment2PlainText( fmt.getObjectName( OMOON, TF_MEDIUM ))
	 << SPACE
	 << fmt.fragment2PlainText( fmt.getPosFormatted( mlen ));
	if ( config->preferVedic )
	{
		nakportion = (int)(getNakshatraLongitude27( mlen ) * 10000 /NAKSHATRA_LEN );
		nakportion /= 100;

		t1 << SPACE << nakportion << wxT( "%" ) << SPACE
			<< lang.getNakshatra27Name( ::getNakshatra27( mlen ), TF_MEDIUM );
	}
	SetStatusText( t1, 1 );
}
Ejemplo n.º 2
0
void MainForm::BtnSigNDel0_Click(Fl_Widget *w, void *data)
{
	
	try
	{
		Fl_Button *lpbtn = (Fl_Button *)w;
		MainForm *lpwnd = (MainForm *)data;
		string tmp = lpwnd->Output->value();
		if(tmp == "0" && lpbtn->label() == "-")//特殊情况
		{
			lpwnd->Output->value("-");
			return;
		}
		if(lpwnd->mode == 1)//单步模式
		{
			lpwnd->UpWnd->value((tmp + " =").c_str());
			Calculator *calc = new Calculator(tmp + ";");
			double val = calc->calculate();
			stringstream ss;
			ss.precision(10);
			ss<<val;
			ss>>tmp;
			delete calc;
		}
		tmp += lpbtn->label();
		lpwnd->Output->value(tmp.c_str());
	}
Ejemplo n.º 3
0
/*****************************************************
**
**   LagnaVimsottariDasaExpert   ---   getPortion
**
******************************************************/
double LagnaVimsottariDasaExpert::getPortion( Nakshatra &nak )
{
	Calculator *calculator = CalculatorFactory().getCalculator();
	double mlen = horoscope->getVedicLongitude( OASCENDANT );
	nak = (Nakshatra)( mlen / NAKSHATRA_LEN );
	return calculator->calcAscendantPortion( horoscope->getDataSet(), mlen );
}
Ejemplo n.º 4
0
/*****************************************************
**
**   EphemExpert   ---   calcLength
**
******************************************************/
int EphemExpert::calcLength()
{
	int i, p, ret = 0;
	unsigned int i1;
	double dummy;
	Calculator *calculator = CalculatorFactory().getCalculator();

	planetdata.clear();
	for ( i1 = 0; i1 < chartprops->getPlanetList().size(); i1++ )
	{
		p = chartprops->getPlanetList()[i1];
		if ( p == OASCENDANT || p == OMERIDIAN || p > MAX_EPHEM_OBJECTS ) continue;
		EphemPlanetData pdata( p );
		for ( i = 0; i <= nb_days; i++ ) // calc length and retrogression
		{
			//d->setDate( i+1, month, year, -tz );
			d->setDate( jd[i] );
			calculator->calcPositionSpeed( d, p, pdata.len[i], dummy, pdata.speed[i], true, chartprops->isVedic() );
			pdata.retro[i] = ( pdata.speed[i] < 0 );
			pdata.rasi[i] = getRasi( pdata.len[i] );
			pdata.nakshatra[i] = getNakshatra( pdata.len[i], N27 );
		}

		if ( pdata.len[0] == 0 && p != OARIES ) ret++;

		planetdata.push_back( pdata );
	}
	clen = true;
	return ret;
}
Ejemplo n.º 5
0
void NewAccount::showCreditLimitCalculator ()
  {
    Calculator *calculator = new Calculator ( this );
    calculator->setMaximumWidth ( ( int ) ( this->size().width() * 0.9 ) );
    if ( calculator->exec () == QDialog::Accepted )
      creditlimit->setText ( calculator->display->text() );
  }
Ejemplo n.º 6
0
void FormulaDialog::accept()
{
    extern Calculator calculator;
    QString formula = ui.formulaComboBox->currentText();
    if (calculator.setFormula(formula)) {
        QDialog::accept();
        EigenbroetlerWindow *eb = EigenbroetlerWindow::instance();
        QSettings settings(eb->app_owner, eb->app_name);
        settings.setValue(sq_name, ui.squareCheckBox->checkState() ? true : false);
        settings.setValue(dim_name, ui.twoDRadioButton->isChecked());
        settings.setValue(width_name, ui.widthSpinBox->value());
        settings.setValue(height_name, ui.heightSpinBox->value());

        settings.setValue(start_name, ui.firstNSpinBox->value());
        settings.setValue(stop_name, ui.finalNSpinBox->value());
        settings.setValue(incr_name, ui.incrNSpinBox->value());
        settings.setValue(multi_name, ui.multiviewCheckBox->checkState() ? true : false);

        std::map<QString, QString> frms;
        frms[zip(formula)] = formula;
        int item = 0;
        settings.setValue(form_name.arg(item++), formula);
        for (int i = 0; i < num_formulae && i < ui.formulaComboBox->count(); ++i) {
            QString const key = zip(ui.formulaComboBox->itemText(i));
            if (frms.find(key) == frms.end()) {
                frms[key] = ui.formulaComboBox->itemText(i);
                settings.setValue(form_name.arg(item++), ui.formulaComboBox->itemText(i));
            }
        }
    }
}
Ejemplo n.º 7
0
/*****************************************************
**
**   TextHelper   ---   writeAstronomicalData
**
******************************************************/
int TextHelper::writeAstronomicalData()
{
	wxString pname;
	int p, ret = 0;

	Calculator *calculator = CalculatorFactory().getCalculator();
	Formatter *f = Formatter::get();
	Lang lang;

	vector<int> obs1 = chartprops->getPlanetList();
	vector<int> obs;
	for ( unsigned int i = 0; i < obs1.size(); i++ )
	{
		if ( obs1[i] < MAX_EPHEM_OBJECTS ) obs.push_back( obs1[i] );
	}

	if ( show_header ) writer->writeHeader1( _( "Astronomical Positions" ));
	Table table( 4, obs.size() + 1 );
	table.setHeader( 0,  _( "Planet" ));
	table.setHeader( 1,  _( "Longitude" ));
	table.setHeader( 2,  _( "Latitute" ));
	table.setHeader( 3,  _( "Speed (deg/day)" ));
	table.col_line[0] = true;
	table.col_alignment[0] = Align::Right;
	table.col_alignment[1] = Align::Right;

	int line = 1;
	for ( unsigned int i = 0; i < obs.size(); i++ )
	{
		p = obs[i];
		if ( horoscope->getTropicalLength( p ) == 0 ) ret++;
		pname = writer->getObjectName( p, TLARGE);
		table.setEntry( 0, line, pname );
		table.setEntry( 1, line, writer->getPosFormatted( horoscope->getTropicalLength( p ), horoscope->isRetrograde( p ), DEG_PRECISION_MORE ));

		if ( p != OASCENDANT && p != OMERIDIAN )
		{
			table.setEntry( 2, line, f->getLatitudeFormatted( horoscope->getLatitude( p ), DEG_PRECISION_MORE ));
			table.setEntry( 3, line, f->getLenFormatted( horoscope->getSpeed( p ), DEG_PRECISION_MORE ));
		}
		line++;
	}
	writer->writeTable( table );

	Table t2( 2, 5 );
	t2.setHeader( 0,  _( "Name" ));
	t2.setHeader( 1,  _( "Value" ));
	writer->writeHeader2( _( "Ayanamsa" ));
	line = 1;
	for ( int i = 0; i < NB_AYANAMSAS; i++ )
	{
		t2.setEntry( 0, line, lang.getAyanamsaName( i+1 ));
		t2.setEntry( 1, line, f->getDegreesFormatted( calculator->calcAyanamsa( horoscope->getJD(), i+1 ), DEG_PRECISION_MORE ));
		line++;
	}
	t2.setEntry( 0, 4, _( "Custom" ) );
	t2.setEntry( 1, 4, f->getDegreesFormatted( calculator->calcAyanamsa( horoscope->getJD(), 4 ), DEG_PRECISION_MORE ));
	writer->writeTable( t2 );
	return ret;
}
Ejemplo n.º 8
0
TEST(Calculator, switchingOperandsForAdd) {
  Calculator calc;
  calc.firstOperandIs(2);
  calc.secondOperandIs(5);
  calc.secondOperandIs(9);
  ASSERT_TRUE(11 == calc.add());
}
Ejemplo n.º 9
0
/*****************************************************
**
**   LagnaVimsottariDasaExpert   ---   getPortion 
**
******************************************************/
double LagnaVimsottariDasaExpert::getPortion( const Horoscope *h, int &nak )
{
	Calculator *calculator = CalculatorFactory().getCalculator();
	double mlen = h->getVedicLength( OASCENDANT );
	nak = (int)( mlen / NAKSHATRA_LEN );
	return calculator->calcAscendantPortion( h->getDataSet(), mlen );
}
Ejemplo n.º 10
0
TEST(Calculator, switchingOperandsForMultiply) {
  Calculator calc;
  calc.firstOperandIs(2);
  calc.secondOperandIs(5);
  calc.secondOperandIs(9);
  ASSERT_TRUE(18 == calc.multiply());
}
void Graph2D_Container_gui::on_pushButton_options_clicked()
{

    Graph2D_Editor_gui graph2D_edit;    
    graph2D_edit.m_graph2DEditorListPtr = m_graph2DcontainerListPtr;

    QString aux = QString("%1").arg(m_graph2D_OpenGL.getTimeDelta());
    graph2D_edit.setTimeDelta(aux);

    graph2D_edit.exec();

    Calculator calc;
    m_graph2D_OpenGL.setTimeDelta(calc.SolveExpression(graph2D_edit.getTimeDelta()).numberReal());


    //m_graph2D_OpenGL->prepareGraph();
    m_graph2D_OpenGL.prepareGraphs();
    m_graph2D_OpenGL.setBackGroundColor(graph2D_edit.getBackGroundColor());

    if (!m_graph2D_OpenGL.areTimeGraphs())
    {
        m_graph2D_OpenGL.stopTimer2D();
    }

}
Ejemplo n.º 12
0
int main(int argc, char *argv[])
{
	QApplication a(argc, argv);
	Calculator w;
	w.show();
	return a.exec();
}
Ejemplo n.º 13
0
int main()
{
    StackTest* stackTest1 = new StackByHeapTest();
    QTest::qExec(stackTest1);
    delete stackTest1;
    StackTest* stackTest2 = new StackByArrayTest();
    QTest::qExec(stackTest2);
    delete stackTest2;

    Calculator* calc = new Calculator;
    cout << "Enter expression: " << endl;
    string expr;
    char ch = ' ';
    while (ch != '\n')
    {
        expr += ch;
        cin.get(ch);
    }
    cout << endl;
    try
    {
        int value = calc->calc(expr);
        cout << "Value of expression: " << value << endl;
    }
    catch (std::exception* e)
    {
        cout << e->what() << endl;
    }

    delete calc;
    return 0;
}
Ejemplo n.º 14
0
int main()
{
    ArrayStackTest t1;
    PointStackTest t2;
    QTest::qExec(&t1);
    QTest::qExec(&t2);

    cout << "Input sample" << endl;
    char s[100];
    gets(s);

    cout << "What kind of stack u wanna use?" << endl;
    cout << "Type 'p' or 'a' for pointer/array stack." << endl;
    char c;
    cin >> c;

    Calculator *cal = new Calculator();
    cal->init(c == 'p' ? false : true);

    int res = cal->calc(s);

    cout << "Result: " << res;

    return 0;
}
Ejemplo n.º 15
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    Calculator calc;
    calc.show();
    return app.exec();
}
Ejemplo n.º 16
0
/*****************************************************
**
**   GenericNakshatraDasaExpert   ---   getPortion
**
******************************************************/
double GenericNakshatraDasaExpert::getPortion( Nakshatra &nak )
{
	// Generic Calculation based upon the Moon, overwritten by Lagna Vimsottari Dasa
	Calculator *calculator = CalculatorFactory().getCalculator();
	double mlen = horoscope->getVedicLongitude( OMOON );
	nak = (Nakshatra)( mlen / NAKSHATRA_LEN );
	return calculator->calcNakshatraPortion( horoscope->getDataSet(), mlen, false );
}
Ejemplo n.º 17
0
int main(){
	Calculator c;
	int sum = c.add(100,45);
	int diff = c.subtract(80,50);
	int product = c.multiply(2,8);
	cout << "sum = " << sum << "\n" << "diff = " << diff << "\n" << "product = " << product << endl;
	return 0;
}
Ejemplo n.º 18
0
int main() {
    Calculator<double> calc;
    std::string str;
    std::cout << "Enter expression:" << std::endl;
    std::getline(std::cin, str);
    std::cout << calc.parse(str) << std::endl;
    return 0;
}
Ejemplo n.º 19
0
void Dialog::on_btnDiv_clicked()
{
    Calculator calc;
    double a = ui->leA->text().toDouble();
    double b = ui->leB->text().toDouble();
    double result = calc.div(a, b);
    ui->leResult->setText(QString::number(result));
}
Ejemplo n.º 20
0
//-----------------------------------------------------------------------------
// main() serves as the tester for the code samples. This will change between 
// different problem types. Try to keep as much as possible generic.
//-----------------------------------------------------------------------------
int main(int argc, char **argv){
   
    if(argc != 3){
        cout << "Usage incorrect!\n";
        return -1;
    }
    
    string infile (argv[1]);      // First parameter is the input file of test vectors
    ofstream outfile (argv[2]);     // Second parameter is output of the results

    //  JungleUtils jUtils;  
    Jungle::Timer sw; 
    double total_time_elapsed = 0;

    //-------------------------------------------------------------------------
    // Instantiate the class in question, this will be different per problem.
    // This will fail linking with the user's code if the Class naming is wrong.
    //-------------------------------------------------------------------------
    Calculator testCalc;
    int param0;
    int param1;
    int result;

    vector<string> input_strings; 
    Jungle::Utils::ReadLinesFromFile(infile, input_strings);

    // 5 Seconds MAX to complete the test suite
    signal(SIGALRM, alarm_handler);
    alarm(5);

    // For each line in the test vector file
    for(auto line = input_strings.begin(); line != input_strings.end();++line)
    {
        vector<string> tokens;

        // Tokenize each line with a spaces
        Jungle::Utils::TokenizeWithSpace(*line, tokens);

        // Based on the Jungle problem, set up the input parameters
        param0 = Jungle::Utils::GetIntFromString(tokens[0]);
        param1 = Jungle::Utils::GetIntFromString(tokens[1]);

        sw.start();
        // Call the corresponding Jungle class and method in question. 
        result = testCalc.add(param0,param1);
        sw.stop();
        total_time_elapsed += sw.getElapsedTimeInMilliSec();

        // Write the result out as a string
        outfile << result << endl;
    }

    // Write out the final time
    outfile << "TIME " << total_time_elapsed << endl;
    outfile.close();
 
    return 0;
}
Ejemplo n.º 21
0
int main(void)
{
    Calculator cal;
    cout<< "3+5= "<<cal.Add(3,5)<<endl;
    cout<< "3/5= "<<cal.Div(3,5)<<endl;
    cout<< "12-4= "<<cal.Min(12,4)<<endl;
    cout<< "12/4= "<<cal.Div(12,4)<<endl;
    return 0;
}
QVariant AttributeValuePrivate::calculate()
{
    Q_Q(AttributeValue);
    Calculator *calculator = entity->entityType()->calculator();
    if(!calculator)
        return QVariant();

    return calculator->calculate(entity,q);
}
Ejemplo n.º 23
0
	/**************************************************************
	***
	**    MaitreyaTextclient   ---   showEclipses
	***
	***************************************************************/
	void showEclipses( const int &year )
	{
		EclipseExpert ec;
		Calculator *calculator = CalculatorFactory().getCalculator();
		const double ejd = calculator->calc_jd( year, 1, 1, 0 );
		ec.update( ejd, ejd + 365 * 3, 0, 0, chartprops->isVedic() );
		ec.write( sheet, config->viewprefs->ephemTimezone );
		writecount++;
	}
Ejemplo n.º 24
0
void main(const int argc, const char* const * const argv)
{
	Calculator calc;

//	auto result = calc.Calculate("7**10+6**5");
	auto result = calc.Calculate(argv[1]);

	std::cout << result.AsString() << std::endl;
	return;
}
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);


    Calculator calc;
    calc.unitTest();

    return a.exec();
}
Ejemplo n.º 26
0
void TurnOn() {
    if (!calc.lcd.getActive()) {
        calc.Interrupt.setOnInterrupt(false);
        calc.run(CYCLES_PER(7));
        calc.Interrupt.setOnInterrupt(true);
        calc.run(CYCLES_PER(6));
        calc.Interrupt.setOnInterrupt(false);
        calc.run(CYCLES_PER(7));
    }
}
Ejemplo n.º 27
0
QVariant FunctionValuePrivate::calculate(const Entity *key)
{
    Q_Q(FunctionValue);
    Calculator *calculator = entity->entityType()->calculator();

    if(calculator)
        return calculator->calculate(entity,q,key);

    return QVariant();
}
Ejemplo n.º 28
0
QHash<const Entity *, QVariant> FunctionValuePrivate::calculate()
{
    Q_Q(FunctionValue);
    Calculator *calculator = entity->entityType()->calculator();

    if(calculator)
        return calculator->calculate(entity,q);

    return QHash<const Entity *, QVariant>();
}
Ejemplo n.º 29
0
					void Client::main(std::string args[])
					{
						//1:组装命令和接收者
						//创建接收者
						OperationApi *operation = new Operation();
						//创建命令
						AddCommand *addCmd = new AddCommand(5);
						SubstractCommand *substractCmd = new SubstractCommand(3);
						//组装命令和接收者
						addCmd->setOperation(operation);
						substractCmd->setOperation(operation);

						//2:把命令设置到持有者,就是计算器里面
						Calculator *calculator = new Calculator();
						calculator->setAddCmd(addCmd);
						calculator->setSubstractCmd(substractCmd);

						//3:模拟按下按钮,测试一下
						calculator->addPressed();
						puts("一次加法运算后的结果为:"+operation->getResult());
						calculator->substractPressed();
						puts("一次减法运算后的结果为:"+operation->getResult());

						//测试撤消
						calculator->undoPressed();
						puts("撤销一次后的结果为:"+operation->getResult());
						calculator->undoPressed();
						puts("再撤销一次后的结果为:"+operation->getResult());

						//测试恢复
						calculator->redoPressed();
						puts("恢复操作一次后的结果为:"+operation->getResult());
						calculator->redoPressed();
						puts("再恢复操作一次后的结果为:"+operation->getResult());
					}
Ejemplo n.º 30
0
/*****************************************************
**
**   EphemExpert   ---   testIngressEvent
**
******************************************************/
void EphemExpert::testIngressEvent( const int& t1, const int &t2, const int &planet, const int &type, const bool &r )
{
	double tjd, targetlen;
	if ( t1 != t2 )
	{
		Calculator *calculator = CalculatorFactory().getCalculator();
		targetlen = ( r ? t1 : t2 ) * ( type ? 13.3333333333 : 30 );
		tjd = calculator->calcPlanetaryEvent( d, targetlen, planet, chartprops->isVedic() );
		ingressEvents.push_back( IngressEvent( tjd, planet, t2, type ));
	}
}