Exemplo n.º 1
0
SatellitesComponent::SatellitesComponent( SkyComposite *parent ) :
    SkyComponent( parent )
{
    KSFileReader fileReader;
    QString line;
    QStringList group_infos;
    
    if ( ! fileReader.open( "satellites.dat" ) ) return;

    emitProgressText( i18n("Loading satellites" ) );
    

    while ( fileReader.hasMoreLines() ) {
        line = fileReader.readLine();
        if ( line.trimmed().isEmpty() || line.at( 0 ) == '#' )
            continue;
        group_infos = line.split( ';' );
        m_groups.append( new SatelliteGroup( group_infos.at( 0 ), group_infos.at( 1 ), QUrl( group_infos.at( 2 ) ) ) );
    }

    objectNames(SkyObject::SATELLITE).clear();

    foreach( SatelliteGroup *group, m_groups )
    {
        for ( int i=0; i<group->size(); i++ )
        {
            Satellite *sat = group->at( i );
            if ( sat->selected() && nameHash.contains(sat->name().toLower()) == false)
            {
                objectNames(SkyObject::SATELLITE).append(sat->name());
                nameHash[sat->name().toLower()] = sat;
            }
        }
    }
}
Exemplo n.º 2
0
void SatellitesComponent::draw( SkyPainter *skyp )
{
    // Return if satellites must not be draw
    if( ! selected() )
        return;

    bool hideLabels =  (!Options::showSatellitesLabels() || ( SkyMap::Instance()->isSlewing() && Options::hideLabels() ));

    foreach( SatelliteGroup *group, m_groups )
    {
        for ( int i=0; i<group->size(); i++ )
        {
            Satellite *sat = group->at( i );
            if ( sat->selected() )
            {
                bool drawn = false;
                if ( Options::showVisibleSatellites() )
                {
                    if ( sat->isVisible() )
                        drawn = skyp->drawSatellite( sat );
                }
                else
                {
                    drawn = skyp->drawSatellite( sat );
                }

                if (drawn && !hideLabels)
                    SkyLabeler::AddLabel( sat, SkyLabeler::SATELLITE_LABEL );
            }
        }
    }
}
Exemplo n.º 3
0
 foreach ( SatelliteGroup *group, m_groups ) {
     for ( int i=0; i<group->size(); i++ ) {
         Satellite *sat = group->at( i );
         if ( sat->name() == name )
             return sat;
     }
 }
