Example #1
0
void RK4_solve(cube &data_vector,double step_size,int time_steps, int n_planets,vec masses,double G,double epsilon){

    //Define all the different variables used for the method
    mat k1(n_planets,6);
    mat k2(n_planets,6);
    mat k3(n_planets,6);
    mat k4(n_planets,6);
    mat start_data(n_planets,6);
    mat accel(n_planets,3);

    k1.fill(0);
    k2.fill(0);
    k3.fill(0);
    k4.fill(0);
    start_data.fill(0);
    accel.fill(0);

    //Evolve through time
    clock_t start,finish;
    start = clock();
    for(int t=0;t< time_steps-1;t++){

        //Calculate inital acceleration
        accel_calculate(data_vector,masses,n_planets,accel,t,G,epsilon);

        for(int i=0;i< n_planets;i++){
            //Set start data
            for(int j=0;j<6;j++){
                start_data(i,j) = data_vector(i,j,t);

                //Calculate k1 for each dim
                for(int j=0;j<3;j++){
                    k1(i,j)= step_size*data_vector(i,3+j,t);
                    k1(i,3+j)= step_size*accel(i,j);
                }
            }
            //Save temp vel
            for(int j=0;j<6;j++){
                data_vector(i,j,t)= start_data(i,j) +k1(i,j)/2.;
            }
        }

        //end k1 step

        //Calculate new acceleration at this temporary position
        accel_calculate(data_vector,masses,n_planets,accel,t,G,epsilon);
        for(int i=0;i<n_planets;i++){
            //Calculate k2 for each dim
            k2(i,0)= step_size*data_vector(i,3,t);
            k2(i,1)= step_size*data_vector(i,4,t);
            k2(i,2)= step_size*data_vector(i,5,t);
            k2(i,3)= step_size*accel(i,0);
            k2(i,4)= step_size*accel(i,1);
            k2(i,5)= step_size*accel(i,2);

            //Save temp pos & temp vel
            data_vector(i,0,t)= start_data(i,0) +k2(i,0)/2.;
            data_vector(i,1,t)= start_data(i,1) +k2(i,1)/2.;
            data_vector(i,2,t)= start_data(i,2) +k2(i,2)/2.;
            data_vector(i,3,t)= start_data(i,3) +k2(i,3)/2.;
            data_vector(i,4,t)= start_data(i,4) +k2(i,4)/2.;
            data_vector(i,5,t)= start_data(i,5) +k2(i,5)/2.;

        }

        //Calculate new acceleration again
        accel_calculate(data_vector,masses,n_planets,accel,t,G,epsilon);
        for(int i=0;i<n_planets;i++){
            //Calculate k3 for each dim
            k3(i,0)= step_size*data_vector(i,3,t);
            k3(i,1)= step_size*data_vector(i,4,t);
            k3(i,2)= step_size*data_vector(i,5,t);
            k3(i,3)= step_size*accel(i,0);
            k3(i,4)= step_size*accel(i,1);
            k3(i,5)= step_size*accel(i,2);

            //Save temp vel and pos
            data_vector(i,0,t)= start_data(i,0) +k3(i,0);
            data_vector(i,1,t)= start_data(i,1) +k3(i,1);
            data_vector(i,2,t)= start_data(i,2) +k3(i,2);
            data_vector(i,3,t)= start_data(i,3) +k3(i,3);
            data_vector(i,4,t)= start_data(i,4) +k3(i,4);
            data_vector(i,5,t)= start_data(i,5) +k3(i,5);
        }

        //Calculate new acceleration again
        accel_calculate(data_vector,masses,n_planets,accel,t,G,epsilon);
        for(int i=0;i<n_planets;i++){
            //Calculate k4 for each dim
            k4(i,0)= step_size*data_vector(i,3,t);
            k4(i,1)= step_size*data_vector(i,4,t);
            k4(i,2)= step_size*data_vector(i,5,t);
            k4(i,3)= step_size*accel(i,0);
            k4(i,4)= step_size*accel(i,1);
            k4(i,5)= step_size*accel(i,2);

            //Return start position to data_vector
            data_vector(i,0,t)= start_data(i,0);
            data_vector(i,1,t)= start_data(i,1);
            data_vector(i,2,t)= start_data(i,2);
            data_vector(i,3,t)= start_data(i,3);
            data_vector(i,4,t)= start_data(i,4);
            data_vector(i,5,t)= start_data(i,5);
        }


        for(int i=0;i<n_planets;i++){
            //Update new position
            for(int j=0;j<6;j++){
                data_vector(i,j,t+1) = data_vector(i,j,t) + 1/6.*(k1(i,j) + 2.*k2(i,j) + 2.*k3(i,j) + k4(i,j));    }
        }
    }
    finish = clock();
    cout << "Total RK4 time = "<< ((float)(finish-start)/CLOCKS_PER_SEC)<<" sec"  << endl;
    cout << "RK4 time/step = "<< ((float)(finish-start)/CLOCKS_PER_SEC)/time_steps<<" sec"  << endl;
}
Example #2
0
int Newmark::domainChanged()
{
    AnalysisModel *myModel = this->getAnalysisModel();
    LinearSOE *theLinSOE = this->getLinearSOE();
    const Vector &x = theLinSOE->getX();
    int size = x.Size();
    
    
    // create the new Vector objects
    if (Ut == 0 || Ut->Size() != size)  {
        
        // delete the old
        if (Ut != 0)
            delete Ut;
        if (Utdot != 0)
            delete Utdot;
        if (Utdotdot != 0)
            delete Utdotdot;
        if (U != 0)
            delete U;
        if (Udot != 0)
            delete Udot;
        if (Udotdot != 0)
            delete Udotdot;
        
        // create the new
        Ut = new Vector(size);
        Utdot = new Vector(size);
        Utdotdot = new Vector(size);
        U = new Vector(size);
        Udot = new Vector(size);
        Udotdot = new Vector(size);
        
        // check we obtained the new
        if (Ut == 0 || Ut->Size() != size ||
            Utdot == 0 || Utdot->Size() != size ||
            Utdotdot == 0 || Utdotdot->Size() != size ||
            U == 0 || U->Size() != size ||
            Udot == 0 || Udot->Size() != size ||
            Udotdot == 0 || Udotdot->Size() != size)  {
            
            opserr << "Newmark::domainChanged - ran out of memory\n";
            
            // delete the old
            if (Ut != 0)
                delete Ut;
            if (Utdot != 0)
                delete Utdot;
            if (Utdotdot != 0)
                delete Utdotdot;
            if (U != 0)
                delete U;
            if (Udot != 0)
                delete Udot;
            if (Udotdot != 0)
                delete Udotdot;
            
            Ut = 0; Utdot = 0; Utdotdot = 0;
            U = 0; Udot = 0; Udotdot = 0;

            return -1;
        }
    }        
    
    // now go through and populate U, Udot and Udotdot by iterating through
    // the DOF_Groups and getting the last committed velocity and accel
    DOF_GrpIter &theDOFs = myModel->getDOFs();
    DOF_Group *dofPtr;
    while ((dofPtr = theDOFs()) != 0)  {
        const ID &id = dofPtr->getID();
        int idSize = id.Size();
        
        int i;
        const Vector &disp = dofPtr->getCommittedDisp();	
        for (i=0; i < idSize; i++)  {
            int loc = id(i);
            if (loc >= 0)  {
                (*U)(loc) = disp(i);		
            }
        }
        
        const Vector &vel = dofPtr->getCommittedVel();
        for (i=0; i < idSize; i++)  {
            int loc = id(i);
            if (loc >= 0)  {
                (*Udot)(loc) = vel(i);
            }
        }
        
        const Vector &accel = dofPtr->getCommittedAccel();	
        for (i=0; i < idSize; i++)  {
            int loc = id(i);
            if (loc >= 0)  {
                (*Udotdot)(loc) = accel(i);
            }
        }
    }    
    
    return 0;
}
dgFloat32 dgWorldDynamicUpdate::CalculateJointForceJacobi1(const dgJointInfo* const jointInfo, const dgBodyInfo* const bodyArray, dgJacobian* const internalForces, dgJacobianMatrixElement* const matrixRow, dgFloat32 restAcceleration) const
{
	dgVector accNorm(dgVector::m_zero);
	const dgInt32 m0 = jointInfo->m_m0;
	const dgInt32 m1 = jointInfo->m_m1;

	dgVector linearM0(internalForces[m0].m_linear);
	dgVector angularM0(internalForces[m0].m_angular);
	dgVector linearM1(internalForces[m1].m_linear);
	dgVector angularM1(internalForces[m1].m_angular);
	const dgVector scale0(jointInfo->m_scale0);
	const dgVector scale1(jointInfo->m_scale1);

	const dgInt32 index = jointInfo->m_pairStart;
	const dgInt32 rowsCount = jointInfo->m_pairCount;

	dgFloat32 cacheForce[DG_CONSTRAINT_MAX_ROWS + 4];
	cacheForce[0] = dgFloat32(1.0f);
	cacheForce[1] = dgFloat32(1.0f);
	cacheForce[2] = dgFloat32(1.0f);
	cacheForce[3] = dgFloat32(1.0f);
	dgFloat32* const normalForce = &cacheForce[4];

	dgVector maxAccel(1.0e10f);
	dgFloat32 prevError = dgFloat32(1.0e20f);
	dgVector firstPass(dgVector::m_one);
	for (dgInt32 j = 0; (j < 5) && (maxAccel.GetScalar() > restAcceleration) && (prevError - maxAccel.GetScalar()) > dgFloat32(1.0e-2f); j++) {
		prevError = maxAccel.GetScalar();
		maxAccel = dgVector::m_zero;
		for (dgInt32 i = 0; i < rowsCount; i++) {
			dgJacobianMatrixElement* const row = &matrixRow[index + i];

			dgAssert(row->m_Jt.m_jacobianM0.m_linear.m_w == dgFloat32(0.0f));
			dgAssert(row->m_Jt.m_jacobianM0.m_angular.m_w == dgFloat32(0.0f));
			dgAssert(row->m_Jt.m_jacobianM1.m_linear.m_w == dgFloat32(0.0f));
			dgAssert(row->m_Jt.m_jacobianM1.m_angular.m_w == dgFloat32(0.0f));

			dgVector diag(row->m_JMinv.m_jacobianM0.m_linear * linearM0 + row->m_JMinv.m_jacobianM0.m_angular * angularM0 +
						  row->m_JMinv.m_jacobianM1.m_linear * linearM1 + row->m_JMinv.m_jacobianM1.m_angular * angularM1);

			dgVector accel(row->m_coordenateAccel - row->m_force * row->m_diagDamp - (diag.AddHorizontal()).GetScalar());
			dgVector force(row->m_force + row->m_invJMinvJt * accel.GetScalar());

			const dgInt32 frictionIndex = row->m_normalForceIndex;
			dgAssert(((frictionIndex < 0) && (normalForce[frictionIndex] == dgFloat32(1.0f))) || ((frictionIndex >= 0) && (normalForce[frictionIndex] >= dgFloat32(0.0f))));
			const dgFloat32 frictionNormal = normalForce[frictionIndex];
			dgVector lowerFrictionForce(frictionNormal * row->m_lowerBoundFrictionCoefficent);
			dgVector upperFrictionForce(frictionNormal * row->m_upperBoundFrictionCoefficent);

			accel = accel.AndNot((force > upperFrictionForce) | (force < lowerFrictionForce));
			dgVector accelAbs(accel.Abs());
			maxAccel = maxAccel.GetMax(accelAbs);
			accNorm = accNorm.GetMax(accelAbs * firstPass);
			dgAssert(maxAccel.m_x >= dgAbsf(accel.m_x));

			dgFloat32 f = (force.GetMax(lowerFrictionForce).GetMin(upperFrictionForce)).GetScalar();
			dgVector deltaForce(f - row->m_force);

			row->m_force = f;
			normalForce[i] = f;
			dgVector deltaforce0(scale0 * deltaForce);
			dgVector deltaforce1(scale1 * deltaForce);
			linearM0 += row->m_Jt.m_jacobianM0.m_linear * deltaforce0;
			angularM0 += row->m_Jt.m_jacobianM0.m_angular * deltaforce0;
			linearM1 += row->m_Jt.m_jacobianM1.m_linear * deltaforce1;
			angularM1 += row->m_Jt.m_jacobianM1.m_angular * deltaforce1;
		}
		firstPass = dgVector::m_zero;
	}

	for (dgInt32 i = 0; i < rowsCount; i++) {
		dgJacobianMatrixElement* const row = &matrixRow[index + i];
		row->m_maxImpact = dgMax(dgAbsf(row->m_force), row->m_maxImpact);
	}

	return accNorm.GetScalar();
}
StyleDialog::StyleDialog (
    wxWindow *parent,
    wxIcon icon,
    const std::string& bufferParameterUtf8,
    const wxString& fileNameParameter,
    const wxString& ruleSetDirectoryParameter,
    const wxString& filterDirectoryParameter,
    const wxString& ruleSetPresetParameter,
    const wxString& filterPresetParameter,
#if !defined(USE_ENCHANT) && defined(__WXMSW__)
    const wxString& aspellDataPathParameter,
    const wxString& aspellDictPathParameter,
#endif
    int typeParameter,
    bool readOnlyParameter,
    wxPoint position,
    wxSize size )
		: wxDialog (
		    parent,
		    wxID_ANY,
		    wxString ( ( typeParameter == ID_TYPE_STYLE) ? _ ( "Style" ) : _ ( "Spelling" ) ),
		    position,
		    size,
		    wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX ),
		indexForContextMenu ( -1 ),
		bufferUtf8 ( bufferParameterUtf8 ),
#if !defined(USE_ENCHANT) && defined(__WXMSW__)
		aspellDataPath ( aspellDataPathParameter ),
		aspellDictPath ( aspellDictPathParameter ),