Exemplo n.º 4
0
void SatellitesItem::update() {
    if( ! m_satComp->selected() ) {
        hide();
        return;
    }

    QSGNode *n = firstChild();

    while(n != 0) {
        SatelliteNode *satNode = static_cast<SatelliteNode *>(n);
        Satellite *sat = satNode->sat();
        if ( sat->selected() ) {
            if ( Options::showVisibleSatellites() ) {
                if ( sat->isVisible() ) {
                    satNode->update();
                } else {
                    satNode->hide();
                }
            } else {
                satNode->update();
            }
        } else {
            satNode->hide();
        }
        n = n->nextSibling();
    }
}
Exemplo n.º 5
0
void SatelliteGroup::updateSatellitesPos()
{
    for ( int i=0; i<size(); i++ ) {
        Satellite *sat = at( i );
        if ( sat->selected() )
            sat->updatePos();
    }
}
Exemplo n.º 6
0
//---- main function
int main(int argc, char *argv[])
{
    clock_t start, end;
    start = clock();

    FILE *fp;
    FILE *fp2;
    if (argc <= 1) {
        printf("not enough argument\n");
        exit(0);
    }
    if ((fp = fopen(argv[1], "w")) == NULL) {
        printf("file cannot open\n");
        exit(0);
    }
    if ((fp2 = fopen(argv[2], "w")) == NULL) {
        printf("file cannot open\n");
        exit(0);
    }
    Satellite* debris;
    debris = new Satellite();
    double previous;
    int count = 0;

    for(int t=0; t<1000000; t++){
        double r = hypot(hypot(debris->qx, debris->qy), debris->qz);
        double p = hypot(hypot(debris->px, debris->py), debris->pz);

        double q = hypot(debris->qz , debris->qx);
        double theta = atan2(debris->qy, debris->qx) * 180.0 / M_PI;
        if (theta<0) {
            theta += 360;
        }
        if (t%50==0) {
            if (previous>359.0 && theta<1.0) {
                count++;
            }
            double KE = debris->getKineticE();
            double UE = debris->getPotentialE();
            fprintf(fp, "%f %f %f %f %f %f %f\n", debris->qx, debris->qy, debris->qz, debris->px, debris->py, debris->pz, KE+UE);
            fprintf(fp2, "%f %f %f %f %f\n", theta+count*360, p, KE, UE, KE + UE);
            previous = theta;
        }
       debris->motion();
   }
    fclose(fp);

    end = clock();
    printf("%.10lf[s]\n", (double)(end - start)/CLOCKS_PER_SEC);

    /*
    glutInit(&argc, argv);
    openGL(argv[1]);
    */
}
Exemplo n.º 7
0
void SatellitesComponent::draw( SkyPainter *skyp )
{
    // Return if satellites must not be draw
    if( ! selected() )
        return;

    foreach( SatelliteGroup *group, m_groups ) {
        for ( int i=0; i<group->size(); i++ ) {
            Satellite *sat = group->at( i );
            if ( sat->selected() ) {
                if ( Options::showVisibleSatellites() ) {
                    if ( sat->isVisible() )
                        skyp->drawSatellite( sat );
                } else {
                    skyp->drawSatellite( sat );
                }
            }
        }
    }
}
Exemplo n.º 8
0
	void FragmentTree::processFragment( FragmentPtr fg, MassLossWindow& mlw, size_t degree, Satellite sate )
	{
		if(degree == mlw.size()) {  // Out of boundary.
			NodeItem node(fg);

			int max_num = (int)fg->getModificationSiteNum("SO3", 1);
			Satellite::iterator ac_iter = sate.find("CH2CO");
			int ac_num = ac_iter == sate.end() ? 0 : -1 * ac_iter->second;
			Satellite::iterator s_iter = sate.find("SO3");
			int s_num = s_iter == sate.end() ? 0 : -1 * s_iter->second;
			if(s_num + ac_num > max_num)
				s_iter->second = max_num - ac_num;

			// Update the composition.
			for(Satellite::iterator iter = sate.begin(); iter != sate.end(); iter++) {
				//std::cout << iter->first << " " << iter->second << " ";
				if(!node.appendMassShift(iter->first, iter->second)) {
					return;
				}
			}
			//std::cout << std::endl;

			node_pool.insert(node);
			return;
		}

		MassLoss& ml = mlw.at(degree);

		for(int i = ml.lower; i<=ml.upper; i++)
		{
			// Copy the composition.
			Satellite temp_sate(sate);

			if(i != 0) {
				temp_sate.insert(std::make_pair(ml.loss_compo.getCompositionString(), i));
				this->processFragment(fg, mlw, degree+1, temp_sate);
			} else {
				this->processFragment(fg, mlw, degree+1, temp_sate);
			}
		}

	}
Exemplo n.º 9
0
void page_update_planet() {
  SDL_Rect srcr = {0, 0, 64, 64};
  SDL_Rect destr = {0, 0, 64, 64};
  Planet *plan = (Planet*)cur_object;
  if(lasttick != -1) {
    for(int sctr=0; sctr < plan->num_satellites; ++sctr) {
      Satellite *sat = plan->satellites[sctr];
      srcr.x = sat->XPos(lasttick) - 32;
      srcr.y = sat->YPos(lasttick) - 32;
      destr.x = sat->XPos(lasttick) - 32;
      destr.y = sat->YPos(lasttick) - 32;
      SDL_FillRect(screen, &destr, black);
      SDL_BlitSurface(planet[plan->Type()], &srcr, screen, &destr);
      update(&destr);
      }
    }
  for(int sctr=0; sctr < plan->num_satellites; ++sctr) {
    Satellite *sat = plan->satellites[sctr];
    if(!(sat->InFront(cur_game->tick))) {
      srcr.x = sat->XPos(cur_game->tick) - 32;
      srcr.y = sat->YPos(cur_game->tick) - 32;
      destr.x = sat->XPos(cur_game->tick) - 32;
      destr.y = sat->YPos(cur_game->tick) - 32;
      SDL_BlitSurface(satellite[sat->Type()], NULL, screen, &destr);
      SDL_BlitSurface(planet[plan->Type()], &srcr, screen, &destr);
      update(&destr);
      }
    }
  for(int sctr=0; sctr < plan->num_satellites; ++sctr) {
    Satellite *sat = plan->satellites[sctr];
    if(sat->InFront(cur_game->tick)) {
      srcr.x = sat->XPos(cur_game->tick) - 32;
      srcr.y = sat->YPos(cur_game->tick) - 32;
      destr.x = sat->XPos(cur_game->tick) - 32;
      destr.y = sat->YPos(cur_game->tick) - 32;
      SDL_BlitSurface(satellite[sat->Type()], NULL, screen, &destr);
      update(&destr);
      }
    }
  lasttick = cur_game->tick;
  }