#endif
		fileName ( fileNameParameter ),
		ruleSetDirectory ( ruleSetDirectoryParameter ),
		filterDirectory ( filterDirectoryParameter ),
		ruleSetPreset ( ruleSetPresetParameter ),
		filterPreset ( filterPresetParameter ),
		type(typeParameter),
		readOnly ( readOnlyParameter )
{
	SetIcon ( icon );


	// top box
	ruleSetCombo = new wxComboBox (
	    this,
	    ID_STYLE_COMBO_RULESET,
	    _T ( "" ),
	    wxDefaultPosition,
	    wxSize ( 200, -1 )
	);
	
	int width, height;
	ruleSetCombo->GetSize ( &width, &height );
	wxSize buttonSize ( 100, height );

    	filterCombo = new wxComboBox (
		this,
		ID_STYLE_COMBO_FILTER,
		_T ( "" ),
		wxDefaultPosition,
		wxSize ( 200, -1 ) );
	//if (type != ID_TYPE_STYLE) // from v. 1.1.0.7: never show
		filterCombo->Show ( false );

	wxButton *createReportButton = new wxButton (
	    this,
	    ID_STYLE_REPORT,
	    _ ( "&Check" ),
	    wxDefaultPosition,
	    buttonSize,
	    0 );

	wxBoxSizer *comboSizer = new wxBoxSizer ( wxHORIZONTAL );
	comboSizer->Add ( ruleSetCombo, 0, wxRIGHT, 10 );
	comboSizer->Add ( filterCombo, 0, wxRIGHT, 10 );
	comboSizer->Add ( createReportButton, 0, wxRIGHT, 10 );

	// middle box
	wxListCtrl *myTable = new wxListCtrl (
	    this,
	    ID_STYLE_TABLE,
	    wxPoint ( 0, 0 ),
	    wxSize ( -1, -1 ),
	    wxLC_REPORT );
	int widthUnit = 35;
	myTable->InsertColumn ( 0, _ ( "No." ), wxLIST_FORMAT_LEFT, widthUnit * 1 );
	myTable->InsertColumn ( 1, _ ( "Context" ), wxLIST_FORMAT_RIGHT, widthUnit * 3 );
	myTable->InsertColumn ( 2, _ ( "Error" ), wxLIST_FORMAT_CENTER, widthUnit * 3 );
	myTable->InsertColumn ( 3, _ ( "Context" ), wxLIST_FORMAT_LEFT, widthUnit * 3 );
	myTable->InsertColumn ( 4, _ ( "Suggestion" ), wxLIST_FORMAT_LEFT, widthUnit * 3 );
	
	myTable->InsertColumn ( 5, _ ( "Rule" ), wxLIST_FORMAT_LEFT, widthUnit * 3 );
	myTable->InsertColumn ( 6, _ ( "Action" ), wxLIST_FORMAT_LEFT, widthUnit * 3 );
	table = myTable;

	// lower box
	wxButton *editItemsButton =
	    new wxButton (
	    this,
	    ID_STYLE_EDIT,
	    _ ( "&Apply changes" ),
	    wxDefaultPosition,
	    wxSize ( -1, buttonSize.GetHeight() ),
	    0 );
	wxButton *webReportButton =
	    new wxButton (
	    this,
	    ID_STYLE_WEB_REPORT,
	    _ ( "&Printable report" ),
	    wxDefaultPosition,
	    wxSize ( -1, buttonSize.GetHeight() ),
	    0 );
	wxButton *webSummaryButton =
	    new wxButton (
	    this,
	    ID_STYLE_WEB_SUMMARY,
	    _ ( "Pr&intable summary" ),
	    wxDefaultPosition,
	    wxSize ( -1, buttonSize.GetHeight() ),
	    0 );
	wxButton *selectAllButton =
	    new wxButton (
	    this,
	    ID_STYLE_CHANGE_ALL,
	    _ ( "C&hange all" ),
	    wxDefaultPosition,
	    wxSize ( -1, buttonSize.GetHeight() ),
	    0 );
	wxButton *deselectAllButton =
	    new wxButton (
	    this,
	    ID_STYLE_IGNORE_ALL,
	    _ ( "I&gnore all" ),
	    wxDefaultPosition,
	    wxSize ( -1, buttonSize.GetHeight() ),
	    0 );
	wxButton *cancelButton =
	    new wxButton (
	    this,
	    wxID_CANCEL,
	    _ ( "Ca&ncel" ),
	    wxDefaultPosition,
	    wxSize ( -1, buttonSize.GetHeight() ),
	    0 );

	wxBoxSizer *reportButtonSizer = new wxBoxSizer ( wxHORIZONTAL );
	reportButtonSizer->Add ( editItemsButton, 0, wxRIGHT, 10 );
	reportButtonSizer->Add ( webReportButton, 0, wxLEFT | wxRIGHT, 10 );
	reportButtonSizer->Add ( webSummaryButton, 0, wxRIGHT, 10 );
	reportButtonSizer->Add ( selectAllButton, 0, wxLEFT | wxRIGHT, 10 );
	reportButtonSizer->Add ( deselectAllButton, 0, wxRIGHT, 10 );
	reportButtonSizer->Add ( cancelButton, 0, wxLEFT, 10 );

	// status bar
	status = new wxStatusBar ( this, wxID_ANY );

	// overall sizer
	wxBoxSizer *reportTopSizer = new wxBoxSizer ( wxVERTICAL );
	reportTopSizer->Add ( comboSizer, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5 );
	reportTopSizer->Add ( table, 1, wxEXPAND | wxALL, 5 );
	reportTopSizer->Add ( reportButtonSizer, 0, wxALL, 5 );
	reportTopSizer->Add ( status, 0, wxEXPAND | wxALL );
	this->SetSizer ( reportTopSizer );

	createReportButton->SetFocus();

	if ( readOnly )
		filterCombo->Enable ( false );

	// keyboard shortcuts
	wxAcceleratorEntry entries[7];
	entries[0].Set ( wxACCEL_ALT, ( int ) 'C', ID_STYLE_REPORT );
	entries[1].Set ( wxACCEL_ALT, ( int ) 'A', ID_STYLE_EDIT );
	entries[2].Set ( wxACCEL_ALT, ( int ) 'W', ID_STYLE_WEB_REPORT );
	entries[3].Set ( wxACCEL_ALT, ( int ) 'B', ID_STYLE_WEB_SUMMARY );
	entries[4].Set ( wxACCEL_ALT, ( int ) 'H', ID_STYLE_CHANGE_ALL );
	entries[5].Set ( wxACCEL_ALT, ( int ) 'I', ID_STYLE_IGNORE_ALL );
	entries[6].Set ( wxACCEL_ALT, ( int ) 'N', wxID_CANCEL );

	wxAcceleratorTable accel ( 7, entries );
	this->SetAcceleratorTable ( accel );
	
	// update combo lists

	// special case spellcheck
	if (type == ID_TYPE_SPELL)
	{
#ifdef USE_ENCHANT
		EnchantBroker *broker = enchant_broker_init();
		dictdetect adetected(ruleSetCombo);
		enchant_broker_list_dicts(broker, EnchantDictDescribe, &adetected);
		bool anyFound = !adetected.empty();
#else
		AspellConfig *config;
		AspellDictInfoList *dlist;
		AspellDictInfoEnumeration *dels;
		const AspellDictInfo *entry;
		
		config = new_aspell_config();
		
#ifdef __WXMSW__
		aspell_config_replace ( config, "data-dir", aspellDataPath.mb_str() ); //ASPELL_DATA_PATH );
		aspell_config_replace ( config, "dict-dir", aspellDictPath.mb_str() ); //ASPELL_DICT_PATH );
#endif
		dlist = get_aspell_dict_info_list( config );
		
		delete_aspell_config ( config );
		
		dels = aspell_dict_info_list_elements ( dlist );
		
		bool anyFound = false;
		while ( ( entry = aspell_dict_info_enumeration_next ( dels ) ) != 0 )
		{
			anyFound = true;
			std::string stdEntry = entry->name;
			wxString entry = wxString ( stdEntry.c_str(), wxConvUTF8, stdEntry.size() );
			ruleSetCombo->Append ( entry );
		}
#endif
		
		if ( anyFound )
		{
			if ( ruleSetPreset.empty() )
				ruleSetPreset = _ ( "en_US" );
			ruleSetCombo->SetValue ( ruleSetPreset );
		}
		else
		{
			ruleSetCombo->Append ( _ ( "(No dictionaries found)" ) );
			ruleSetCombo->Select ( 0 );
			createReportButton->Enable ( false );
		}
		
		return;
	}

	// all other branches
	if ( wxDirExists ( ruleSetDirectory ) )
	{
		wxString ruleMask, ruleFile;
		ruleMask = ruleSetDirectory + wxFileName::GetPathSeparator() + _T ( "*.xml" );
		ruleFile = wxFindFirstFile ( ruleMask, wxFILE );

		if ( !ruleFile.empty() )
		{
			ruleFile.Replace ( _T ( ".xml" ), _T ( "" ) );
			ruleFile.Replace ( _T ( "_" ), _T ( " " ) );
			ruleSetCombo->Append ( wxFileNameFromPath ( ruleFile ) );
			for ( ;; )
			{
				ruleFile = wxFindNextFile();
				if ( ruleFile.empty() )
					break;
				ruleFile.Replace ( _T ( ".xml" ), _T ( "" ) );
				ruleFile.Replace ( _T ( "_" ), _T ( " " ) );
				ruleSetCombo->Append ( wxFileNameFromPath ( ruleFile ) );
			}
		}
		if ( ruleSetPreset.empty() )
			ruleSetPreset = _ ( "Default" );
		ruleSetCombo->SetValue ( ruleSetPreset );
	}
	else
	{
		ruleSetCombo->Append ( _ ( "(No rule sets found)" ) );
		ruleSetCombo->Select ( 0 );
	}

	if ( wxDirExists ( filterDirectory ) )
	{
		filterCombo->Append ( _ ( "(No filter)" ) );
		wxString filterMask, filterFile;
		filterMask = filterDirectory + wxFileName::GetPathSeparator() + _T ( "*.xml" );

		filterFile = wxFindFirstFile ( filterMask, wxFILE );

		if ( !filterFile.empty() )
		{
			filterFile.Replace ( _T ( ".xml" ), _T ( "" ) );
			filterCombo->Append ( wxFileNameFromPath ( filterFile ) );
			for ( ;; )
			{
				filterFile = wxFindNextFile();
				if ( filterFile.empty() )
					break;
				filterFile.Replace ( _T ( ".xml" ), _T ( "" ) );
				filterCombo->Append ( wxFileNameFromPath ( filterFile ) );
			}
		}
		filterCombo->SetValue ( filterPreset );
	}
	else
	{
		filterCombo->Append ( _ ( "(No filters found)" ) );
		filterCombo->Select ( 0 );
	}
}
Example #5
0
void rocket::gravity() {
	float r = length(pos);
	accel(-pos * (G_PARAM / (r*r*r)));
}
Example #6
0
//******************************************************************************
void SHSensors::handleUpdate()
{
const float fToC = 9.0 / 5.0;
const float fOffset = 32;

    //*** read all data ***
    while ( imu_->IMURead() )
    {
        //*** get IMU data ***
        RTIMU_DATA imuData = imu_->getIMUData();

        //*** pressure / temperature ***
        if ( ((enabled_ & IMU_PRESSURE) || (enabled_ & IMU_TEMP)) && pressure_ )
        {
            pressure_->pressureRead( imuData );

            if ( enabled_ & IMU_PRESSURE )
            {
                //*** pressure in hPa ***
                emit pressure( imuData.pressure, RTMath::convertPressureToHeight(imuData.pressure) );
            }

            if ( enabled_ & IMU_TEMP )
            {
                //*** temp celsius, fahrenheit ***
                emit temperature( imuData.temperature,
                                  imuData.temperature * fToC + fOffset );
            }
        }

        //*** humidity ***
        if ( (enabled_ & IMU_HUMIDITY) && humidity_ )
        {
            humidity_->humidityRead( imuData );

            //*** relative humidity ***
            emit humidity( imuData.humidity );
        }

        //*** gyroscope ***
        if ( enabled_ & IMU_GYRO )
        {
            //*** gyroscope in degrees per second ***
            emit gyro( imuData.gyro.x() * RTMATH_RAD_TO_DEGREE,
                       imuData.gyro.y() * RTMATH_RAD_TO_DEGREE,
                       imuData.gyro.z() * RTMATH_RAD_TO_DEGREE );
        }

        //*** accelerometer ***
        if ( enabled_ & IMU_ACCEL )
        {
            //*** acceleration in g's ***'
            emit accel( imuData.accel.x(), imuData.accel.y(),
                        imuData.accel.z(), imuData.accel.length() );
        }

        //*** compass ***
        if ( enabled_ & IMU_COMPASS )
        {
            //*** compas (magnetometer) in uT ***
            emit compass( imuData.compass.x(), imuData.compass.y(),
                          imuData.compass.z(), imuData.compass.length() );
        }

        //*** always emit fusion data - degrees ***
        float fusionX = imuData.fusionPose.x() * RTMATH_RAD_TO_DEGREE;
        float fusionY = imuData.fusionPose.y() * RTMATH_RAD_TO_DEGREE;
        float fusionZ = imuData.fusionPose.z() * RTMATH_RAD_TO_DEGREE;
        emit fusionPose( fusionX, fusionY, fusionZ );
    }

}
Example #7
0
dlgFindReplace::dlgFindReplace(ctlSQLBox *parent) :
	pgDialog()
{
	sqlbox = parent;

	wxWindowBase::SetFont(settings->GetSystemFont());
	LoadResource(parent, wxT("dlgFindReplace"));
	RestorePosition();

	// Icon
	appearanceFactory->SetIcons(this);

	// Accelerator table
	wxAcceleratorEntry entries[1];
	entries[0].Set(wxACCEL_NORMAL, WXK_F3, wxID_FIND);
	wxAcceleratorTable accel(1, entries);
	SetAcceleratorTable(accel);


	// Load up the defaults
	wxString val;
	bool bVal;

	// Find/Replace values
	settings->Read(wxT("FindReplace/Find"), &val, wxT(""));
	txtFind->SetValue(val);

	settings->Read(wxT("FindReplace/Replace"), &val, wxT(""));
	txtReplace->SetValue(val);

	// Origin
	settings->Read(wxT("FindReplace/Origin"), &val, wxT("c"));
	if (val == wxT("t"))
	{
		rdOriginCursor->SetValue(false);
		rdOriginTop->SetValue(true);
	}
	else
	{
		rdOriginCursor->SetValue(true);
		rdOriginTop->SetValue(false);
	}

	// Origin
	settings->Read(wxT("FindReplace/Direction"), &val, wxT("f"));
	if (val == wxT("b"))
	{
		rdDirectionForward->SetValue(false);
		rdDirectionBackward->SetValue(true);
	}
	else
	{
		rdDirectionForward->SetValue(true);
		rdDirectionBackward->SetValue(false);
	}

	// WholeWord
	settings->Read(wxT("FindReplace/WholeWord"), &bVal, false);
	chkOptionsWholeWord->SetValue(bVal);

	// MatchCase
	settings->Read(wxT("FindReplace/MatchCase"), &bVal, false);
	chkOptionsMatchCase->SetValue(bVal);

	// UseRegexps
	settings->Read(wxT("FindReplace/UseRegexps"), &bVal, false);
	chkOptionsUseRegexps->SetValue(bVal);

	wxCommandEvent ev;
	OnChange(ev);
	ResetTabOrder();
}
Example #8
0
const Vector &
TransformationFE::getC_Force(const Vector &accel, double fact)
{
  this->FE_Element::zeroTangent();    
  this->FE_Element::addCtoTang();    
  const Matrix &theTangent = this->FE_Element::getTangent(0);

  static ID numDOFs(dofData, 1);
  numDOFs.setData(dofData, numGroups);
    
  // DO THE SP STUFF TO THE TANGENT 
  
  // get the transformation matrix from each dof group & number of local dof
  // for original node.
  int numNode = numGroups;
  for (int a = 0; a<numNode; a++) {
    Matrix *theT = theDOFs[a]->getT();
    theTransformations[a] = theT;
    if (theT != 0)
      numDOFs[a] = theT->noRows(); // T^ 
    else
      numDOFs[a] = theDOFs[a]->getNumDOF();
  }
  
  // perform Tt K T -- as T is block diagonal do T(i)^T K(i,j) T(j)
  // where blocks are of size equal to num ele dof at a node
  
  int startRow = 0;
  int noRowsTransformed = 0;
  int noRowsOriginal = 0;
  
  static Matrix localK;
  
  // foreach block row, for each block col do
  for (int i=0; i<numNode; i++) {
    
    int startCol = 0;
    int numDOFi = numDOFs[i];	
    int noColsOriginal = 0;
    
    for (int j=0; j<numNode; j++) {
      
      const Matrix *Ti = theTransformations[i];
      const Matrix *Tj = theTransformations[j];
      int numDOFj = numDOFs[j];	
      localK.setData(localKbuffer, numDOFi, numDOFj);
      
      // copy K(i,j) into localK matrix
      // CHECK SIZE OF BUFFFER	    
      for (int a=0; a<numDOFi; a++)
	for (int b=0; b<numDOFj; b++)
	  localK(a,b) = theTangent(noRowsOriginal+a, noColsOriginal+b);
      
      // now perform the matrix computation T(i)^T localK T(j)
      // note: if T == 0 then the Identity is assumed
      int noColsTransformed = 0;
      static Matrix localTtKT;
      
      if (Ti != 0 && Tj != 0) {
	noRowsTransformed = Ti->noCols();
	noColsTransformed = Tj->noCols();
	// CHECK SIZE OF BUFFFER
	localTtKT.setData(dataBuffer, noRowsTransformed, noColsTransformed);
	//localTtKT = (*Ti) ^ localK * (*Tj);
	localTtKT.addMatrixTripleProduct(0.0, *Ti, localK, *Tj, 1.0);
      } else if (Ti == 0 && Tj != 0) {
	noRowsTransformed = numDOFi;
	noColsTransformed = Tj->noCols();
	// CHECK SIZE OF BUFFFER
	localTtKT.setData(dataBuffer, noRowsTransformed, noColsTransformed);
	// localTtKT = localK * (*Tj);	       
	localTtKT.addMatrixProduct(0.0, localK, *Tj, 1.0);
      } else if (Ti != 0 && Tj == 0) {
	noRowsTransformed = Ti->noCols();
	noColsTransformed = numDOFj;
	// CHECK SIZE OF BUFFFER
	localTtKT.setData(dataBuffer, noRowsTransformed, noColsTransformed);
	//localTtKT = (*Ti) ^ localK;
	localTtKT.addMatrixTransposeProduct(0.0, *Ti, localK, 1.0);
      } else {
	noRowsTransformed = numDOFi;
	noColsTransformed = numDOFj;
	localTtKT.setData(dataBuffer, noRowsTransformed, noColsTransformed);
	localTtKT = localK;
      }
      // now copy into modTangent the T(i)^t K(i,j) T(j) product
      for (int c=0; c<noRowsTransformed; c++) 
	for (int d=0; d<noColsTransformed; d++) 
	  (*modTangent)(startRow+c, startCol+d) = localTtKT(c,d);
      
      startCol += noColsTransformed;
      noColsOriginal += numDOFj;
    }
    
    noRowsOriginal += numDOFi;
    startRow += noRowsTransformed;
  }
  
  // get the components we need out of the vector
  // and place in a temporary vector
  Vector tmp(numTransformedDOF);
  for (int j=0; j<numTransformedDOF; j++) {
    int dof = (*modID)(j);
    if (dof >= 0)
      tmp(j) = accel(dof);
    else
      tmp(j) = 0.0;
  }

  modResidual->addMatrixVector(0.0, *modTangent, tmp, 1.0);

  return *modResidual;
}
const Vector &AC3D8HexWithSensitivity::getResistingForceIncInertia(void) 
{
  // form resisting force
  // this->getResistingForce();
  
  int i;

  // printf("Resting-Force: Element tag is %d!\n", this->getTag());
  // for(i = 0; i < numDOF; i++) {
  //   printf("P(%d) = %g;\n", i+1, P(i));
  // }
  
  //
  // now add dynamic terms
  // P += M * a + C * v
  //
  
  Vector &a = VecA;
  Vector &v = VecV;
  Vector &d = VecD;
  
  a.Zero();
  v.Zero();
  
  this->getMass();
  this->getDamp();
  this->getTangentStiff();
  
  for(i = 0; i < nodes_in_elem; i++) {
    const Vector &accel = theNodes[i]->getTrialAccel();
    const Vector &vel = theNodes[i]->getTrialVel();
    const Vector &disp = theNodes[i]->getTrialDisp();
    
    a(i) = accel(0);
    v(i) = vel(0);
    d(i) = disp(0);
  }
  
  P.Zero();
  
  P.addMatrixVector(1.0, K, d, 1.0);
  
  // printf("Element tag is %d!\n", this->getTag());
  // for(i = 0; i < numDOF; i++) {
  //   printf("P(%d) = %g;\n", i+1, P(i));
  // }
  
  P.addMatrixVector(1.0, M, a, 1.0);
  // P.addMatrixVector(1.0, C, v, 1.0);
  
  // // add the damping forces if rayleigh damping
  // if (alphaM != 0.0 || betaK != 0.0 || betaK0 != 0.0 || betaKc != 0.0)
  //   P += this->getRayleighDampingForces();
  // 
  // } else {
  // 
  //   // add the damping forces if rayleigh damping
  //   if (betaK != 0.0 || betaK0 != 0.0 || betaKc != 0.0) 
  //     P += this->getRayleighDampingForces();
  
  // printf("Element tag is %d!\n", this->getTag());
  // for(i = 0; i < numDOF; i++) {
  //   printf("P(%d) = %g;\n", i+1, P(i));
  // }
 
  return P;
}
MyFrame::MyFrame(wxFrame *frame, const wxString&title, const wxPoint&pos, const wxSize&size)
        : wxFrame(frame, wxID_ANY, title, pos, size)
{
    m_canvas = NULL;
    m_previewModality = wxPreviewFrame_AppModal;

#if wxUSE_STATUSBAR
    // Give us a status line
    CreateStatusBar(2);
    SetStatusText(wxT("Printing demo"));
#endif // wxUSE_STATUSBAR

    // Load icon and bitmap
    SetIcon( wxICON( sample) );

    // Make a menubar
    wxMenu *file_menu = new wxMenu;

    file_menu->Append(wxID_PRINT, wxT("&Print..."),                 wxT("Print"));
    file_menu->Append(WXPRINT_PAGE_SETUP, wxT("Page Set&up..."),    wxT("Page setup"));
#ifdef __WXMAC__
    file_menu->Append(WXPRINT_PAGE_MARGINS, wxT("Page Margins..."), wxT("Page margins"));
#endif
    file_menu->Append(wxID_PREVIEW, wxT("Print Pre&view"),          wxT("Preview"));

    wxMenu * const menuModalKind = new wxMenu;
    menuModalKind->AppendRadioItem(WXPRINT_FRAME_MODAL_APP, "&App modal");
    menuModalKind->AppendRadioItem(WXPRINT_FRAME_MODAL_WIN, "&Window modal");
    menuModalKind->AppendRadioItem(WXPRINT_FRAME_MODAL_NON, "&Not modal");
    file_menu->AppendSubMenu(menuModalKind, "Preview frame &modal kind");
#if wxUSE_ACCEL
    // Accelerators
    wxAcceleratorEntry entries[1];
    entries[0].Set(wxACCEL_CTRL, (int) 'V', wxID_PREVIEW);
    wxAcceleratorTable accel(1, entries);
    SetAcceleratorTable(accel);
#endif

#if defined(__WXMSW__) &&wxTEST_POSTSCRIPT_IN_MSW
    file_menu->AppendSeparator();
    file_menu->Append(WXPRINT_PRINT_PS, wxT("Print PostScript..."),           wxT("Print (PostScript)"));
    file_menu->Append(WXPRINT_PAGE_SETUP_PS, wxT("Page Setup PostScript..."), wxT("Page setup (PostScript)"));
    file_menu->Append(WXPRINT_PREVIEW_PS, wxT("Print Preview PostScript"),    wxT("Preview (PostScript)"));
#endif

    file_menu->AppendSeparator();
    file_menu->Append(WXPRINT_ANGLEUP, wxT("Angle up\tAlt-U"),                wxT("Raise rotated text angle"));
    file_menu->Append(WXPRINT_ANGLEDOWN, wxT("Angle down\tAlt-D"),            wxT("Lower rotated text angle"));
    file_menu->AppendSeparator();
    file_menu->Append(wxID_EXIT, wxT("E&xit"),                                wxT("Exit program"));

    wxMenu *help_menu = new wxMenu;
    help_menu->Append(wxID_ABOUT, wxT("&About"),                              wxT("About this demo"));

    wxMenuBar *menu_bar = new wxMenuBar;

    menu_bar->Append(file_menu, wxT("&File"));
    menu_bar->Append(help_menu, wxT("&Help"));

    // Associate the menu bar with the frame
    SetMenuBar(menu_bar);


    // create the canvas
    // -----------------

    m_canvas = new MyCanvas(this, wxPoint(0, 0), wxSize(100, 100),
                            wxRETAINED|wxHSCROLL|wxVSCROLL);

    // Give it scrollbars: the virtual canvas is 20 * 50 = 1000 pixels in each direction
    m_canvas->SetScrollbars(20, 20, 50, 50);
}
Example #11
0
bool MyApp::OnInit(void)
{
  wxInitAllImageHandlers();

  // Set the font path and working directory
  wxFileName exePath = wxStandardPaths::Get().GetExecutablePath();
#ifdef __WXMAC__
  wxString fontPath = exePath.GetPathWithSep() + wxT("../../../../../lib/fonts");
  wxString cwdPath  = exePath.GetPathWithSep() + wxT("../../..");
#else
  wxString fontPath = exePath.GetPathWithSep() + wxT("../../lib/fonts");
  wxString cwdPath  = exePath.GetPath();
#endif
  wxPdfFontManager::GetFontManager()->AddSearchPath(fontPath);
  wxSetWorkingDirectory(cwdPath);

#if wxCHECK_VERSION(2,9,0)
    m_testFont.Create(10, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
#else
    m_testFont.Create(10, wxSWISS, wxNORMAL, wxNORMAL);
#endif

    g_printData = new wxPrintData;
    // You could set an initial paper size here
//    g_printData->SetPaperId(wxPAPER_LETTER); // for Americans
//    g_printData->SetPaperId(wxPAPER_A4);    // for everyone else    

    g_pageSetupData = new wxPageSetupDialogData;
    // copy over initial paper size from print record
    (*g_pageSetupData) = *g_printData;
    // Set some initial page margins in mm. 
    g_pageSetupData->SetMarginTopLeft(wxPoint(15, 15));
    g_pageSetupData->SetMarginBottomRight(wxPoint(15, 15));

    // Create the main frame window
    frame = new MyFrame((wxFrame *) NULL, _T("wxWidgets Printing Demo"), 
        wxPoint(0, 0), wxSize(400, 400));

#if wxUSE_STATUSBAR
    // Give it a status line
    frame->CreateStatusBar(2);
#endif // wxUSE_STATUSBAR

    // Load icon and bitmap
    frame->SetIcon( wxICON( mondrian) );

    // Make a menubar
    wxMenu *file_menu = new wxMenu;

    file_menu->Append(WXPRINT_PRINT, _T("&Print..."),              _T("Print"));
    file_menu->Append(WXPRINT_PDF, _T("PDF..."),              _T("PDF"));
    file_menu->Append(WXPRINT_PAGE_SETUP, _T("Page Set&up..."),              _T("Page setup"));
#ifdef __WXMAC__
    file_menu->Append(WXPRINT_PAGE_MARGINS, _T("Page Margins..."), _T("Page margins"));
#endif
    file_menu->Append(WXPRINT_PREVIEW, _T("Print Pre&view"),              _T("Preview"));

#if wxUSE_ACCEL
    // Accelerators
    wxAcceleratorEntry entries[1];
    entries[0].Set(wxACCEL_CTRL, (int) 'V', WXPRINT_PREVIEW);
    wxAcceleratorTable accel(1, entries);
    frame->SetAcceleratorTable(accel);
#endif

#if defined(__WXMSW__) && wxTEST_POSTSCRIPT_IN_MSW
    file_menu->AppendSeparator();
    file_menu->Append(WXPRINT_PRINT_PS, _T("Print PostScript..."),              _T("Print (PostScript)"));
    file_menu->Append(WXPRINT_PAGE_SETUP_PS, _T("Page Setup PostScript..."),              _T("Page setup (PostScript)"));
    file_menu->Append(WXPRINT_PREVIEW_PS, _T("Print Preview PostScript"),              _T("Preview (PostScript)"));
#endif

    file_menu->AppendSeparator();
    file_menu->Append(WXPRINT_ANGLEUP, _T("Angle up\tAlt-U"),                _T("Raise rotated text angle"));
    file_menu->Append(WXPRINT_ANGLEDOWN, _T("Angle down\tAlt-D"),            _T("Lower rotated text angle"));
    file_menu->AppendSeparator();
    file_menu->Append(WXPRINT_QUIT, _T("E&xit"),                _T("Exit program"));

    wxMenu *help_menu = new wxMenu;
    help_menu->Append(WXPRINT_ABOUT, _T("&About"),              _T("About this demo"));

    wxMenuBar *menu_bar = new wxMenuBar;

    menu_bar->Append(file_menu, _T("&File"));
    menu_bar->Append(help_menu, _T("&Help"));

    // Associate the menu bar with the frame
    frame->SetMenuBar(menu_bar);

    MyCanvas *canvas = new MyCanvas(frame, wxPoint(0, 0), wxSize(100, 100), wxRETAINED|wxHSCROLL|wxVSCROLL);

    // Give it scrollbars: the virtual canvas is 20 * 50 = 1000 pixels in each direction
    canvas->SetScrollbars(20, 20, 50, 50);

    frame->canvas = canvas;

    frame->Centre(wxBOTH);
    frame->Show();

#if wxUSE_STATUSBAR
    frame->SetStatusText(_T("Printing demo"));
#endif // wxUSE_STATUSBAR

    SetTopWindow(frame);

    return true;
}
Example #12
0
void frmMain::CreateMenus()
{
	// to add a new menu or context menu to the main window, i.e. define a possible
	// action on a pgObject, everything has to go into this method. Doing menu related
	// stuff elsewhere is plain wrong!
	// Create a proper actionFactory  (or contextActionFactory) for each of your new actions
	// in the new frmXXX.cpp and register it here.

	fileMenu = new wxMenu();
	pluginsMenu = new wxMenu();
	viewMenu = new wxMenu();
	editMenu = new wxMenu();
	newMenu = new wxMenu();
	toolsMenu = new wxMenu();
	slonyMenu = new wxMenu();
	scriptingMenu = new wxMenu();
	viewDataMenu = new wxMenu();
	debuggingMenu = new wxMenu();
	reportMenu = new wxMenu();
	wxMenu *cfgMenu = new wxMenu();
	helpMenu = new wxMenu();
	newContextMenu = new wxMenu();

	toolBar = new ctlMenuToolbar(this, -1, wxDefaultPosition, wxDefaultSize, wxTB_FLAT | wxTB_NODIVIDER );
	toolBar->SetToolBitmapSize(wxSize(32, 32));
	menuFactories = new menuFactoryList();

	// Load plugins - must do this after creating the menus and the factories
	LoadPluginUtilities();

	//--------------------------
	fileMenu->Append(MNU_SAVEDEFINITION, _("&Save Definition..."), _("Save the SQL definition of the selected object."));
	fileMenu->AppendSeparator();
	new addServerFactory(menuFactories, fileMenu, toolBar);

	viewMenu->Append(MNU_OBJECTBROWSER, _("&Object browser\tCtrl-Alt-O"),     _("Show or hide the object browser."), wxITEM_CHECK);
	viewMenu->Append(MNU_SQLPANE, _("&SQL pane\tCtrl-Alt-S"),     _("Show or hide the SQL pane."), wxITEM_CHECK);
	viewMenu->Append(MNU_TOOLBAR, _("&Tool bar\tCtrl-Alt-T"),     _("Show or hide the tool bar."), wxITEM_CHECK);
	viewMenu->AppendSeparator();
	viewMenu->Append(MNU_DEFAULTVIEW, _("&Default view\tCtrl-Alt-V"),     _("Restore the default view."));
	viewMenu->AppendSeparator();
	actionFactory *refFact = new refreshFactory(menuFactories, viewMenu, toolBar);
	new countRowsFactory(menuFactories, viewMenu, 0);
	new executePgstattupleFactory(menuFactories, viewMenu, 0);
	new executePgstatindexFactory(menuFactories, viewMenu, 0);
	new enabledisableRuleFactory(menuFactories, toolsMenu, 0);
	new enabledisableTriggerFactory(menuFactories, toolsMenu, 0);
	new enabledisableEventTriggerFactory(menuFactories, toolsMenu, 0);
	new disableAllTriggersFactory(menuFactories, toolsMenu, 0);
	new enableAllTriggersFactory(menuFactories, toolsMenu, 0);
	new validateForeignKeyFactory(menuFactories, toolsMenu, 0);
	new validateCheckFactory(menuFactories, toolsMenu, 0);
	new validateDomainCheckFactory(menuFactories, toolsMenu, 0);
	toolsMenu->AppendSeparator();

	//--------------------------
	new separatorFactory(menuFactories);

	toolBar->AddSeparator();

	new passwordFactory(menuFactories, fileMenu, 0);
	fileMenu->AppendSeparator();
	optionsFactory *optFact = new optionsFactory(menuFactories, fileMenu, 0);
	fileMenu->AppendSeparator();
	new mainConfigFileFactory(menuFactories, fileMenu, 0);
	new hbaConfigFileFactory(menuFactories, fileMenu, 0);
	new pgpassConfigFileFactory(menuFactories, fileMenu, 0);

	fileMenu->AppendSeparator();
	fileMenu->Append(MNU_EXIT, _("E&xit\tCtrl-Q"),                _("Quit this program."));

	new slonyRestartFactory(menuFactories, slonyMenu, 0);
	new slonyUpgradeFactory(menuFactories, slonyMenu, 0);
	new slonyFailoverFactory(menuFactories, slonyMenu, 0);
	new slonyLockSetFactory(menuFactories, slonyMenu, 0);
	new slonyUnlockSetFactory(menuFactories, slonyMenu, 0);
	new slonyMergeSetFactory(menuFactories, slonyMenu, 0);
	new slonyMoveSetFactory(menuFactories, slonyMenu, 0);
	toolsMenu->Append(MNU_SLONY_SUBMENU, _("Slony Replication"), slonyMenu);

	propFactory = new propertyFactory(menuFactories, 0, toolBar);
	new separatorFactory(menuFactories);


	// -------------------------

	editMenu->Append(MNU_COPY, _("&Copy\tCtrl-C"),                _("Copy selected text to clipboard"));
	editMenu->AppendSeparator();

	// -------------------------

	//--------------------------

	newMenuFactory = new submenuFactory(menuFactories);     // placeholder where "New objects" submenu will be inserted
	editMenu->Append(newMenuFactory->GetId(), _("New &Object"), newMenu,    _("Create a new object."));
	editMenu->AppendSeparator();


	//--------------------------

	new connectServerFactory(menuFactories, toolsMenu, 0);
	new disconnectServerFactory(menuFactories, toolsMenu, 0);
	new disconnectDatabaseFactory(menuFactories, toolsMenu, 0);

	new startServiceFactory(menuFactories, toolsMenu, 0);
	new stopServiceFactory(menuFactories, toolsMenu, 0);
	new reloadconfServiceFactory(menuFactories, toolsMenu, 0);
	new pausereplayServiceFactory(menuFactories, toolsMenu, 0);
	new resumereplayServiceFactory(menuFactories, toolsMenu, 0);
	new addnamedrestorepointServiceFactory(menuFactories, toolsMenu, 0);

	new createFactory(menuFactories, editMenu, toolBar);
	new dropFactory(menuFactories, editMenu, toolBar);
	new dropCascadedFactory(menuFactories, editMenu, 0);
	new truncateFactory(menuFactories, editMenu, 0);
	new truncateCascadedFactory(menuFactories, editMenu, 0);
	new resetTableStatsFactory(menuFactories, editMenu, 0);
	new resetFunctionStatsFactory(menuFactories, editMenu, 0);
	new reassignDropOwnedFactory(menuFactories, editMenu, 0);
	new searchObjectFactory(menuFactories, editMenu, 0);
	editMenu->AppendSeparator();

	new separatorFactory(menuFactories);

	toolBar->AddSeparator();
	toolsMenu->AppendSeparator();

	debuggingMenuFactory = new submenuFactory(menuFactories);     // placeholder where "Debugging" submenu will be inserted
	toolsMenu->Append(debuggingMenuFactory->GetId(), _("&Debugging"), debuggingMenu,    _("Debugging options for the selected item."));
	new debuggerFactory(menuFactories, debuggingMenu, 0);
	new breakpointFactory(menuFactories, debuggingMenu, 0);

	new queryToolFactory(menuFactories, toolsMenu, toolBar);
	scriptingMenuFactory = new submenuFactory(menuFactories);    // placeholder where "Query Template" submenu will be inserted
	toolsMenu->Append(scriptingMenuFactory->GetId(), _("Scripts"), scriptingMenu, _("Start Query Tool with scripted query."));
	new queryToolSqlFactory(menuFactories, scriptingMenu, 0);
	new queryToolSelectFactory(menuFactories, scriptingMenu, 0);
	new queryToolExecFactory(menuFactories, scriptingMenu, 0);
	new queryToolInsertFactory(menuFactories, scriptingMenu, 0);
	new queryToolUpdateFactory(menuFactories, scriptingMenu, 0);
	new queryToolDeleteFactory(menuFactories, scriptingMenu, 0);

#ifdef DATABASEDESIGNER
	new databaseDesignerFactory(menuFactories, toolsMenu, toolBar);
#endif

	viewdataMenuFactory = new submenuFactory(menuFactories);     // placeholder where "View data" submenu will be inserted
	toolsMenu->Append(viewdataMenuFactory->GetId(), _("View &Data"), viewDataMenu, _("View data."));

	reportMenuFactory = new submenuFactory(menuFactories);     // placeholder where "Reports" submenu will be inserted
	toolsMenu->Append(reportMenuFactory->GetId(), _("&Reports"), reportMenu,    _("Create reports about the selected item."));
	new reportObjectPropertiesFactory(menuFactories, reportMenu, 0);
	new reportObjectDdlFactory(menuFactories, reportMenu, 0);
	new reportObjectDataDictionaryFactory(menuFactories, reportMenu, 0);
	new reportObjectStatisticsFactory(menuFactories, reportMenu, 0);
	new reportObjectDependenciesFactory(menuFactories, reportMenu, 0);
	new reportObjectDependentsFactory(menuFactories, reportMenu, 0);
	new reportObjectListFactory(menuFactories, reportMenu, 0);


	toolsMenu->AppendSeparator();

	new editGridLimitedFactory(menuFactories, viewDataMenu, toolBar, 100, true);
	new editGridLimitedFactory(menuFactories, viewDataMenu, toolBar, 100, false);
	new editGridFactory(menuFactories, viewDataMenu, toolBar);
	new editGridFilteredFactory(menuFactories, viewDataMenu, toolBar);

	new maintenanceFactory(menuFactories, toolsMenu, toolBar);

	new backupFactory(menuFactories, toolsMenu, 0);
	new backupGlobalsFactory(menuFactories, toolsMenu, 0);
	new backupServerFactory(menuFactories, toolsMenu, 0);
	new restoreFactory(menuFactories, toolsMenu, 0);
	new importFactory(menuFactories, toolsMenu, 0);

	new grantWizardFactory(menuFactories, toolsMenu, 0);
	new mainConfigFactory(menuFactories, cfgMenu, 0);
	new hbaConfigFactory(menuFactories, cfgMenu, 0);
	toolsMenu->Append(MNU_CONFIGSUBMENU, _("Server Configuration"), cfgMenu);
	toolsMenu->AppendSeparator();

	new runNowFactory(menuFactories, toolsMenu, 0);
	toolsMenu->AppendSeparator();

	new separatorFactory(menuFactories);

	new propertyFactory(menuFactories, editMenu, 0);
	new serverStatusFactory(menuFactories, toolsMenu, 0);

	// Add the plugin toolbar button/menu
	new pluginButtonMenuFactory(menuFactories, pluginsMenu, toolBar, pluginUtilityCount);

	//--------------------------
	toolBar->AddSeparator();

	actionFactory *helpFact = new contentsFactory(menuFactories, helpMenu, 0);
	new hintFactory(menuFactories, helpMenu, toolBar, true);
	new faqFactory(menuFactories, helpMenu, 0);
	new bugReportFactory(menuFactories, helpMenu, 0);

	helpMenu->AppendSeparator();

	new pgsqlHelpFactory(menuFactories, helpMenu, toolBar, true);
	if (!appearanceFactory->GetHideEnterprisedbHelp())
		new edbHelpFactory(menuFactories, helpMenu, toolBar, true);
	if (!appearanceFactory->GetHideGreenplumHelp())
		new greenplumHelpFactory(menuFactories, helpMenu, toolBar, true);
	new slonyHelpFactory(menuFactories, helpMenu, toolBar, true);

	// Don't include this seperator on Mac, because the only option
	// under it will be moved to the application menu.
#ifndef __WXMAC__
	helpMenu->AppendSeparator();
#endif

	actionFactory *abFact = new aboutFactory(menuFactories, helpMenu, 0);

#ifdef __WXMAC__
	wxApp::s_macPreferencesMenuItemId = optFact->GetId();
	wxApp::s_macExitMenuItemId = MNU_EXIT;
	wxApp::s_macAboutMenuItemId = abFact->GetId();
#else
	(void)optFact;
	(void)abFact;
#endif


	menuBar = new wxMenuBar();
	menuBar->Append(fileMenu, _("&File"));
	menuBar->Append(editMenu, _("&Edit"));
	// Changing the caption of the plugins menu also needs a similar change below
	menuBar->Append(pluginsMenu, _("&Plugins"));
	menuBar->Append(viewMenu, _("&View"));
	menuBar->Append(toolsMenu, _("&Tools"));
	menuBar->Append(helpMenu, _("&Help"));
	SetMenuBar(menuBar);

	// Disable the plugins menu if there aren't any.
	if (!pluginUtilityCount)
	{
		pluginsMenu->Append(MNU_DUMMY, _("No plugins installed"));
		pluginsMenu->Enable(MNU_DUMMY, false);
	}

	treeContextMenu = 0;

	// Status bar
	statusBar = CreateStatusBar(3);
	int iWidths[3] = {0, -1, 100};
	SetStatusWidths(3, iWidths);
	SetStatusBarPane(-1);
	statusBar->SetStatusText(wxT(""), 0);
	statusBar->SetStatusText(_("Ready."), 1);
	statusBar->SetStatusText(_("0 Secs"), 2);

	wxAcceleratorEntry entries[4];
	entries[0].Set(wxACCEL_NORMAL, WXK_F5, refFact->GetId());
	entries[1].Set(wxACCEL_NORMAL, WXK_DELETE, MNU_DELETE);
	entries[2].Set(wxACCEL_NORMAL, WXK_F1, helpFact->GetId());
	entries[3].Set(wxACCEL_SHIFT, WXK_F10, MNU_CONTEXTMENU);
	wxAcceleratorTable accel(4, entries);

	SetAcceleratorTable(accel);

	// Display the bar and configure buttons.
	toolBar->Realize();
}
/*
  process any 
 */
bool AP_InertialSensor_MPU6000::update( void )
{    
#if !MPU6000_FAST_SAMPLING
    if (_sum_count < _sample_count) {
        // we don't have enough samples yet
        return false;
    }
#endif

    // we have a full set of samples
    uint16_t num_samples;
    Vector3f accel, gyro;

    hal.scheduler->suspend_timer_procs();
#if MPU6000_FAST_SAMPLING
    gyro = _gyro_filtered;
    accel = _accel_filtered;
    num_samples = 1;
#else
    gyro(_gyro_sum.x, _gyro_sum.y, _gyro_sum.z);
    accel(_accel_sum.x, _accel_sum.y, _accel_sum.z);
    num_samples = _sum_count;
    _accel_sum.zero();
    _gyro_sum.zero();
#endif
    _sum_count = 0;
    hal.scheduler->resume_timer_procs();

    gyro *= _gyro_scale / num_samples;
    accel *= MPU6000_ACCEL_SCALE_1G / num_samples;

#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXF
    accel.rotate(ROTATION_PITCH_180_YAW_90);
    gyro.rotate(ROTATION_PITCH_180_YAW_90);
#endif

    _publish_accel(_accel_instance, accel);
    _publish_gyro(_gyro_instance, gyro);

#if MPU6000_FAST_SAMPLING
    if (_last_accel_filter_hz != _accel_filter_cutoff()) {
        _accel_filter.set_cutoff_frequency(1000, _accel_filter_cutoff());
        _last_accel_filter_hz = _accel_filter_cutoff();
    }

    if (_last_gyro_filter_hz != _gyro_filter_cutoff()) {
        _gyro_filter.set_cutoff_frequency(1000, _gyro_filter_cutoff());
        _last_gyro_filter_hz = _gyro_filter_cutoff();
    }
#else
    if (_last_accel_filter_hz != _accel_filter_cutoff()) {
        if (_spi_sem->take(10)) {
            _spi->set_bus_speed(AP_HAL::SPIDeviceDriver::SPI_SPEED_LOW);
            _set_filter_register(_accel_filter_cutoff());
            _spi->set_bus_speed(AP_HAL::SPIDeviceDriver::SPI_SPEED_HIGH);
            _spi_sem->give();
            _last_accel_filter_hz = _accel_filter_cutoff();
        }
    }
#endif

    return true;
}
Example #14
0
BrowserLibraryFilter::BrowserLibraryFilter(BrowserLibraryController *pController) :
wxDialog (0, -1, wxT ("Library Filter"), wxDefaultPosition, wxDefaultSize),
// Initialisation of member objects and variables
    m_pCancelButton (NULL),
    m_pCardNameText (NULL),
    m_pClanLess (NULL),
    m_pClanList (NULL),
    m_pClearButton (NULL),
    m_pCombo (NULL),
    m_pController (pController),
    m_pCostBlood (NULL),
    m_pCostPool (NULL),
    m_pHave (NULL),
    m_pHaveOrWant (NULL),
    m_pDisciplineLess (NULL),
    m_pDisciplineList (NULL),
    m_pEditionList (NULL),
    m_pMultiDiscipline (NULL),
    m_pOKButton (NULL),
    m_pOtherText (NULL),
    m_pRarityList (NULL),
    m_pReflex (NULL),
    m_pTitleList (NULL)
{
    wxAcceleratorEntry entries[3];
    entries[0].Set(wxACCEL_NORMAL, WXK_RETURN, ID_OK_BUTTON);
    entries[1].Set(wxACCEL_NORMAL, WXK_ESCAPE, ID_CANCEL_BUTTON);
    entries[2].Set(wxACCEL_NORMAL, WXK_DELETE, ID_CLEAR_BUTTON);
    wxAcceleratorTable accel(3, entries);
    this->SetAcceleratorTable(accel);

    InterfaceData *pUIData = InterfaceData::Instance ();

    wxBoxSizer *pPapaSizerV = new wxBoxSizer (wxVERTICAL);
    wxBoxSizer *pPapaSizer = new wxBoxSizer (wxHORIZONTAL);
    pPapaSizerV->Add(pPapaSizer);

    SetAutoLayout(TRUE);
    SetSizer(pPapaSizerV);

    // The card types
    wxStaticBoxSizer *pTypeBox = new wxStaticBoxSizer (new wxStaticBox (this, -1, wxT ("By card type")), wxVERTICAL);
    wxBoxSizer *pCardTypeSizer = new wxBoxSizer(wxVERTICAL);

    for (unsigned int i = 0; i < pUIData->GetTypes()->GetCount(); i++) {
        BuildType(i, pTypeBox);
    }

    m_pCombo = new wxCheckBox (this, -1, wxT ("Combo"));
    wxBoxSizer *pComboSizer = new wxBoxSizer (wxHORIZONTAL);
    wxString sComboIconName (wxT ("Type Combo"));
    wxStaticBitmap *pComboIcon = pUIData->MakeStaticBitmap (this, sComboIconName);
    if (pComboIcon) pComboSizer->Add (pComboIcon, 0, wxRIGHT, 5);
    pComboSizer->Add (m_pCombo);
    m_pReflex = new wxCheckBox (this, -1, wxT ("Reflex"));
    wxBoxSizer *pReflexSizer = new wxBoxSizer (wxHORIZONTAL);
    wxString sReflexIconName (wxT ("Type Reflex"));
    wxStaticBitmap *pReflexIcon = pUIData->MakeStaticBitmap(this, sReflexIconName);
    if (pReflexIcon) pReflexSizer->Add(pReflexIcon, 0, wxRIGHT, 5);
    pReflexSizer->Add (m_pReflex);

#ifdef __WXMSW__
    // this looks nicer in Windows
    pTypeBox->Add (pComboSizer, 0, wxALL, 3);
    pTypeBox->Add (pReflexSizer, 0, wxALL, 3);
#else
    pTypeBox->Add (pComboSizer);
    pTypeBox->Add (pReflexSizer);
#endif

    pPapaSizer->Add(pCardTypeSizer, 0, wxEXPAND | wxALL, 5);
    pCardTypeSizer->Add(pTypeBox, 0, wxEXPAND);

    // The Clans and Disciplines Sizer
    wxBoxSizer *pClanDiscSizer = new wxBoxSizer (wxVERTICAL);
    pPapaSizer->Add(pClanDiscSizer, 1, wxEXPAND | wxALL, 5);

    // The Disciplines list
    wxStaticBoxSizer *pDisciplineBox = new wxStaticBoxSizer (new wxStaticBox (this, -1, wxT ("By discipline")), wxVERTICAL);
    m_pDisciplineList = new wxListView (this, -1, wxDefaultPosition, wxSize (200, 75), wxLC_REPORT | wxLC_NO_HEADER);
    m_pDisciplineList->InsertColumn (0, wxEmptyString);
    for (unsigned int i = 0; i < pUIData->GetLibraryDisciplines ()->GetCount (); i++) {
        m_pDisciplineList->InsertItem (i, pUIData->GetLibraryDisciplines ()->Item (i)[0]);
    }
    pDisciplineBox->Add (m_pDisciplineList, 1, wxEXPAND | wxTOP, 5);
    m_pMultiDiscipline = new wxCheckBox (this, -1, wxT ("Multi Discipline"));
    m_pDisciplineLess = new wxCheckBox (this, ID_CHECK_DISCLESS, wxT ("Disciplineless"));
#ifdef __WXMSW__
    // this looks nicer in Windows
    pDisciplineBox->Add (m_pMultiDiscipline, 0, wxALL, 3);
    pDisciplineBox->Add (m_pDisciplineLess, 0, wxALL, 3);
#else
    pDisciplineBox->Add (m_pMultiDiscipline);
    pDisciplineBox->Add (m_pDisciplineLess);
#endif
    pClanDiscSizer->Add (pDisciplineBox, 1, wxEXPAND);

    // the Titles and Other sizers
    wxBoxSizer *pTitleOtherSizer = new wxBoxSizer (wxVERTICAL);
    pPapaSizer->Add (pTitleOtherSizer, 1, wxEXPAND | wxALL, 5);

    // Titles
    wxStaticBoxSizer *pTitleBox = new wxStaticBoxSizer (new wxStaticBox (this, -1, wxT ("By title")), wxVERTICAL);
    m_pTitleList = new wxListView (this, -1, wxDefaultPosition, wxSize (200, 75), wxLC_REPORT | wxLC_NO_HEADER);
    m_pTitleList->InsertColumn (0, wxEmptyString);
    // here we won't include any of the wildcard titles

    for (unsigned int i = 0; i < pUIData->GetTitles ()->GetCount () - 2; i++) {
        m_pTitleList->InsertItem (i, pUIData->GetTitles ()->Item (i)[0]);
    }

    pTitleBox->Add (m_pTitleList, 1, wxEXPAND | wxTOP, 5);
    pTitleOtherSizer->Add (pTitleBox, 0, wxEXPAND);

    // Clans
    wxStaticBoxSizer *pClanBox = new wxStaticBoxSizer (new wxStaticBox (this, -1, wxT ("By clan")), wxVERTICAL);
    m_pClanList = new wxListView (this, -1, wxDefaultPosition, wxSize (200, 75), wxLC_REPORT | wxLC_NO_HEADER);
    m_pClanList->InsertColumn (0, wxEmptyString);
    for (unsigned int i = 0; i < pUIData->GetClans ()->GetCount (); i++) {
        m_pClanList->InsertItem (i, pUIData->GetClans ()->Item (i));
    }
    pClanBox->Add (m_pClanList, 1, wxEXPAND | wxTOP, 5);
    wxGridSizer *pAnarchEtcSizer = new wxGridSizer (2);
    pClanBox->Add (pAnarchEtcSizer);
    m_pClanLess = new wxCheckBox (this, ID_CHECK_CLANLESS, wxT ("Clanless"));
#ifdef __WXMSW__
    // this looks nicer in Windows
    pAnarchEtcSizer->Add (m_pClanLess, 0, wxALL, 3);
#else
    pAnarchEtcSizer->Add (m_pClanLess);
#endif
    pClanDiscSizer->Add (pClanBox, 1, wxEXPAND);

    // Editions
    wxStaticBoxSizer *pEditionBox = new wxStaticBoxSizer (new wxStaticBox (this, -1, wxT ("By set")), wxHORIZONTAL);
    wxBoxSizer *pEditionSizer = new wxBoxSizer (wxVERTICAL);
    pEditionBox->Add (pEditionSizer, 1, wxEXPAND);
    m_pEditionList = new wxListView (this, -1, wxDefaultPosition, wxSize (200, 75), wxLC_REPORT | wxLC_NO_HEADER);
    m_pEditionList->InsertColumn (0, wxEmptyString);
    for (unsigned int i = 0; i < pUIData->GetEditions ()->GetCount (); i++) {
        m_pEditionList->InsertItem (i, pUIData->GetEditions ()->Item (i));
    }
    pEditionSizer->Add (m_pEditionList, 1, wxEXPAND | wxTOP, 5);
    pTitleOtherSizer->Add (pEditionBox, 1, wxEXPAND);


    // Rarity
    wxStaticBoxSizer *pRarityBox = new wxStaticBoxSizer (new wxStaticBox (this, -1, wxT ("By rarity")), wxHORIZONTAL);
    wxBoxSizer *pRaritySizer = new wxBoxSizer (wxVERTICAL);
    pRarityBox->Add (pRaritySizer, 1, wxEXPAND);
    m_pRarityList = new wxListView (this, -1, wxDefaultPosition, wxSize (200, 75), wxLC_REPORT | wxLC_NO_HEADER);
    m_pRarityList->InsertColumn (0, wxEmptyString);
    for (unsigned int i = 0; i < pUIData->GetRarities ()->GetCount (); i++) {
        m_pRarityList->InsertItem (i, pUIData->GetRarities ()->Item (i)[0]);
    }
    pRaritySizer->Add (m_pRarityList, 1, wxEXPAND | wxTOP, 5);
    pTitleOtherSizer->Add (pRarityBox, 1, wxEXPAND);


    // Card text
    wxStaticBoxSizer *pTextBox = new wxStaticBoxSizer (new wxStaticBox (this, -1, wxT ("By card text")), wxVERTICAL);
    wxFlexGridSizer *pTextSizer = new wxFlexGridSizer (2, 5, 5);

    wxStaticText *pLabel = new wxStaticText (this, -1, wxT ("Card name :"));
    pTextSizer->Add (pLabel, 0, wxALIGN_CENTER_VERTICAL);
    m_pCardNameText = new wxTextCtrl (this, -1, wxT (""), wxDefaultPosition, wxSize (150, -1));
    pTextSizer->Add (m_pCardNameText, 1, wxEXPAND);

    wxStaticText *pLabel2 = new wxStaticText (this, -1, wxT ("Other text :"));
    pTextSizer->Add (pLabel2, 0, wxALIGN_CENTER_VERTICAL);
    m_pOtherText = new wxTextCtrl (this, -1, wxT (""), wxDefaultPosition, wxSize (150, -1));
    pTextSizer->Add (m_pOtherText, 1, wxEXPAND);

    pTextBox->Add (pTextSizer, 1, wxEXPAND | wxTOP, 5);
    pTitleOtherSizer->Add (pTextBox, 0, wxEXPAND);

    // Other (cost blood, pool, burn option, etc..)
    wxStaticBoxSizer *pOtherBox = new wxStaticBoxSizer (new wxStaticBox (this, -1, wxT ("Other")), wxVERTICAL);
    wxFlexGridSizer *pOtherSizer = new wxFlexGridSizer (2,2);
    pOtherBox->Add (pOtherSizer, 1, wxEXPAND | wxTOP, 5);
    for (unsigned int i = 0; i < pUIData->GetLibraryReqs ()->GetCount (); i++) {
        BuildLibraryReqs (i, pOtherSizer, this);
    }

    for (unsigned int i = 0; i < pUIData->GetLibraryTexts ()->GetCount (); i++) {
        BuildLibraryTexts (i, pOtherSizer, this);
    }

    m_pCostBlood = new wxCheckBox (this, -1, wxT ("Cost Blood"));
    m_pCostPool = new wxCheckBox (this, -1, wxT ("Cost Pool"));
    m_pHave = new wxCheckBox (this, -1, wxT ("Have Only"));
    m_pHaveOrWant = new wxCheckBox (this, -1, wxT ("Have or Want"));

    pOtherSizer->Add(m_pCostBlood, 0, wxALL, 3);
    pOtherSizer->Add(m_pCostPool, 0, wxALL, 3);
    pOtherSizer->Add(m_pHave, 0, wxALL, 3);
    pOtherSizer->Add(m_pHaveOrWant, 0, wxALL, 3);
    pClanDiscSizer->Add(pOtherBox, 0, wxEXPAND);


    // OK, Clear and Cancel buttons
    wxBoxSizer *pOKCancelSizer = new wxBoxSizer (wxHORIZONTAL);
    m_pOKButton = new wxButton (this, ID_OK_BUTTON, wxT ("OK"));
    pOKCancelSizer->Add (m_pOKButton, 0, wxRIGHT | wxALIGN_BOTTOM, 5);
    m_pClearButton = new wxButton (this, ID_CLEAR_BUTTON, wxT ("Clear All"));
    pOKCancelSizer->Add (m_pClearButton, 0, wxRIGHT | wxALIGN_BOTTOM, 5);
    m_pCancelButton = new wxButton (this, ID_CANCEL_BUTTON, wxT ("Cancel"));
    pOKCancelSizer->Add (m_pCancelButton, 0, wxRIGHT | wxALIGN_BOTTOM, 5);
    pPapaSizerV->Add (pOKCancelSizer, 1, wxALIGN_RIGHT | wxALL, 5);

    pPapaSizerV->Layout ();
    pPapaSizerV->Fit (this);

    m_pClanList->SetColumnWidth (0, m_pClanList->GetClientSize ().GetWidth () - 20);
    m_pDisciplineList->SetColumnWidth (0, m_pDisciplineList->GetClientSize ().GetWidth () - 20);
    m_pTitleList->SetColumnWidth (0, m_pTitleList->GetClientSize ().GetWidth () - 20);
    m_pEditionList->SetColumnWidth (0, m_pEditionList->GetClientSize ().GetWidth () - 20);
    m_pRarityList->SetColumnWidth (0, m_pRarityList->GetClientSize ().GetWidth () - 20);

    SetIcon (*g_pIcon);
}
Example #15
0
ModEditWindow::ModEditWindow(MainWindow *parent, Instance *inst)
	: wxFrame(parent, -1, _("Edit Mods"), wxDefaultPosition, wxSize(500, 400))
{
	m_mainWin = parent;
	wxPanel *mainPanel = new wxPanel(this);

	SetTitle(wxString::Format(_("Edit Mods for %s"), inst->GetName().c_str()));
	
	m_inst = inst;
	
	wxBoxSizer *mainBox = new wxBoxSizer(wxVERTICAL);
	mainPanel->SetSizer(mainBox);
	
	wxNotebook *modEditNotebook = new wxNotebook(mainPanel, -1);
	mainBox->Add(modEditNotebook, wxSizerFlags(1).Expand().Border(wxALL, 8));
	
	// .jar mod panel
	{
		wxPanel *jarModPanel = new wxPanel(modEditNotebook, -1);
		wxBoxSizer *jarModSizer = new wxBoxSizer(wxHORIZONTAL);
		jarModPanel->SetSizer(jarModSizer);
		modEditNotebook->AddPage(jarModPanel, _("Minecraft.jar"), true);
		
		jarModList = new JarModListCtrl(jarModPanel, ID_JAR_MOD_LIST, inst);
		jarModList->InsertColumn(0, _("Mod Name"));
		jarModList->InsertColumn(1, _("Mod Version"), wxLIST_FORMAT_RIGHT);
		jarModList->SetDropTarget(new JarModsDropTarget(jarModList, inst));
		jarModSizer->Add(jarModList, wxSizerFlags(1).Expand().Border(wxALL, 8));
		
		wxBoxSizer *jarListBtnBox = new wxBoxSizer(wxVERTICAL);
		jarModSizer->Add(jarListBtnBox, wxSizerFlags(0).Border(wxTOP | wxBOTTOM, 4).Expand());
		
		wxButton *addJarModBtn = new wxButton(jarModPanel, ID_ADD_JAR_MOD, _("&Add"));
		addJarModBtn->SetToolTip(_("Add a jar mod."));
		jarListBtnBox->Add(addJarModBtn, wxSizerFlags(0).Border(wxTOP | wxBOTTOM | wxRIGHT, 4).Expand());
		
		delJarModBtn = new wxButton(jarModPanel, ID_DEL_JAR_MOD, _("&Remove"));
		delJarModBtn->SetToolTip(_("Remove the selected jar mod."));
		jarListBtnBox->Add(delJarModBtn, wxSizerFlags(0).Border(wxTOP | wxBOTTOM | wxRIGHT, 4).Expand());

		wxButton *installMCForgeBtn = new wxButton(jarModPanel, ID_INSTALL_FORGE, _("MCForge"));
		installMCForgeBtn->SetToolTip(_("Download and install Minecraft Forge"));
		jarListBtnBox->Add(installMCForgeBtn, wxSizerFlags(0).Border(wxTOP | wxBOTTOM | wxRIGHT, 4).Expand());

		jarListBtnBox->AddStretchSpacer();
		
		jarModUpBtn = new wxButton(jarModPanel, ID_MOVE_JAR_MOD_UP, _("Move &Up"));
		jarModUpBtn->SetToolTip(_("Move the selected jar mod up."));
		jarListBtnBox->Add(jarModUpBtn, wxSizerFlags(0).Border(wxTOP | wxBOTTOM | wxRIGHT, 4).Align(wxALIGN_BOTTOM).Expand());
		
		jarModDownBtn = new wxButton(jarModPanel, ID_MOVE_JAR_MOD_DOWN, _("Move &Down"));
		jarModDownBtn->SetToolTip(_("Move the selected jar mod down"));
		jarListBtnBox->Add(jarModDownBtn, wxSizerFlags(0).Border(wxTOP | wxBOTTOM | wxRIGHT, 4).Align(wxALIGN_BOTTOM).Expand());
	}
	
	// Core mod folder panel
	{
		auto coreModPanel = new wxPanel(modEditNotebook, -1);
		auto coreModSizer = new wxBoxSizer(wxHORIZONTAL);
		coreModPanel->SetSizer(coreModSizer);
		modEditNotebook->AddPage(coreModPanel, _("Coremods Folder"));
		
		coreModList = new CoreModListCtrl(coreModPanel, ID_CORE_MOD_LIST, inst);
		coreModList->InsertColumn(0, _("Mod Name"));
		coreModList->InsertColumn(1, _("Mod Version"), wxLIST_FORMAT_RIGHT);
		coreModList->SetDropTarget(new CoreModsDropTarget(coreModList, inst));
		coreModSizer->Add(coreModList, wxSizerFlags(1).Expand().Border(wxALL, 8));
		
		auto coreModListBtnBox = new wxBoxSizer(wxVERTICAL);
		coreModSizer->Add(coreModListBtnBox, wxSizerFlags(0).Border(wxTOP | wxBOTTOM, 4).Expand());
		
		wxButton *addCoreModBtn = new wxButton(coreModPanel, ID_ADD_CORE_MOD, _("&Add"));
		addCoreModBtn->SetToolTip(_("Add a new forge core mod."));
		coreModListBtnBox->Add(addCoreModBtn, wxSizerFlags(0).Border(wxTOP | wxBOTTOM | wxRIGHT, 4).Expand());
		
		wxButton *delCoreModBtn = new wxButton(coreModPanel, ID_DEL_CORE_MOD, _("&Remove"));
		delCoreModBtn->SetToolTip(_("Remove the selected core mod"));
		coreModListBtnBox->Add(delCoreModBtn, wxSizerFlags(0).Border(wxTOP | wxBOTTOM | wxRIGHT, 4).Expand());

		coreModListBtnBox->AddStretchSpacer();
		
		auto exploreCoreModBtn = new wxButton(coreModPanel, ID_EXPLORE_CORE, _("&View Folder"));
		exploreCoreModBtn->SetToolTip(_("Open the core mod folder in your file browser."));
		coreModListBtnBox->Add(exploreCoreModBtn, wxSizerFlags(0).Border(wxTOP | wxBOTTOM | wxRIGHT, 4).Align(wxALIGN_BOTTOM).Expand());
	}
	
	// Mod folder panel
	{
		wxPanel *mlModPanel = new wxPanel(modEditNotebook, -1);
		wxBoxSizer *mlModSizer = new wxBoxSizer(wxHORIZONTAL);
		mlModPanel->SetSizer(mlModSizer);
		modEditNotebook->AddPage(mlModPanel, _("Mods Folder"));
		
		mlModList = new MLModListCtrl(mlModPanel, ID_ML_MOD_LIST, inst);
		mlModList->InsertColumn(0, _("Mod Name"));
		mlModList->InsertColumn(1, _("Mod Version"), wxLIST_FORMAT_RIGHT);
		mlModList->SetDropTarget(new MLModsDropTarget(mlModList, inst));
		mlModSizer->Add(mlModList, wxSizerFlags(1).Expand().Border(wxALL, 8));
		
		wxBoxSizer *mlModListBtnBox = new wxBoxSizer(wxVERTICAL);
		mlModSizer->Add(mlModListBtnBox, wxSizerFlags(0).Border(wxTOP | wxBOTTOM, 4).Expand());
		
		wxButton *addMLModBtn = new wxButton(mlModPanel, ID_ADD_ML_MOD, _("&Add"));
		addMLModBtn->SetToolTip(_("Add a new modloader mod."));
		mlModListBtnBox->Add(addMLModBtn, wxSizerFlags(0).Border(wxTOP | wxBOTTOM | wxRIGHT, 4).Expand());
		
		wxButton *delMLModBtn = new wxButton(mlModPanel, ID_DEL_ML_MOD, _("&Remove"));
		delMLModBtn->SetToolTip(_("Remove the selected modloader mod."));
		mlModListBtnBox->Add(delMLModBtn, wxSizerFlags(0).Border(wxTOP | wxBOTTOM | wxRIGHT, 4).Expand());

		mlModListBtnBox->AddStretchSpacer();
		
		auto exploreMLModBtn = new wxButton(mlModPanel, ID_EXPLORE_ML, _("&View Folder"));
		exploreMLModBtn->SetToolTip(_("Open the modloader mods folder in your file browser."));
		mlModListBtnBox->Add(exploreMLModBtn, wxSizerFlags(0).Border(wxTOP | wxBOTTOM | wxRIGHT, 4).Align(wxALIGN_BOTTOM).Expand());
	}

	// Texture pack tab
	{
		wxPanel *tpPanel = new wxPanel(modEditNotebook, -1);
		wxBoxSizer *tpSizer = new wxBoxSizer(wxHORIZONTAL);
		tpPanel->SetSizer(tpSizer);
		modEditNotebook->AddPage(tpPanel, _("Texture Packs"));

		texturePackList = new TexturePackListCtrl(tpPanel, ID_TEXTURE_PACK_LIST, inst);
		texturePackList->InsertColumn(0, _("Name"));
		texturePackList->SetDropTarget(new TexturePackDropTarget(texturePackList, inst));
		tpSizer->Add(texturePackList, wxSizerFlags(1).Expand().Border(wxALL, 8));

		wxBoxSizer *tpackListBtnBox = new wxBoxSizer(wxVERTICAL);
		tpSizer->Add(tpackListBtnBox, wxSizerFlags(0).Border(wxTOP | wxBOTTOM, 4).Expand());

		wxButton *addTPackButton = new wxButton(tpPanel, ID_ADD_TEXTURE_PACK, _("&Add"));
		addTPackButton->SetToolTip(_("Add a new texture pack."));
		tpackListBtnBox->Add(addTPackButton, wxSizerFlags(0).Border(wxTOP | wxBOTTOM | wxRIGHT, 4).Expand());

		wxButton *delTPackButton = new wxButton(tpPanel, ID_DEL_TEXTURE_PACK, _("&Remove"));
		delTPackButton->SetToolTip(_("Remove the selected texture pack."));
		tpackListBtnBox->Add(delTPackButton, wxSizerFlags(0).Border(wxTOP | wxBOTTOM | wxRIGHT, 4).Expand());

		tpackListBtnBox->AddStretchSpacer();

		auto exploreTPackButton = new wxButton(tpPanel, ID_EXPLORE_TEXTURE_PACK, _("&View Folder"));
		exploreTPackButton->SetToolTip(_("Open the texture packs folder in your file browser."));
		tpackListBtnBox->Add(exploreTPackButton, wxSizerFlags(0).Border(wxTOP | wxBOTTOM | wxRIGHT, 4).Align(wxALIGN_BOTTOM).Expand());
	}
	
	// Buttons on the bottom of the dialog
	{
		wxBoxSizer *btnBox = new wxBoxSizer(wxHORIZONTAL);
		mainBox->Add(btnBox, 0, wxEXPAND | wxBOTTOM | wxRIGHT | wxLEFT, 8);

		wxButton *btnReload = new wxButton(mainPanel, ID_RELOAD, _("&Reload"));
		btnReload->SetToolTip(_("Reload the mod lists."));
		btnBox->Add(btnReload, wxSizerFlags(0).Align(wxALIGN_LEFT).Border(wxRIGHT | wxTOP | wxBOTTOM, 4));

		wxButton *btnExport = new wxButton(mainPanel, ID_EXPORT, _("&Export"));
		btnExport->SetToolTip(_("Export the instance to a config pack."));
		btnBox->Add(btnExport, wxSizerFlags(0).Align(wxALIGN_LEFT).Border(wxRIGHT | wxTOP | wxBOTTOM, 4));

		btnBox->AddStretchSpacer();

		wxButton *btnClose = new wxButton(mainPanel, wxID_CLOSE, _("&Close"));
		btnClose->SetToolTip(_("Close this window."));
		btnBox->Add(btnClose, wxSizerFlags(0).Align(wxALIGN_RIGHT).Border(wxTOP | wxBOTTOM, 4));
	}

	// Keyboard accelerators.
	wxAcceleratorEntry entries[1];
	entries[0].Set(wxACCEL_CTRL,	(int) 'W',	wxID_CLOSE);
	wxAcceleratorTable accel(sizeof(entries), entries);
	SetAcceleratorTable(accel);
	
	CenterOnParent();
	
	LoadJarMods();
	LoadMLMods();
	LoadCoreMods();
	texturePackList->UpdateItems();
}
Example #16
0
void ErdPanel::Init(wxWindow* parent, IDbAdapter* dbAdapter)
{

    SetExtraStyle(wxWS_EX_BLOCK_EVENTS);

    ErdInfo* pInfo = new ErdInfo();
    pInfo->SetAdapterType(m_pDbAdapter->GetAdapterType());
    m_diagramManager.SetRootItem(pInfo);

    m_pFrameCanvas = new FrameCanvas(&m_diagramManager, dbAdapter, m_wxsfPanel, this, wxID_ANY);
    m_wxsfPanel->GetSizer()->Add(m_pFrameCanvas, 1, wxEXPAND, 2);
    m_wxsfPanel->Layout();

    m_nToolMode = modeDESIGN;

    BitmapLoader* bmpLoader = DatabaseExplorer::GetManager()->GetStdIcons();

    //	m_toolBarErd->SetToolBitmapSize(wxSize(16, 16));
    m_toolBarErd->AddTool(
        XRCID("IDT_OPEN"), _("Open"), bmpLoader->LoadBitmap(wxT("toolbars/16/standard/file_open")), _("Open diagram"));
    m_toolBarErd->AddTool(
        XRCID("IDT_SAVE"), _("Save"), bmpLoader->LoadBitmap(wxT("toolbars/16/standard/file_save")), _("Save diagram"));
    m_toolBarErd->AddTool(XRCID("IDT_ERD_SAVE_SQL"), _("Save SQL"), wxBitmap(export_sql_xpm), _("Save SQL"));
    m_toolBarErd->AddTool(XRCID("IDT_ERD_COMMIT"), _("Commit ERD"), wxBitmap(export_db_xpm), _("Commit ERD"));
    m_toolBarErd->AddTool(
        XRCID("IDT_ERD_SAVE_IMG"), _("Export canvas to image"), wxBitmap(export_img_xpm), _("Export canvas to image"));
    m_toolBarErd->AddSeparator();
    m_toolBarErd->AddTool(XRCID("IDT_PRINT"), _("Print"), wxBitmap(fileprint_xpm), _("Print diagram"));
    m_toolBarErd->AddTool(XRCID("IDT_PREVIEW"), _("Preview"), wxBitmap(filepreview_xpm), _("Print preview"));
    m_toolBarErd->AddSeparator();
    m_toolBarErd->AddTool(
        XRCID("IDT_COPY"), _("Copy"), bmpLoader->LoadBitmap(wxT("toolbars/16/standard/copy")), _("Copy item"));
    m_toolBarErd->AddTool(
        XRCID("IDT_CUT"), _("Cut"), bmpLoader->LoadBitmap(wxT("toolbars/16/standard/cut")), _("Cut item"));
    m_toolBarErd->AddTool(
        XRCID("IDT_PASTE"), _("Paste"), bmpLoader->LoadBitmap(wxT("toolbars/16/standard/paste")), _("Paste item"));
    m_toolBarErd->AddSeparator();
    m_toolBarErd->AddTool(
        XRCID("IDT_UNDO"), _("Undo"), bmpLoader->LoadBitmap(wxT("toolbars/16/standard/undo")), _("Undo"));
    m_toolBarErd->AddTool(
        XRCID("IDT_REDO"), _("Redo"), bmpLoader->LoadBitmap(wxT("toolbars/16/standard/redo")), _("Redo"));
    m_toolBarErd->AddSeparator();
    m_toolBarErd->AddTool(XRCID("IDT_ERD_TOOL"),
                          _("Tool"),
                          wxBitmap(Tool_xpm),
                          wxNullBitmap,
                          wxITEM_RADIO,
                          _("Design tool"),
                          _("Design tool"),
                          NULL);
    m_toolBarErd->AddTool(XRCID("IDT_ERD_TABLE"),
                          _("DBETable"),
                          bmpLoader->LoadBitmap(wxT("db-explorer/16/table")),
                          wxNullBitmap,
                          wxITEM_RADIO,
                          _("Database table"),
                          _("Database table"),
                          NULL);
    m_toolBarErd->AddTool(XRCID("IDT_ERD_VIEW"),
                          _("View"),
                          bmpLoader->LoadBitmap(wxT("toolbars/16/search/find")),
                          wxNullBitmap,
                          wxITEM_RADIO,
                          _("Database view"),
                          _("Database view"),
                          NULL);
    m_toolBarErd->AddTool(XRCID("IDT_ERD_LINE"),
                          _("Constraint 1:N"),
                          wxXmlResource::Get()->LoadBitmap(wxT("link_editor")),
                          wxNullBitmap,
                          wxITEM_RADIO,
                          _("Foreign key connection"),
                          _("Foreign key connection"),
                          NULL);
    m_toolBarErd->AddSeparator();
    m_toolBarErd->AddTool(
        XRCID("IDT_ERD_ALIGN_CIRCLE"), _("Align into circle"), wxBitmap(AlignCircle_xpm), _("Align into circle"));
    m_toolBarErd->AddTool(
        XRCID("IDT_ERD_ALIGN_MESH"), _("Align into mesh"), wxBitmap(AlignMesh_xpm), _("Align into mesh"));
    m_toolBarErd->AddTool(XRCID("IDT_ERD_ALIGN_VTREE"),
                          _("Align into vertical tree"),
                          wxBitmap(AlignVTree_xpm),
                          _("Align into vertical tree"));
    m_toolBarErd->AddTool(XRCID("IDT_ERD_ALIGN_HTREE"),
                          _("Align into horizontal tree"),
                          wxBitmap(AlignHTree_xpm),
                          _("Align into horizontal tree"));
    m_toolBarErd->AddSeparator();
    m_toolBarErd->AddTool(XRCID("IDT_ERD_ZOOM100"), _("Zoom 100%"), wxBitmap(Zoom100_xpm), _("Zoom 100%"));
    m_toolBarErd->AddTool(XRCID("IDT_ERD_ZOOMALL"), _("Zoom to all"), wxBitmap(ZoomAll_xpm), _("Zoom to all"));
    m_toolBarErd->Realize();

    wxAcceleratorEntry entries[4];
    entries[0].Set(wxACCEL_CTRL, (int)'C', XRCID("IDT_COPY"));
    entries[1].Set(wxACCEL_CTRL, (int)'X', XRCID("IDT_CUT"));
    entries[2].Set(wxACCEL_CTRL, (int)'V', XRCID("IDT_PASTE"));
    entries[3].Set(wxACCEL_CTRL, (int)'A', XRCID("IDT_SELECTALL"));
    wxAcceleratorTable accel(4, entries);
    SetAcceleratorTable(accel);
}
Example #17
0
void ctlSQLBox::Create(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style)
{
	wxStyledTextCtrl::Create(parent, id , pos, size, style);

	// Clear all styles
	StyleClearAll();

	// Font
	extern sysSettings *settings;
	wxFont fntSQLBox = settings->GetSQLFont();

	wxColour bgColor = settings->GetSQLBoxColourBackground();
	if (settings->GetSQLBoxUseSystemBackground())
	{
		bgColor = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
	}

	wxColour frColor = settings->GetSQLBoxColourForeground();
	if (settings->GetSQLBoxUseSystemForeground())
	{
		frColor = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
	}
	StyleSetBackground(wxSTC_STYLE_DEFAULT, bgColor);
	StyleSetForeground(wxSTC_STYLE_DEFAULT, frColor);
	StyleSetFont(wxSTC_STYLE_DEFAULT, fntSQLBox);

	SetSelBackground(true, wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT));
	SetSelForeground(true, wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT));

	SetCaretForeground(settings->GetSQLColourCaret());

	SetMarginWidth(1, 0);
	SetTabWidth(settings->GetIndentSpaces());
	SetUseTabs(!settings->GetSpacesForTabs());

	// Setup the different highlight colurs
	for (int i = 0; i < 34; ++ i )
	{
		if (i > 0 && i < 12)
			StyleSetForeground(i, settings->GetSQLBoxColour(i));
		else
			StyleSetForeground(i, frColor);
		StyleSetBackground(i, bgColor);
		StyleSetFont(i, fntSQLBox);
	}

	// Keywords in uppercase?

	if (settings->GetSQLKeywordsInUppercase())
		StyleSetCase(5, wxSTC_CASE_UPPER);

	// Margin style
	StyleSetBackground(wxSTC_STYLE_LINENUMBER, settings->GetSQLMarginBackgroundColour());

	// Brace maching styles
	StyleSetBackground(34, wxColour(0x99, 0xF9, 0xFF));
	StyleSetBackground(35, wxColour(0xFF, 0xCF, 0x27));
	StyleSetFont(34, fntSQLBox);
	StyleSetFont(35, fntSQLBox);

	// SQL Lexer and keywords.
	if (sqlKeywords.IsEmpty())
		FillKeywords(sqlKeywords);
	SetLexer(wxSTC_LEX_SQL);
	SetKeyWords(0, sqlKeywords + plpgsqlKeywords + ftsKeywords + pgscriptKeywords);

	// Enable folding
	SetMarginSensitive(2, true);

	SetMarginType(2, wxSTC_MARGIN_SYMBOL); // margin 2 for symbols
	SetMarginMask(2, wxSTC_MASK_FOLDERS);  // set up mask for folding symbols
	SetMarginSensitive(2, true);           // this one needs to be mouse-aware
	SetMarginWidth(2, 16);                 // set margin 2 16 px wide

	MarkerDefine(wxSTC_MARKNUM_FOLDEREND,     wxSTC_MARK_BOXPLUSCONNECTED,  *wxWHITE, *wxBLACK);
	MarkerDefine(wxSTC_MARKNUM_FOLDEROPENMID, wxSTC_MARK_BOXMINUSCONNECTED, *wxWHITE, *wxBLACK);
	MarkerDefine(wxSTC_MARKNUM_FOLDERMIDTAIL, wxSTC_MARK_TCORNER,  *wxWHITE, *wxBLACK);
	MarkerDefine(wxSTC_MARKNUM_FOLDERTAIL,    wxSTC_MARK_LCORNER,  *wxWHITE, *wxBLACK);
	MarkerDefine(wxSTC_MARKNUM_FOLDERSUB,     wxSTC_MARK_VLINE,    *wxWHITE, *wxBLACK);
	MarkerDefine(wxSTC_MARKNUM_FOLDER,        wxSTC_MARK_BOXPLUS,  *wxWHITE, *wxBLACK);
	MarkerDefine(wxSTC_MARKNUM_FOLDEROPEN,    wxSTC_MARK_BOXMINUS, *wxWHITE, *wxBLACK);

	SetProperty(wxT("fold"), wxT("1"));
	SetFoldFlags(16);

	// Setup accelerators
	wxAcceleratorEntry entries[2];
	entries[0].Set(wxACCEL_CTRL, (int)'F', MNU_FIND);
	entries[1].Set(wxACCEL_CTRL, (int)' ', MNU_AUTOCOMPLETE);
	wxAcceleratorTable accel(2, entries);
	SetAcceleratorTable(accel);

	// Autocompletion configuration
	AutoCompSetSeparator('\t');
	AutoCompSetChooseSingle(true);
	AutoCompSetIgnoreCase(true);
	AutoCompSetFillUps(wxT(" \t"));
	AutoCompSetDropRestOfWord(true);

	SetEOLMode(settings->GetLineEndingType());
}
Example #18
0
void AsiMS2000::selectCommand(int commandNum)
{
  switch(commandNum)
  {
      case 0:
          accel();
          break;
      case 1:
          aalign();
          break;
      case 2:
          afcont();
          break;
      case 3:
          aflim();
          break;
      case 4:
          afocus();
          break;
      case 5:
          afset();
          break;
      case 6:
          afmove();
          break;
      case 7:
          ahome();
          break;
      case 8:
          aij();
          break;
      case 9:
          array();
          break;
      case 10:
          azero();
          break;
      case 11:
          backlash();
          break;
      case 12:
          bcustom();
          break;
      case 13:
          benable();
          break;
      case 14:
          build();
          break;
      case 15:
          cdate();
          break;
      case 16:
          cnts();
          break;
      case 17:
          customa();
          break;
      case 18:
          customb();
          break;
      case 19:
          dack();
          break;
      case 20:
          dump();
          break;
      case 21:
          ensync();
          break;
      case 22:
          epolarity();
          break;
      case 23:
          error();
          break;
      case 24:
          halt();
          break;
      case 25:
          here();
          break;
      case 26:
          home();
          break;
      case 27:
          info();
          break;
      case 28:
          joystick();
          break;
      case 29:
          jsspd();
          break;
      case 30:
          kadc();
          break;
      case 31:
          kd();
          break;
      case 32:
          ki();
          break;
      case 33:
          kp();
          break;
      case 34:
          lcd();
          break;
      case 35:
          led();
          break;
      case 36:
          lladdr();
          break;
      case 37:
          load();
          break;
      case 38:
          lock();
          break;
      case 39:
          lockrg();
          break;
      case 40:
          lockset();
          break;
      case 41:
          maintain();
          break;
      case 42:
          motctrl();
          break;
      case 43:
          move();
          break;
      case 44:
          movrel();
          break;
      case 45:
          pcros();
          break;
      case 46:
          pedal();
          break;
      case 47:
          rbmode();
          break;
      case 48:
          rdadc();
          break;
      case 49:
          rdsbyte();
          break;
      case 50:
          rdstat();
          break;
      case 51:
          relock();
          break;
      case 52:
          reset();
          break;
      case 53:
          rt();
          break;
      case 54:
          runaway();
          break;
      case 55:
          saveset();
          break;
      case 56:
          savepos();
          break;
      case 57:
          scan();
          break;
      case 58:
          scanr();
          break;
      case 59:
          scanv();
          break;
      case 60:
          secure();
          break;
      case 61:
          sethome();
          break;
      case 62:
          setlow();
          break;
      case 63:
          setup();
          break;
      case 64:
          si();
          break;
      case 65:
          speed();
          break;
      case 66:
          spin();
          break;
      case 67:
          status();
          break;
      case 68:
          stopbits();
          break;
      case 69:
          ttl();
          break;
      case 70:
          um();
          break;
      case 71:
          units();
          break;
      case 72:
          unlock();
          break;
      case 73:
          vb();
          break;
      case 74:
          vector();
          break;
      case 75:
          version();
          break;
      case 76:
          wait();
          break;
      case 77:
          where();
          break;
      case 78:
          who();
          break;
      case 79:
          wrdac();
          break;
      case 80:
          zero();
          break;
      case 81:
          z2b();
          break;
      case 82:
          zs();
          break;
      case 83:
          overshoot();
          break;
  }
}
Example #19
0
// Define my frame constructor
MyFrame::MyFrame()
       : wxMDIParentFrame(NULL, wxID_ANY, "wxWidgets MDI Sample",
                          wxDefaultPosition, wxSize(500, 400))
{
    SetIcon(wxICON(sample));

    // Make a menubar
#if wxUSE_MENUS
    // Associate the menu bar with the frame
    SetMenuBar(CreateMainMenubar());


    // This shows that the standard window menu may be customized:
    wxMenu * const windowMenu = GetWindowMenu();
    if ( windowMenu )
    {
        // we can change the labels of standard items (which also means we can
        // set up accelerators for them as they're part of the label)
        windowMenu->SetLabel(wxID_MDI_WINDOW_TILE_HORZ,
                             "&Tile horizontally\tCtrl-Shift-H");
        windowMenu->SetLabel(wxID_MDI_WINDOW_TILE_VERT,
                             "&Tile vertically\tCtrl-Shift-V");

        // we can also change the help string
        windowMenu->SetHelpString(wxID_MDI_WINDOW_CASCADE,
                                  "Arrange windows in cascade");

        // we can remove some items
        windowMenu->Delete(wxID_MDI_WINDOW_ARRANGE_ICONS);

        // and we can add completely custom commands -- but then we must handle
        // them ourselves, see OnCloseAll()
        windowMenu->AppendSeparator();
        windowMenu->Append(wxID_CLOSE_ALL, "&Close all windows\tCtrl-Shift-C",
                           "Close all open windows");

        SetWindowMenu(windowMenu);
    }
#endif // wxUSE_MENUS

#if wxUSE_STATUSBAR
    CreateStatusBar();
#endif // wxUSE_STATUSBAR


    m_textWindow = new wxTextCtrl(this, wxID_ANY, "A help window",
                                  wxDefaultPosition, wxDefaultSize,
                                  wxTE_MULTILINE | wxSUNKEN_BORDER);

#if wxUSE_TOOLBAR
    CreateToolBar(wxNO_BORDER | wxTB_FLAT | wxTB_HORIZONTAL);
    InitToolBar(GetToolBar());
#endif // wxUSE_TOOLBAR

#if wxUSE_ACCEL
    // Accelerators
    wxAcceleratorEntry entries[3];
    entries[0].Set(wxACCEL_CTRL, (int) 'N', wxID_NEW);
    entries[1].Set(wxACCEL_CTRL, (int) 'X', wxID_EXIT);
    entries[2].Set(wxACCEL_CTRL, (int) 'A', wxID_ABOUT);
    wxAcceleratorTable accel(3, entries);
    SetAcceleratorTable(accel);
#endif // wxUSE_ACCEL

    // connect it only now, after creating m_textWindow
    Connect(wxEVT_SIZE, wxSizeEventHandler(MyFrame::OnSize));
}
Example #20
0
AppFrame::AppFrame() :
        wxFrame(NULL, wxID_ANY, CUBICSDR_TITLE), activeDemodulator(NULL) {

#ifdef __linux__
    SetIcon(wxICON(cubicsdr));
#endif

    wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL);
    wxBoxSizer *demodVisuals = new wxBoxSizer(wxVERTICAL);
    wxBoxSizer *demodTray = new wxBoxSizer(wxHORIZONTAL);
    wxBoxSizer *demodScopeTray = new wxBoxSizer(wxVERTICAL);

    int attribList[] = { WX_GL_RGBA, WX_GL_STENCIL_SIZE, 8, WX_GL_BUFFER_SIZE, 24, WX_GL_DOUBLEBUFFER, 0 };

    demodModeSelector = new ModeSelectorCanvas(this, attribList);
    demodModeSelector->addChoice(DEMOD_TYPE_FM, "FM");
    demodModeSelector->addChoice(DEMOD_TYPE_AM, "AM");
    demodModeSelector->addChoice(DEMOD_TYPE_LSB, "LSB");
    demodModeSelector->addChoice(DEMOD_TYPE_USB, "USB");
    demodModeSelector->addChoice(DEMOD_TYPE_DSB, "DSB");
    demodModeSelector->addChoice(DEMOD_TYPE_RAW, "I/Q");
    demodModeSelector->setSelection(DEMOD_TYPE_FM);
    demodModeSelector->setHelpTip("Choose modulation type: Frequency Modulation, Amplitude Modulation and Lower, Upper or Double Side-Band.");
    demodTray->Add(demodModeSelector, 2, wxEXPAND | wxALL, 0);

//    demodTray->AddSpacer(2);

    demodSpectrumCanvas = new SpectrumCanvas(this, attribList);
    demodSpectrumCanvas->setup(1024);
    demodSpectrumCanvas->setView(wxGetApp().getConfig()->getCenterFreq(), 300000);
    demodVisuals->Add(demodSpectrumCanvas, 3, wxEXPAND | wxALL, 0);

    demodVisuals->AddSpacer(1);

    demodWaterfallCanvas = new WaterfallCanvas(this, attribList);
    demodWaterfallCanvas->setup(1024, 128);
    demodWaterfallCanvas->setView(wxGetApp().getConfig()->getCenterFreq(), 300000);
    demodWaterfallCanvas->attachSpectrumCanvas(demodSpectrumCanvas);
    demodSpectrumCanvas->attachWaterfallCanvas(demodWaterfallCanvas);
    demodVisuals->Add(demodWaterfallCanvas, 6, wxEXPAND | wxALL, 0);

    demodTray->Add(demodVisuals, 30, wxEXPAND | wxALL, 0);

    demodTray->AddSpacer(1);

    demodSignalMeter = new MeterCanvas(this, attribList);
    demodSignalMeter->setMax(0.5);
    demodSignalMeter->setHelpTip("Current Signal Level.  Click / Drag to set Squelch level.");
    demodTray->Add(demodSignalMeter, 1, wxEXPAND | wxALL, 0);

    demodTray->AddSpacer(1);

    scopeCanvas = new ScopeCanvas(this, attribList);
    demodScopeTray->Add(scopeCanvas, 8, wxEXPAND | wxALL, 0);

    demodScopeTray->AddSpacer(1);

    demodTuner = new TuningCanvas(this, attribList);
    demodTuner->setHelpTip("Testing tuner");
    demodScopeTray->Add(demodTuner, 1, wxEXPAND | wxALL, 0);

    demodTray->Add(demodScopeTray, 30, wxEXPAND | wxALL, 0);

    demodTray->AddSpacer(1);

    demodGainMeter = new MeterCanvas(this, attribList);
    demodGainMeter->setMax(2.0);
    demodGainMeter->setHelpTip("Current Demodulator Gain Level.  Click / Drag to set Gain level.");
    demodTray->Add(demodGainMeter, 1, wxEXPAND | wxALL, 0);

    vbox->Add(demodTray, 12, wxEXPAND | wxALL, 0);
    vbox->AddSpacer(1);
    spectrumCanvas = new SpectrumCanvas(this, attribList);
    spectrumCanvas->setup(2048);
    vbox->Add(spectrumCanvas, 5, wxEXPAND | wxALL, 0);
    vbox->AddSpacer(1);
    waterfallCanvas = new WaterfallCanvas(this, attribList);
    waterfallCanvas->setup(2048, 512);
    waterfallCanvas->attachSpectrumCanvas(spectrumCanvas);
    waterfallCanvas->attachWaterfallCanvas(demodWaterfallCanvas);
    spectrumCanvas->attachWaterfallCanvas(waterfallCanvas);
    vbox->Add(waterfallCanvas, 20, wxEXPAND | wxALL, 0);

    this->SetSizer(vbox);

    //    waterfallCanvas->SetFocusFromKbd();
    waterfallCanvas->SetFocus();

    //    SetIcon(wxICON(sample));

    // Make a menubar
    wxMenuBar *menuBar = new wxMenuBar;
    wxMenu *menu = new wxMenu;
    
    menu->Append(wxID_OPEN, "&Open Session");
    menu->Append(wxID_SAVE, "&Save Session");
    menu->Append(wxID_SAVEAS, "Save Session &As..");
    menu->AppendSeparator();
    menu->Append(wxID_RESET, "&Reset Session");
            
#ifndef __APPLE__
    menu->AppendSeparator();
    menu->Append(wxID_CLOSE);
#endif
            
    menuBar->Append(menu, wxT("&File"));
            
    menu = new wxMenu;
    
    menu->Append(wxID_SET_FREQ_OFFSET, "Frequency Offset");
    menu->Append(wxID_SET_PPM, "Device PPM");
    iqSwapMenuItem = menu->AppendCheckItem(wxID_SET_SWAP_IQ, "Swap I/Q");
            
    wxMenu *dsMenu = new wxMenu;
    
    directSamplingMenuItems[0] = dsMenu->AppendRadioItem(wxID_SET_DS_OFF, "Off");
    directSamplingMenuItems[1] = dsMenu->AppendRadioItem(wxID_SET_DS_I, "I-ADC");
    directSamplingMenuItems[2] = dsMenu->AppendRadioItem(wxID_SET_DS_Q, "Q-ADC");
    
    menu->AppendSubMenu(dsMenu, "Direct Sampling");

    menuBar->Append(menu, wxT("&Settings"));
            
    menu = new wxMenu;

    std::vector<RtAudio::DeviceInfo>::iterator devices_i;
    std::map<int, RtAudio::DeviceInfo>::iterator mdevices_i;
    AudioThread::enumerateDevices(devices);

    int i = 0;

    for (devices_i = devices.begin(); devices_i != devices.end(); devices_i++) {
        if (devices_i->inputChannels) {
            inputDevices[i] = *devices_i;
        }
        if (devices_i->outputChannels) {
            outputDevices[i] = *devices_i;
        }
        i++;
    }

    for (mdevices_i = outputDevices.begin(); mdevices_i != outputDevices.end(); mdevices_i++) {
        wxMenuItem *itm = menu->AppendRadioItem(wxID_RT_AUDIO_DEVICE + mdevices_i->first, mdevices_i->second.name, wxT("Description?"));
        itm->SetId(wxID_RT_AUDIO_DEVICE + mdevices_i->first);
        if (mdevices_i->second.isDefaultOutput) {
            itm->Check(true);
        }
        outputDeviceMenuItems[mdevices_i->first] = itm;
    }

    menuBar->Append(menu, wxT("Audio &Output"));

    menu = new wxMenu;

    int themeId = wxGetApp().getConfig()->getTheme();
            
    menu->AppendRadioItem(wxID_THEME_DEFAULT, "Default")->Check(themeId==COLOR_THEME_DEFAULT);
    menu->AppendRadioItem(wxID_THEME_RADAR, "RADAR")->Check(themeId==COLOR_THEME_RADAR);
    menu->AppendRadioItem(wxID_THEME_BW, "Black & White")->Check(themeId==COLOR_THEME_BW);
    menu->AppendRadioItem(wxID_THEME_SHARP, "Sharp")->Check(themeId==COLOR_THEME_SHARP);
    menu->AppendRadioItem(wxID_THEME_RAD, "Rad")->Check(themeId==COLOR_THEME_RAD);
    menu->AppendRadioItem(wxID_THEME_TOUCH, "Touch")->Check(themeId==COLOR_THEME_TOUCH);
    menu->AppendRadioItem(wxID_THEME_HD, "HD")->Check(themeId==COLOR_THEME_HD);

    menuBar->Append(menu, wxT("&Color Scheme"));

    menu = new wxMenu;
            
    sampleRateMenuItems[wxID_BANDWIDTH_250K] = menu->AppendRadioItem(wxID_BANDWIDTH_250K, "250k");
    sampleRateMenuItems[wxID_BANDWIDTH_1000M] = menu->AppendRadioItem(wxID_BANDWIDTH_1000M, "1.0M");
    sampleRateMenuItems[wxID_BANDWIDTH_1500M] = menu->AppendRadioItem(wxID_BANDWIDTH_1024M, "1.024M");
    sampleRateMenuItems[wxID_BANDWIDTH_1024M] = menu->AppendRadioItem(wxID_BANDWIDTH_1500M, "1.5M");
    sampleRateMenuItems[wxID_BANDWIDTH_1800M] = menu->AppendRadioItem(wxID_BANDWIDTH_1800M, "1.8M");
    sampleRateMenuItems[wxID_BANDWIDTH_1920M] = menu->AppendRadioItem(wxID_BANDWIDTH_1920M, "1.92M");
    sampleRateMenuItems[wxID_BANDWIDTH_2000M] = menu->AppendRadioItem(wxID_BANDWIDTH_2000M, "2.0M");
    sampleRateMenuItems[wxID_BANDWIDTH_2048M] = menu->AppendRadioItem(wxID_BANDWIDTH_2048M, "2.048M");
    sampleRateMenuItems[wxID_BANDWIDTH_2160M] = menu->AppendRadioItem(wxID_BANDWIDTH_2160M, "2.16M");
    sampleRateMenuItems[wxID_BANDWIDTH_2400M] = menu->AppendRadioItem(wxID_BANDWIDTH_2400M, "2.4M");
    sampleRateMenuItems[wxID_BANDWIDTH_2560M] = menu->AppendRadioItem(wxID_BANDWIDTH_2560M, "2.56M");
    sampleRateMenuItems[wxID_BANDWIDTH_2880M] = menu->AppendRadioItem(wxID_BANDWIDTH_2880M, "2.88M");
//    sampleRateMenuItems[wxID_BANDWIDTH_3000M] = menu->AppendRadioItem(wxID_BANDWIDTH_3000M, "3.0M");
    sampleRateMenuItems[wxID_BANDWIDTH_3200M] = menu->AppendRadioItem(wxID_BANDWIDTH_3200M, "3.2M");

    sampleRateMenuItems[wxID_BANDWIDTH_2400M]->Check(true);

    menuBar->Append(menu, wxT("&Input Bandwidth"));

    std::vector<SDRDeviceInfo *> *devs = wxGetApp().getDevices();
    std::vector<SDRDeviceInfo *>::iterator devs_i;

    if (devs->size() > 1) {

        menu = new wxMenu;

        int p = 0;
        for (devs_i = devs->begin(); devs_i != devs->end(); devs_i++) {
            std::string devName = (*devs_i)->getName();
            if ((*devs_i)->isAvailable()) {
                devName.append(": ");
                devName.append((*devs_i)->getProduct());
                devName.append(" [");
                devName.append((*devs_i)->getSerial());
                devName.append("]");
            } else {
                devName.append(" (In Use?)");
            }

            menu->AppendRadioItem(wxID_DEVICE_ID + p, devName)->Check(wxGetApp().getDevice() == p);
            p++;
        }

        menuBar->Append(menu, wxT("Input &Device"));
    }

    menu = new wxMenu;

#define NUM_RATES_DEFAULT 4
    int desired_rates[NUM_RATES_DEFAULT] = { 48000, 44100, 96000, 192000 };

    for (mdevices_i = outputDevices.begin(); mdevices_i != outputDevices.end(); mdevices_i++) {
        int desired_rate = 0;
        int desired_rank = NUM_RATES_DEFAULT + 1;

        for (std::vector<unsigned int>::iterator srate = mdevices_i->second.sampleRates.begin(); srate != mdevices_i->second.sampleRates.end();
                srate++) {
            for (i = 0; i < NUM_RATES_DEFAULT; i++) {
                if (desired_rates[i] == (*srate)) {
                    if (desired_rank > i) {
                        desired_rank = i;
                        desired_rate = (*srate);
                    }
                }
            }
        }

        if (desired_rank > NUM_RATES_DEFAULT) {
            desired_rate = mdevices_i->second.sampleRates.back();
        }
        AudioThread::deviceSampleRate[mdevices_i->first] = desired_rate;
    }

    for (mdevices_i = outputDevices.begin(); mdevices_i != outputDevices.end(); mdevices_i++) {
        new wxMenu;
        int menu_id = wxID_AUDIO_BANDWIDTH_BASE + wxID_AUDIO_DEVICE_MULTIPLIER * mdevices_i->first;
        wxMenu *subMenu = new wxMenu;
        menu->AppendSubMenu(subMenu, mdevices_i->second.name, wxT("Description?"));

        int j = 0;
        for (std::vector<unsigned int>::iterator srate = mdevices_i->second.sampleRates.begin(); srate != mdevices_i->second.sampleRates.end();
                srate++) {
            std::stringstream srateName;
            srateName << ((float) (*srate) / 1000.0f) << "kHz";
            wxMenuItem *itm = subMenu->AppendRadioItem(menu_id + j, srateName.str(), wxT("Description?"));

            if ((*srate) == AudioThread::deviceSampleRate[mdevices_i->first]) {
                itm->Check(true);
            }
            audioSampleRateMenuItems[menu_id + j] = itm;

            j++;
        }
    }

    menuBar->Append(menu, wxT("Audio &Bandwidth"));

    SetMenuBar(menuBar);

    CreateStatusBar();

    wxRect *win = wxGetApp().getConfig()->getWindow();
    if (win) {
        this->SetPosition(win->GetPosition());
        this->SetClientSize(win->GetSize());
    } else {
        SetClientSize(1280, 600);
        Centre();
    }
    bool max = wxGetApp().getConfig()->getWindowMaximized();

    if (max) {
        this->Maximize();
    }

    long long freqSnap = wxGetApp().getConfig()->getSnap();
    wxGetApp().setFrequencySnap(freqSnap);
            
    ThemeMgr::mgr.setTheme(wxGetApp().getConfig()->getTheme());

    Show();

#ifdef _WIN32
    SetIcon(wxICON(frame_icon));
#endif

    wxAcceleratorEntry entries[3];
    entries[0].Set(wxACCEL_CTRL, (int) 'O', wxID_OPEN);
    entries[1].Set(wxACCEL_CTRL, (int) 'S', wxID_SAVE);
    entries[2].Set(wxACCEL_CTRL, (int) 'A', wxID_SAVEAS);

    wxAcceleratorTable accel(3, entries);
    SetAcceleratorTable(accel);

//    static const int attribs[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, 0 };
//    wxLogStatus("Double-buffered display %s supported", wxGLCanvas::IsDisplaySupported(attribs) ? "is" : "not");
//    ShowFullScreen(true);
}
Example #21
0
/**
 * @brief Creates an XsOutputConfigurationArray and pushes it to the sensor.
 * @details
 * - Configures the sensor with desired modules
 * - Refer to xsdataidentifier.h
 */
void mtiG::configure(){

	XsOutputConfigurationArray configArray;

	if(mSettings.orientationData){			//Quaternion - containsOrientation
			XsOutputConfiguration quat(XDI_Quaternion, mSettings.orientationFreq);// para pedir quaternion
			configArray.push_back(quat);
	}
	
	if(mSettings.gpsData){
			//LATITUDE E LONGITUDE -containsLatitudeLongitude
			XsOutputConfiguration gps(XDI_LatLon, mSettings.gpsFreq);// para pedir gps, //XDI_Quaternion 06/04
			configArray.push_back(gps);

			XsOutputConfiguration gps_age(XDI_GpsAge, mSettings.gpsFreq);// para pedir gps, //XDI_Quaternion 06/04
			configArray.push_back(gps_age);

			XsOutputConfiguration gps_sol(XDI_GpsSol, mSettings.gpsFreq);// para pedir gps, //XDI_Quaternion 06/04
			configArray.push_back(gps_sol);

			XsOutputConfiguration gps_dop(XDI_GpsDop, mSettings.gpsFreq);// para pedir gps, //XDI_Quaternion 06/04
			configArray.push_back(gps_dop);
	}
	
	if(mSettings.temperatureData){	
			//TEMPERATURA - containsTemperature
			XsOutputConfiguration temp(XDI_Temperature, mSettings.temperatureFreq);
			configArray.push_back(temp);
	}	
	
	if(mSettings.accelerationData){
			//ACCELERATION - containsCalibratedAcceleration
			XsOutputConfiguration accel(XDI_Acceleration, mSettings.accelerationFreq);
			configArray.push_back(accel);
	}

	if(mSettings.pressureData){	
			//PRESSURE - containsPressure
			XsOutputConfiguration baro(XDI_BaroPressure, mSettings.pressureFreq);
			configArray.push_back(baro);
	}

	if(mSettings.magneticData){
			//MAGNETIC FIELD - containsCalibratedMagneticField
			XsOutputConfiguration magnet(XDI_MagneticField, mSettings.magneticFreq);
			configArray.push_back(magnet);
	}

	if(mSettings.altitudeData){
			//ALTITUDE - containsAltitude
			XsOutputConfiguration alt(XDI_AltitudeEllipsoid, mSettings.altitudeFreq);
			configArray.push_back(alt);
	}

	if(mSettings.gyroscopeData){
			//GYRO - containsCalibratedGyroscopeData
			XsOutputConfiguration gyro(XDI_RateOfTurn, mSettings.gyroscopeFreq);
			configArray.push_back(gyro);
	}	

	if(mSettings.velocityData){
			//VELOCIDADE XYZ
			XsOutputConfiguration vel_xyz(XDI_VelocityXYZ, mSettings.velocityFreq);
			configArray.push_back(vel_xyz);
	}
	
	// Puts configArray into the device, overwriting the current configuration
	if (!device->setOutputConfiguration(configArray))
	{
			throw std::runtime_error("Could not configure MTmk4 device. Aborting.");
	}
}
Example #22
0
void
main_loop (void)
{
  struct timeval tv;
  fd_set rfds;
  int retval;
  struct js_event event;

  char buf[2048];
  int type;
  double value;
  int num;

  /* Wait up to one seconds. */
  tv.tv_sec = 1;
  tv.tv_usec = 0;

  while (1)
    {
      FD_ZERO (&rfds);
      FD_SET (0, &rfds);
      FD_SET (joy_fd, &rfds);
      retval = select (6, &rfds, NULL, NULL, &tv);

      if (FD_ISSET (joy_fd, &rfds))
	{
	  read (joy_fd, &event, sizeof (struct js_event));
	  switch (event.type)
	    {

	    case JS_EVENT_BUTTON:
	      switch (event.number)
		{
		case 0:	/* brake */
		  if (event.value)	/* pressed */
		    brake_on ();
		  else		/* released */
		    brake_off ();
		  break;
		case 1:
		  if (event.value)	/* pressed */
		    shoot ();
		  break;
		case 2:	/* shoot */
		  /* do something if your joypad has button 3 */
		  break;
		case 3:
		  /* do something if your joypad has button 4 */
		  break;
		default:
		  break;	/* do nothing */
		}
	      break;
	    case JS_EVENT_AXIS:
	      switch (event.number)
		{
		case 0:	/* right/left */
		  turn (event.value);
		  break;
		case 1:	/* down/up */
		  accel (event.value);
		  break;
		default:
		  /* do nothing */
		  break;
		}
	      break;
	    default:
	      break;
	    }
	}
      else if (FD_ISSET (0, &rfds))	/* message from RTB */
	{
	  fgets (buf, 2048, stdin);
	  if (strncmp (buf, "Initialize", 10) == 0)
	    {
	      sscanf (buf, "Initialize %i", &num);
	      initialize (num);
	    }
	  else if (strncmp (buf, "GameOption", 10) == 0)
	    {
	      sscanf (buf, "GameOption %i %lf", &type, &value);
	      gameoption (type, value);

	    }
	  else if (strncmp (buf, "Dead", 4) == 0)
	    {
	      break;
	    }
	}
      else
	{
	  idle ();
	}
      fflush (stdout);
    }
}
Example #23
0
int CollocationHSIncrLimit::domainChanged()
{
    AnalysisModel *myModel = this->getAnalysisModel();
    LinearSOE *theLinSOE = this->getLinearSOE();
    const Vector &x = theLinSOE->getX();
    int size = x.Size();
    
    // if damping factors exist set them in the ele & node of the domain
    if (alphaM != 0.0 || betaK != 0.0 || betaKi != 0.0 || betaKc != 0.0)
        myModel->setRayleighDampingFactors(alphaM, betaK, betaKi, betaKc);
    
    // create the new Vector objects
    if (Ut == 0 || Ut->Size() != size)  {
        
        // delete the old
        if (Ut != 0)
            delete Ut;
        if (Utdot != 0)
            delete Utdot;
        if (Utdotdot != 0)
            delete Utdotdot;
        if (U != 0)
            delete U;
        if (Udot != 0)
            delete Udot;
        if (Udotdot != 0)
            delete Udotdot;
        if (scaledDeltaU != 0)
            delete scaledDeltaU;
        
        // create the new
        Ut = new Vector(size);
        Utdot = new Vector(size);
        Utdotdot = new Vector(size);
        U = new Vector(size);
        Udot = new Vector(size);
        Udotdot = new Vector(size);
        scaledDeltaU = new Vector(size);
        
        // check we obtained the new
        if (Ut == 0 || Ut->Size() != size ||
            Utdot == 0 || Utdot->Size() != size ||
            Utdotdot == 0 || Utdotdot->Size() != size ||
            U == 0 || U->Size() != size ||
            Udot == 0 || Udot->Size() != size ||
            Udotdot == 0 || Udotdot->Size() != size ||
            scaledDeltaU == 0 || scaledDeltaU->Size() != size)  {
            
            opserr << "CollocationHSIncrLimit::domainChanged - ran out of memory\n";
            
            // delete the old
            if (Ut != 0)
                delete Ut;
            if (Utdot != 0)
                delete Utdot;
            if (Utdotdot != 0)
                delete Utdotdot;
            if (U != 0)
                delete U;
            if (Udot != 0)
                delete Udot;
            if (Udotdot != 0)
                delete Udotdot;
            if (scaledDeltaU != 0)
                delete scaledDeltaU;
            
            Ut = 0; Utdot = 0; Utdotdot = 0;
            U = 0; Udot = 0; Udotdot = 0;
            scaledDeltaU = 0;
            
            return -1;
        }
    }        
    
    // now go through and populate U, Udot and Udotdot by iterating through
    // the DOF_Groups and getting the last committed velocity and accel
    DOF_GrpIter &theDOFs = myModel->getDOFs();
    DOF_Group *dofPtr;
    while ((dofPtr = theDOFs()) != 0)  {
        const ID &id = dofPtr->getID();
        int idSize = id.Size();
        
        int i;
        const Vector &disp = dofPtr->getCommittedDisp();	
        for (i=0; i < idSize; i++)  {
            int loc = id(i);
            if (loc >= 0)  {
                (*U)(loc) = disp(i);		
            }
        }
        
        const Vector &vel = dofPtr->getCommittedVel();
        for (i=0; i < idSize; i++)  {
            int loc = id(i);
            if (loc >= 0)  {
                (*Udot)(loc) = vel(i);
            }
        }
        
        const Vector &accel = dofPtr->getCommittedAccel();	
        for (i=0; i < idSize; i++)  {
            int loc = id(i);
            if (loc >= 0)  {
                (*Udotdot)(loc) = accel(i);
            }
        }        
    }    
    
    return 0;
}
Example #24
0
      /* Compute satellite position & velocity at the given time
       * using this ephemeris.
       *
       *  @throw InvalidRequest if required data has not been stored.
       */
   Xvt GloEphemeris::svXvt(const CommonTime& epoch) const
      throw( gpstk::InvalidRequest )
   {

         // Check that the given epoch is within the available time limits.
         // We have to add a margin of 15 minutes (900 seconds).
      if ( epoch <  (ephTime - 900.0) ||
           epoch >= (ephTime + 900.0)   )
      {
         InvalidRequest e( "Requested time is out of ephemeris data" );
         GPSTK_THROW(e);
      }

         // Values to be returned will be stored here
      Xvt sv;

         // If the exact epoch is found, let's return the values
      if ( epoch == ephTime )       // exact match for epoch
      {

         sv.x[0] = x[0]*1.e3;   // m
         sv.x[1] = x[1]*1.e3;   // m
         sv.x[2] = x[2]*1.e3;   // m
         sv.v[0] = v[0]*1.e3;  // m/sec
         sv.v[1] = v[1]*1.e3;  // m/sec
         sv.v[2] = v[2]*1.e3;  // m/sec

            // In the GLONASS system, 'clkbias' already includes the
            // relativistic correction, therefore we must substract the late
            // from the former.
         sv.relcorr = sv.computeRelativityCorrection();
         sv.clkbias = clkbias + clkdrift * (epoch - ephTime) - sv.relcorr;
         sv.clkdrift = clkdrift;
         sv.frame = ReferenceFrame::PZ90;

            // We are done, let's return
         return sv;

      }

         // Get the data out of the GloRecord structure
      double px( x[0] );   // X coordinate (km)
      double vx( v[0] );   // X velocity   (km/s)
      double ax( a[0] );   // X acceleration (km/s^2)
      double py( x[1] );   // Y coordinate
      double vy( v[1] );   // Y velocity
      double ay( a[1] );   // Y acceleration
      double pz( x[2] );   // Z coordinate
      double vz( v[2] );   // Z velocity
      double az( a[2] );   // Z acceleration

         // We will need some PZ-90 ellipsoid parameters
      PZ90Ellipsoid pz90;
      double we( pz90.angVelocity() );

         // Get sidereal time at Greenwich at 0 hours UT
      double gst( getSidTime( ephTime ) );
      double s0( gst*PI/12.0 );
      YDSTime ytime( ephTime );
      double numSeconds( ytime.sod );
      double s( s0 + we*numSeconds );
      double cs( std::cos(s) );
      double ss( std::sin(s) );

         // Initial state matrix
      Vector<double> initialState(6), accel(3), dxt1(6), dxt2(6), dxt3(6),
                     dxt4(6), tempRes(6);

         // Get the reference state out of GloEphemeris object data. Values
         // must be rotated from PZ-90 to an absolute coordinate system
         // Initial x coordinate (m)
      initialState(0)  = (px*cs - py*ss);
         // Initial y coordinate
      initialState(2)  = (px*ss + py*cs);
         // Initial z coordinate
      initialState(4)  = pz;

         // Initial x velocity   (m/s)
      initialState(1)  = (vx*cs - vy*ss - we*initialState(2) );
         // Initial y velocity
      initialState(3)  = (vx*ss + vy*cs + we*initialState(0) );
         // Initial z velocity
      initialState(5)  = vz;


         // Integrate satellite state to desired epoch using the given step
      double rkStep( step );

      if ( (epoch - ephTime) < 0.0 ) rkStep = step*(-1.0);
      CommonTime workEpoch( ephTime );

      double tolerance( 1e-9 );
      bool done( false );
      while (!done)
      {

            // If we are about to overstep, change the stepsize appropriately
            // to hit our target final time.
         if( rkStep > 0.0 )
         {
            if( (workEpoch + rkStep) > epoch )
               rkStep = (epoch - workEpoch);
         }
         else
         {
            if ( (workEpoch + rkStep) < epoch )
               rkStep = (epoch - workEpoch);
         }

         numSeconds += rkStep;
         s = s0 + we*( numSeconds );
         cs = std::cos(s);
         ss = std::sin(s);

            // Accelerations are computed once per iteration
         accel(0) = ax*cs - ay*ss;
         accel(1) = ax*ss + ay*cs;
         accel(2) = az;

         dxt1 = derivative( initialState, accel );
         for( int j = 0; j < 6; ++j )
            tempRes(j) = initialState(j) + rkStep*dxt1(j)/2.0;

         dxt2 = derivative( tempRes, accel );
         for( int j = 0; j < 6; ++j )
            tempRes(j) = initialState(j) + rkStep*dxt2(j)/2.0;

         dxt3 = derivative( tempRes, accel );
         for( int j = 0; j < 6; ++j )
            tempRes(j) = initialState(j) + rkStep*dxt3(j);

         dxt4 = derivative( tempRes, accel );
         for( int j = 0; j < 6; ++j )
            initialState(j) = initialState(j) + rkStep * ( dxt1(j)
                            + 2.0 * ( dxt2(j) + dxt3(j) ) + dxt4(j) ) / 6.0;


            // If we are within tolerance of the target time, we are done.
         workEpoch += rkStep;
         if ( std::fabs(epoch - workEpoch ) < tolerance )
            done = true;

      }  // End of 'while (!done)...'


      px = initialState(0);
      py = initialState(2);
      pz = initialState(4);
      vx = initialState(1);
      vy = initialState(3);
      vz = initialState(5);

      sv.x[0] = 1000.0*( px*cs + py*ss );         // X coordinate
      sv.x[1] = 1000.0*(-px*ss + py*cs);          // Y coordinate
      sv.x[2] = 1000.0*pz;                        // Z coordinate
      sv.v[0] = 1000.0*( vx*cs + vy*ss + we*(sv.x[1]/1000.0) ); // X velocity
      sv.v[1] = 1000.0*(-vx*ss + vy*cs - we*(sv.x[0]/1000.0) ); // Y velocity
      sv.v[2] = 1000.0*vz;                        // Z velocity

         // In the GLONASS system, 'clkbias' already includes the relativistic
         // correction, therefore we must substract the late from the former.
      sv.relcorr = sv.computeRelativityCorrection();
      sv.clkbias = clkbias + clkdrift * (epoch - ephTime) - sv.relcorr;
      sv.clkdrift = clkdrift;
      sv.frame = ReferenceFrame::PZ90;

         // We are done, let's return
      return sv;


   }  // End of method 'GloEphemeris::svXvt(const CommonTime& t)'
const Vector&  Twenty_Node_Brick::getResistingForceIncInertia( )

{

	static Vector res(60);



//	printf("getResistingForceIncInertia()\n");



	int i, j, ik;

	static double a[60];



	for (i=0; i<nenu; i++) {

		const Vector &accel = nodePointers[i]->getTrialAccel();

		if ( 3 != accel.Size() ) {

			opserr << "Twenty_Node_Brick::getResistingForceIncInertia matrix and vector sizes are incompatable\n";

			exit(-1);

		}



		a[i*3] = accel(0);

		a[i*3+1] = accel(1);

		a[i*3+2] = accel(2);

	}

	// Compute the current resisting force

	this->getResistingForce();

//	opserr<<"K "<<resid<<endln;



	// Compute the mass matrix

	this->getMass();



	for (i = 0; i < 60; i++) {

		for (j = 0; j < 60; j++){

			resid(i) += mass(i,j)*a[j];

		}

	}

//	printf("\n");

	//opserr<<"K+M "<<P<<endln;





	for (i=0; i<nenu; i++) {

		const Vector &vel = nodePointers[i]->getTrialVel();

		if ( 3!= vel.Size() ) {

			opserr << "Twenty_Node_Brick::getResistingForceIncInertia matrix and vector sizes are incompatable\n";

			exit(-1);

		}

		a[i*3] = vel(0);

		a[i*3+1] = vel(1);

		a[i*3+2] = vel(2);

	}



	this->getDamp();



	for (i = 0; i < 60; i++) {

		for (j = 0; j < 60; j++) {

			resid(i) += damp(i,j)*a[j];

		}

	}

//	opserr<<"Pd"<<Pd<<endln;



	res = resid;

//	opserr<<"res "<<res<<endln;



//	exit(-1);

	return res;

}
Example #26
0
int main()
{
	//configure display pins as outputs
	DDRA |= 0x7F;
	//instantiate shift register (for controlling display)
	// clock - PA2
	// latch - PA1
	// data - PA0
	Shift595 myshift(0x04, 0x02, 0x01, PORTA);

	//instantiate accelerometer
	// chip select - PB2
	// clock - PB0
	// data (SDIO) - PB1
	MMA7455 accel(0x04, 0x01, 0x02, PORTB);
	
	//configure the accelerometer to measure continuously,
	//  ranging from +/-2G of acceleration, using 3 wire SPI
	accel.setMode(_MEASUREMENT | _2g | _SPI3W | _DRPD);

	//calibrate accelerometer
	accel.setOffset(_X, 12);

	//average 8 samples before displaying
	const int samples = 8;
	//pins for display common cathodes (PORTA)
	const uint8_t colenable[] = { 0x08, 0x10, 0x20, 0x40 }; 
	float xsample;
	float zsample;
	float dval;
	float absdv;
	uint8_t disps[4];
	while(true)
	{
		xsample = 0;
		zsample = 0;
		for(uint16_t x=0; x<samples; x++)
		{
			//take the sum of the samples
			xsample += accel.getRoughAccelF(_X);
			zsample += accel.getRoughAccelF(_Z);
			if(x == samples - 1)
			{
				//convert the sum of samples into an average (arithmetic mean)
				xsample /= samples;
				zsample /= samples;

				//convert the average acceleration in X, Z to an angle relative
				// to vertical 
				float newval = asin( xsample / 
						sqrt(zsample * zsample + xsample * xsample)
						) * 180 / M_PI ; 

				//fix the sign of the angle
				newval *= xsample / abs(xsample);

				//store the angle's character representation for easy displaying
				dval = newval;
				absdv = abs(dval);
				disps[0] = xsample < 0 ? 0x02 : 0;
				disps[1] = SEGDIGITS[(int)(absdv /  10) % 10];
				disps[2] = SEGDIGITS[(int)(absdv *   1) % 10] | 0x01;
				disps[3] = SEGDIGITS[(int)(absdv *  10) % 10];
			}
			for(uint8_t z=0; z<32; z++)
				for(uint8_t i=0; i<4 ; i++)
				{
					//turn off all digits
					PORTA = PORTA & 0x87;

					//shift out the i'th character display code
					myshift = ~disps[i];

					//turn on the i'th digit
					PORTA = (PORTA & 0x87) | colenable[i];

					//wait a bit
					_delay_ms(2);
				}
		}
	}
}
Example #27
0
//------------------------------------------------------
//------------------------------------------------------
//------------------------------------------------------
void debug_hyst(const QUESO::FullEnvironment& env) {
  unsigned int numFloors = 4;
  unsigned int numTimeSteps = 401;

  std::vector<double> accel(numTimeSteps,0.);
  FILE *inp;
  inp = fopen("an.txt","r");
  unsigned int numObservations = 0;
  double tmpA;
  while (fscanf(inp,"%lf",&tmpA) != EOF) {
    UQ_FATAL_TEST_MACRO((numObservations >= accel.size()),
                        env.fullRank(),
                        "debug_hyst()",
                        "input file has too many lines");
    accel[numObservations] = tmpA;
    numObservations++;
  }
  UQ_FATAL_TEST_MACRO((numObservations != accel.size()),
                      env.fullRank(),
                      "debug_hyst()",
                      "input file has a smaller number of observations than expected");

  QUESO::VectorSpace<> floorSpace(env, "floor_", numFloors, NULL);

  QUESO::GslVector kVec(floorSpace.zeroVector());
  kVec[0] = 2.20e+7;
  kVec[1] = 2.00e+7;
  kVec[2] = 1.70e+7;
  kVec[3] = 1.45e+7;

  QUESO::GslVector rVec(floorSpace.zeroVector());
  rVec[0] = 0.1;
  rVec[1] = 0.1;
  rVec[2] = 0.1;
  rVec[3] = 0.1;

  QUESO::GslVector uVec(floorSpace.zeroVector());
  uVec[0] = 0.008;
  uVec[1] = 0.008;
  uVec[2] = 0.007;
  uVec[3] = 0.007;

  double rho   = 7.959e-1 ;//0.1976;
  double gamma = 2.500e-3 ; //0.0038;

  std::vector<double> t(numTimeSteps,0.);
  QUESO::SequenceOfVectors<> u     (floorSpace,numTimeSteps,""); // absolute displacement
  QUESO::SequenceOfVectors<> ud    (floorSpace,numTimeSteps,""); // velocity
  QUESO::SequenceOfVectors<> udd   (floorSpace,numTimeSteps,""); // acceleration
  QUESO::SequenceOfVectors<> resfor(floorSpace,numTimeSteps,""); // restoring force
  QUESO::SequenceOfVectors<> ru    (floorSpace,numTimeSteps,""); // relative displacement

  u.setPositionValues     (0,floorSpace.zeroVector());
  ud.setPositionValues    (0,floorSpace.zeroVector());
  udd.setPositionValues   (0,floorSpace.zeroVector());
  resfor.setPositionValues(0,floorSpace.zeroVector());
  ru.setPositionValues    (0,floorSpace.zeroVector());

  QUESO::GslVector massVec(floorSpace.zeroVector());
  massVec.cwSet(2.0e+4);

  hystereticModel(env,
                  massVec,
                  kVec,
                  rVec,
                  uVec,
                  rho,
                  gamma,
                  accel,
                  t, // output
                  u,
                  ud,
                  udd,
                  resfor,
                  ru);

  std::set<unsigned int> auxSet;
  auxSet.insert(0);

  // Writing some data to the file 'outputData/cpp_output.m'
  std::ofstream myFile;
  myFile.open ("outputData/cpp_output.m");

  // Write 't_cpp'
  myFile << "t_cpp = zeros(" << 1 << "," << numTimeSteps << ");\n"
          << "t_cpp = [";
  for (unsigned int j = 0; j < numTimeSteps; ++j) {
    myFile << t[j] << " ";
  }
  myFile << "];" << std::endl;

  // Write 'a_cpp'
  myFile << "a_cpp = zeros(" << 1 << "," << numTimeSteps << ");\n"
          << "a_cpp = [";
  for (unsigned int j = 0; j < numTimeSteps; ++j) {
    myFile << accel[j] << " ";
  }
  myFile << "];" << std::endl;

  QUESO::GslVector auxVec(floorSpace.zeroVector());

  // Write 'u_cpp'
  myFile << "u_cpp = zeros(" << numFloors << "," << numTimeSteps << ");\n"
          << "u_cpp = [";
  for (unsigned int i = 0; i < numFloors; ++i) {
    for (unsigned int j = 0; j < numTimeSteps; ++j) {
      u.getPositionValues(j,auxVec);
      myFile << auxVec[i] << " ";
    }
    myFile << std::endl;
  }
  myFile << "];" << std::endl;

  // Write 'ud_cpp'
  myFile << "ud_cpp = zeros(" << numFloors << "," << numTimeSteps << ");\n"
          << "ud_cpp = [";
  for (unsigned int i = 0; i < numFloors; ++i) {
    for (unsigned int j = 0; j < numTimeSteps; ++j) {
      ud.getPositionValues(j,auxVec);
      myFile << auxVec[i] << " ";
    }
    myFile << std::endl;
  }
  myFile << "];" << std::endl;

  // Write 'udd_cpp'
  myFile << "udd_cpp = zeros(" << numFloors << "," << numTimeSteps << ");\n"
          << "udd_cpp = [";
  for (unsigned int i = 0; i < numFloors; ++i) {
    for (unsigned int j = 0; j < numTimeSteps; ++j) {
      udd.getPositionValues(j,auxVec);
      myFile << auxVec[i] << " ";
    }
    myFile << std::endl;
  }
  myFile << "];" << std::endl;

  // Write 'resfor_cpp'
  myFile << "resfor_cpp = zeros(" << numFloors << "," << numTimeSteps << ");\n"
          << "resfor_cpp = [";
  for (unsigned int i = 0; i < numFloors; ++i) {
    for (unsigned int j = 0; j < numTimeSteps; ++j) {
      resfor.getPositionValues(j,auxVec);
      myFile << auxVec[i] << " ";
    }
    myFile << std::endl;
  }
  myFile << "];" << std::endl;

  // Write 'ru_cpp'
  myFile << "ru_cpp = zeros(" << numFloors << "," << numTimeSteps << ");\n"
          << "ru_cpp = [";
  for (unsigned int i = 0; i < numFloors; ++i) {
    for (unsigned int j = 0; j < numTimeSteps; ++j) {
      ru.getPositionValues(j,auxVec);
      myFile << auxVec[i] << " ";
    }
    myFile << std::endl;
  }
  myFile << "];" << std::endl;

  myFile.close();

  return;
}
Example #28
0
void KPopupMenu::keyPressEvent(QKeyEvent* e)
{
    if (!d->shortcuts) {
        // continue event processing by Qpopup
        //e->ignore();
        QPopupMenu::keyPressEvent(e);
        return;
    }

    int i = 0;
    bool firstpass = true;
    QString keyString = e->text();

    // check for common commands dealt with by QPopup
    int key = e->key();
    if (key == Key_Escape || key == Key_Return || key == Key_Enter
            || key == Key_Up || key == Key_Down || key == Key_Left
            || key == Key_Right || key == Key_F1) {

        resetKeyboardVars();
        // continue event processing by Qpopup
        //e->ignore();
        QPopupMenu::keyPressEvent(e);
        return;
    }

    // check to see if the user wants to remove a key from the sequence (backspace)
    // or clear the sequence (delete)
    if (d->keySeq != QString::null) {

        if (key == Key_Backspace) {

            if (d->keySeq.length() == 1) {
                resetKeyboardVars();
                return;
            }

            // keep the last sequence in keyString
            keyString = d->keySeq.left(d->keySeq.length() - 1);

            // allow sequence matching to be tried again
            resetKeyboardVars();

        } else if (key == Key_Delete) {
            resetKeyboardVars();

            // clear active item
            setActiveItem(0);
            return;

        } else if (d->noMatches) {
            // clear if there are no matches
            resetKeyboardVars();

            // clear active item
            setActiveItem(0);

        } else {
            // the key sequence is not a null string
            // therefore the lastHitIndex is valid
            i = d->lastHitIndex;
        }
    } else if (key == Key_Backspace && parentMenu) {
        // backspace with no chars in the buffer... go back a menu.
        hide();
        resetKeyboardVars();
        return;
    }

    d->keySeq += keyString;
    int seqLen = d->keySeq.length();

    for (; i < (int)count(); i++) {
        // compare typed text with text of this entry
        int j = idAt(i);

        // don't search disabled entries
        if (!isItemEnabled(j))
            continue;

        QString thisText;

        // retrieve the right text
        // (the last selected item one may have additional ampersands)
        if (i == d->lastHitIndex)
            thisText = d->originalText;
        else
            thisText = text(j);

        // if there is an accelerator present, remove it
        if ((int)accel(j) != 0)
            thisText = thisText.replace(QRegExp("&"), "");

        // chop text to the search length
        thisText = thisText.left(seqLen);

        // do the search
        if (thisText.find(d->keySeq, 0, false) == 0) {

            if (firstpass) {
                // match
                setActiveItem(i);

                // check to see if we're underlining a different item
                if (d->lastHitIndex != i)
                    // yes; revert the underlining
                    changeItem(idAt(d->lastHitIndex), d->originalText);

                // set the original text if it's a different item
                if (d->lastHitIndex != i || d->lastHitIndex == -1)
                    d->originalText = text(j);

                // underline the currently selected item
                changeItem(j, underlineText(d->originalText, d->keySeq.length()));

                // remeber what's going on
                d->lastHitIndex = i;

                // start/restart the clear timer
                d->clearTimer.start(5000, true);

                // go around for another try, to see if we can execute
                firstpass = false;
            } else {
                // don't allow execution
                return;
            }
        }

        // fall through to allow execution
    }

    if (!firstpass) {
        if (d->autoExec) {
            // activate anything
            activateItemAt(d->lastHitIndex);
            resetKeyboardVars();

        } else if (findItem(idAt(d->lastHitIndex)) &&
                   findItem(idAt(d->lastHitIndex))->popup()) {
            // only activate sub-menus
            activateItemAt(d->lastHitIndex);
            resetKeyboardVars();
        }

        return;
    }

    // no matches whatsoever, clean up
    resetKeyboardVars(true);
    //e->ignore();
    QPopupMenu::keyPressEvent(e);
}
dgFloat32 dgWorldDynamicUpdate::CalculateJointForceDanzig(const dgJointInfo* const jointInfo, const dgBodyInfo* const bodyArray, dgJacobian* const internalForces, dgJacobianMatrixElement* const matrixRow, dgFloat32 restAcceleration) const
{
	dgFloat32 massMatrix[DG_CONSTRAINT_MAX_ROWS * DG_CONSTRAINT_MAX_ROWS];
	dgFloat32 f[DG_CONSTRAINT_MAX_ROWS];
	dgFloat32 b[DG_CONSTRAINT_MAX_ROWS];
	dgFloat32 low[DG_CONSTRAINT_MAX_ROWS];
	dgFloat32 high[DG_CONSTRAINT_MAX_ROWS];
	dgFloat32 cacheForce[DG_CONSTRAINT_MAX_ROWS + 4];

	const dgInt32 m0 = jointInfo->m_m0;
	const dgInt32 m1 = jointInfo->m_m1;
	
	cacheForce[0] = dgFloat32(1.0f);
	cacheForce[1] = dgFloat32(1.0f);
	cacheForce[2] = dgFloat32(1.0f);
	cacheForce[3] = dgFloat32(1.0f);
	dgFloat32* const normalForce = &cacheForce[4];

	const dgInt32 index = jointInfo->m_pairStart;
	const dgInt32 rowsCount = jointInfo->m_pairCount;

	dgAssert (rowsCount <= DG_CONSTRAINT_MAX_ROWS);

	dgVector accNorm(dgVector::m_zero);
	for (dgInt32 i = 0; i < rowsCount; i++) {

		const dgJacobianMatrixElement* const row_i = &matrixRow[index + i];
		dgFloat32* const massMatrixRow = &massMatrix[rowsCount * i];

		dgJacobian JMinvM0(row_i->m_JMinv.m_jacobianM0);
		dgJacobian JMinvM1(row_i->m_JMinv.m_jacobianM1);
		dgVector diag(JMinvM0.m_linear * row_i->m_Jt.m_jacobianM0.m_linear + JMinvM0.m_angular * row_i->m_Jt.m_jacobianM0.m_angular +
					  JMinvM1.m_linear * row_i->m_Jt.m_jacobianM1.m_linear + JMinvM1.m_angular * row_i->m_Jt.m_jacobianM1.m_angular);

		diag = diag.AddHorizontal();
		dgFloat32 val = diag.GetScalar() + row_i->m_diagDamp;
		dgAssert(val > dgFloat32(0.0f));
		massMatrixRow[i] = val;

		for (dgInt32 j = i + 1; j < rowsCount; j++) {
			const dgJacobianMatrixElement* const row_j = &matrixRow[index + j];

			dgVector offDiag(JMinvM0.m_linear * row_j->m_Jt.m_jacobianM0.m_linear + JMinvM0.m_angular * row_j->m_Jt.m_jacobianM0.m_angular +
							 JMinvM1.m_linear * row_j->m_Jt.m_jacobianM1.m_linear + JMinvM1.m_angular * row_j->m_Jt.m_jacobianM1.m_angular);
			offDiag = offDiag.AddHorizontal();
			dgFloat32 val1 = offDiag.GetScalar();
			massMatrixRow[j] = val1;
			massMatrix[j * rowsCount + i] = val1;
		}
	}

	const dgJacobian& y0 = internalForces[m0];
	const dgJacobian& y1 = internalForces[m1];
	for (dgInt32 i = 0; i < rowsCount; i++) {
		const dgJacobianMatrixElement* const row = &matrixRow[index + i];

		dgJacobian JMinvM0(row->m_JMinv.m_jacobianM0);
		dgJacobian JMinvM1(row->m_JMinv.m_jacobianM1);
		dgVector diag(JMinvM0.m_linear * y0.m_linear + JMinvM0.m_angular * y0.m_angular +
					  JMinvM1.m_linear * y1.m_linear + JMinvM1.m_angular * y1.m_angular);
		dgVector accel(row->m_coordenateAccel - row->m_force * row->m_diagDamp - (diag.AddHorizontal()).GetScalar());
		
		dgInt32 frictionIndex = row->m_normalForceIndex;
		dgAssert(((frictionIndex < 0) && (normalForce[frictionIndex] == dgFloat32(1.0f))) || ((frictionIndex >= 0) && (normalForce[frictionIndex] >= dgFloat32(0.0f))));
		normalForce[i] = row->m_force;
		dgFloat32 frictionNormal = normalForce[frictionIndex];
		dgFloat32 lowerFrictionForce = frictionNormal * row->m_lowerBoundFrictionCoefficent;
		dgFloat32 upperFrictionForce = frictionNormal * row->m_upperBoundFrictionCoefficent;

		//f[i] = row->m_force;
		f[i] = dgFloat32 (0.0f);
		b[i] = accel.GetScalar();
		low[i] = lowerFrictionForce - row->m_force;
		high[i] = upperFrictionForce - row->m_force;

		dgVector force(row->m_force + row->m_invJMinvJt * accel.GetScalar());
		accel = accel.AndNot((force > upperFrictionForce) | (force < lowerFrictionForce));
		accNorm = accNorm.GetMax(accel.Abs());
	}

	dgSolveDantzigLCP(rowsCount, massMatrix, f, b, low, high);

	dgVector linearM0(internalForces[m0].m_linear);
	dgVector angularM0(internalForces[m0].m_angular);
	dgVector linearM1(internalForces[m1].m_linear);
	dgVector angularM1(internalForces[m1].m_angular);
	for (dgInt32 i = 0; i < rowsCount; i++) {
		dgJacobianMatrixElement* const row = &matrixRow[index + i];
		dgVector jointForce (f[i]);
		row->m_force = f[i] + row->m_force;
		linearM0 += row->m_Jt.m_jacobianM0.m_linear * jointForce;
		angularM0 += row->m_Jt.m_jacobianM0.m_angular * jointForce;
		linearM1 += row->m_Jt.m_jacobianM1.m_linear * jointForce;
		angularM1 += row->m_Jt.m_jacobianM1.m_angular * jointForce;
	}

	internalForces[m0].m_linear = linearM0;
	internalForces[m0].m_angular = angularM0;
	internalForces[m1].m_linear = linearM1;
	internalForces[m1].m_angular = angularM1;
	return accNorm.GetScalar();
}
Example #30
0
int NewmarkHSFixedNumIter::domainChanged()
{
    AnalysisModel *myModel = this->getAnalysisModel();
    LinearSOE *theLinSOE = this->getLinearSOE();
    const Vector &x = theLinSOE->getX();
    int size = x.Size();
    
    // create the new Vector objects
    if (Ut == 0 || Ut->Size() != size)  {
        
        // delete the old
        if (Ut != 0)
            delete Ut;
        if (Utdot != 0)
            delete Utdot;
        if (Utdotdot != 0)
            delete Utdotdot;
        if (U != 0)
            delete U;
        if (Udot != 0)
            delete Udot;
        if (Udotdot != 0)
            delete Udotdot;
        if (Utm1 != 0)
            delete Utm1;
        if (Utm2 != 0)
            delete Utm2;
        if (scaledDeltaU != 0)
            delete scaledDeltaU;
        
        // create the new
        Ut = new Vector(size);
        Utdot = new Vector(size);
        Utdotdot = new Vector(size);
        U = new Vector(size);
        Udot = new Vector(size);
        Udotdot = new Vector(size);
        Utm1 = new Vector(size);
        Utm2 = new Vector(size);
        scaledDeltaU = new Vector(size);
        
        // check we obtained the new
        if (Ut == 0 || Ut->Size() != size ||
            Utdot == 0 || Utdot->Size() != size ||
            Utdotdot == 0 || Utdotdot->Size() != size ||
            U == 0 || U->Size() != size ||
            Udot == 0 || Udot->Size() != size ||
            Udotdot == 0 || Udotdot->Size() != size ||
            Utm1 == 0 || Utm1->Size() != size ||
            Utm2 == 0 || Utm2->Size() != size ||
            scaledDeltaU == 0 || scaledDeltaU->Size() != size)  {
            
            opserr << "NewmarkHSFixedNumIter::domainChanged - ran out of memory\n";
            
            // delete the old
            if (Ut != 0)
                delete Ut;
            if (Utdot != 0)
                delete Utdot;
            if (Utdotdot != 0)
                delete Utdotdot;
            if (U != 0)
                delete U;
            if (Udot != 0)
                delete Udot;
            if (Udotdot != 0)
                delete Udotdot;
            if (Utm1 != 0)
                delete Utm1;
            if (Utm2 != 0)
                delete Utm2;
            if (scaledDeltaU != 0)
                delete scaledDeltaU;
            
            Ut = 0; Utdot = 0; Utdotdot = 0;
            U = 0; Udot = 0; Udotdot = 0;
            Utm1 = 0; Utm2 = 0; scaledDeltaU = 0;
            
            return -1;
        }
    }        
    
    // now go through and populate U, Udot and Udotdot by iterating through
    // the DOF_Groups and getting the last committed velocity and accel
    DOF_GrpIter &theDOFs = myModel->getDOFs();
    DOF_Group *dofPtr;
    while ((dofPtr = theDOFs()) != 0)  {
        const ID &id = dofPtr->getID();
        int idSize = id.Size();
        
        int i;
        const Vector &disp = dofPtr->getCommittedDisp();	
        for (i=0; i < idSize; i++)  {
            int loc = id(i);
            if (loc >= 0)  {
                (*Utm1)(loc) = disp(i);
                (*Ut)(loc) = disp(i);
                (*U)(loc) = disp(i);
            }
        }
        
        const Vector &vel = dofPtr->getCommittedVel();
        for (i=0; i < idSize; i++)  {
            int loc = id(i);
            if (loc >= 0)  {
                (*Udot)(loc) = vel(i);
            }
        }
        
        const Vector &accel = dofPtr->getCommittedAccel();	
        for (i=0; i < idSize; i++)  {
            int loc = id(i);
            if (loc >= 0)  {
                (*Udotdot)(loc) = accel(i);
            }
        }
    }
    
    if (polyOrder == 2)
        opserr << "\nWARNING: NewmarkHSFixedNumIter::domainChanged() - assuming Ut-1 = Ut\n";
    else if (polyOrder == 3)
        opserr << "\nWARNING: NewmarkHSFixedNumIter::domainChanged() - assuming Ut-2 = Ut-1 = Ut\n";
    
    return 0;
}