Пример #1
0
void StelMovementMgr::init()
{
	QSettings* conf = StelApp::getInstance().getSettings();
	objectMgr = GETSTELMODULE(StelObjectMgr);
	Q_ASSERT(conf);
	Q_ASSERT(objectMgr);
	connect(objectMgr, SIGNAL(selectedObjectChanged(StelModule::StelModuleSelectAction)),
			this, SLOT(selectedObjectChange(StelModule::StelModuleSelectAction)));

	movementsSpeedFactor=1.;
	flagEnableMoveAtScreenEdge = conf->value("navigation/flag_enable_move_at_screen_edge",false).toBool();
	mouseZoomSpeed = conf->value("navigation/mouse_zoom",30).toInt();
	flagEnableZoomKeys = conf->value("navigation/flag_enable_zoom_keys").toBool();
	flagEnableMoveKeys = conf->value("navigation/flag_enable_move_keys").toBool();
	keyMoveSpeed = conf->value("navigation/move_speed",0.0004f).toFloat();
	keyZoomSpeed = conf->value("navigation/zoom_speed", 0.0004f).toFloat();
	autoMoveDuration = conf->value ("navigation/auto_move_duration",1.5f).toFloat();
	flagManualZoom = conf->value("navigation/flag_manual_zoom").toBool();
	flagAutoZoomOutResetsDirection = conf->value("navigation/auto_zoom_out_resets_direction", true).toBool();
	flagEnableMouseNavigation = conf->value("navigation/flag_enable_mouse_navigation",true).toBool();

	minFov = conf->value("navigation/min_fov",0.001389).toDouble(); // default: minimal FOV = 5"
	maxFov = 100.;
	initFov = conf->value("navigation/init_fov",60.f).toFloat();
	currentFov = initFov;
	setInitConstellationIntensity(conf->value("viewing/constellation_art_intensity", 0.5f).toFloat());

	// With a special code of init_view_position=x/y/2 you can set zenith into the center and atan2(x/y) to bottom of screen.
	// examples: 1/0->0             (-1/0)
	//           -1/0 ->180         (1/0)
	//            0/-1 --> 90       (0/-1)
	//            0/1  ->270        (0/1)
	Vec3f tmp = StelUtils::strToVec3f(conf->value("navigation/init_view_pos").toString());
	if (tmp[2]==2)
	{
		initViewPos.set(0., 0., 1.);
		setViewUpVector(Vec3d(tmp[0], tmp[1], 0.));
		setViewDirectionJ2000(core->altAzToJ2000(Vec3d(0., 0., 1.), StelCore::RefractionOff));
	}
	else
	{
		initViewPos.set(tmp[0], tmp[1], tmp[2]);
		viewDirectionJ2000 = core->altAzToJ2000(initViewPos, StelCore::RefractionOff);
	}

	QString tmpstr = conf->value("navigation/viewing_mode", "horizon").toString();
	if (tmpstr=="equator")
		setMountMode(StelMovementMgr::MountEquinoxEquatorial);
	else
	{
		if (tmpstr=="horizon")
			setMountMode(StelMovementMgr::MountAltAzimuthal);
		else
		{
			qWarning() << "ERROR: Unknown viewing mode type: " << tmpstr;
			setMountMode(StelMovementMgr::MountEquinoxEquatorial);
		}
	}

	QString movementGroup = N_("Movement and Selection");
	addAction("actionSwitch_Equatorial_Mount", N_("Miscellaneous"), N_("Switch between equatorial and azimuthal mount"), "equatorialMount", "Ctrl+M");
	addAction("actionGoto_Selected_Object", movementGroup, N_("Center on selected object"), "setFlagTracking()", "Space");
	addAction("actionZoom_In_Auto", movementGroup, N_("Zoom in on selected object"), "autoZoomIn()", "/");
	addAction("actionZoom_Out_Auto", movementGroup, N_("Zoom out"), "autoZoomOut()", "\\");
	addAction("actionSet_Tracking", movementGroup, N_("Track object"), "tracking", "T");
}
Пример #2
0
bool initialize(FusePrivate* data) {
  int ret;
  ArchiveType* archive_type = NULL;

  if (data->drivers_path)
    path_to_drivers = realpath(data->drivers_path, NULL);

  LOAD_STANDARD_DRIVERS();
  if (drivers->empty()) return false;

  FileSystem::setBufferLimit(data->buffer_limit);
  if (data->keep_trash)     FileSystem::keep_trash = true;
  if (data->respect_rights) ArchiveDriver::respect_rights = true;
  if (data->keep_original)  ArchiveDriver::keep_original = true;

  /* První část inicializace */
  if (data->create_archive) {
    data->mode = FusePrivate::ARCHIVE_MOUNTED;

    char* path = (char*)malloc(PATH_MAX);
    memset(path, 0, PATH_MAX);

    getcwd(path, PATH_MAX);
    strcat(path, "/");
    strcat(path, data->mounted);
    data->mounted = path;

    /* soubor již existuje */
    if (access(path, F_OK) == 0) {
      cerr << "Archive file with specified name already exist" << endl;
      return false;
    }

    /* Najdeme koncovku a ovladač */
    const char* ext = findFileExt(data->mounted, NULL);
    archive_type = TYPE_BY_EXT(ext);
    if (archive_type == NULL) {
      cerr << "Error: this type of archive files is not supported" << endl;
      /* Při destrukci FusePrivate bude data->mounted uvolňován */
      data->mounted = NULL;
      return false;
    }

    if (!archive_type->write_support) {
      /* Při destrukci FusePrivate bude data->mounted uvolňován */
      data->mounted = NULL;
      cerr << "Write support for this type of archive is not implemented, sorry" << endl;
      return false;
    }
  } else {
    data->mounted = realpath(data->mounted, NULL);
    ret = errno;
    if (data->mounted == NULL) {
      cerr << "Error: " << strerror(ret) << endl;
      return false;
    }

    ret = setMountMode(data);
    if (ret == -1) {
      cerr << "Unsupported type of source file, sorry" << endl;
      return false;
    } else if (ret > 0) {
      cerr << "Error: " << strerror(errno) << endl;
      return false;
    }
  }

  /* Kontrola kombinace parametrů */
  if (!controlArgs(data)) {
    cerr << "Invalid combination of parameters" << endl;
    return false;
  }

  /* Druhá část inicializace - budování FileSystémů ze zdrojů */
  FileSystem* fs = NULL;
  if (data->mode == FusePrivate::ARCHIVE_MOUNTED) {
    /* Pokud se vytváří nový archiv, ovladač je již načten.
     * Pokud ne, je třeba jej načíst.
     */
    if (!data->create_archive) {
      /* data->mounted už je realpath-ed */
      archive_type = GET_TYPE(data->mounted);
      if (archive_type == NULL) {
        cerr << "Error: Could not load driver for " << data->mounted << endl;
        return false;
      }
    }

    try {
      fs = new FileSystem(data->mounted, data->create_archive, archive_type);
    }
    catch (ArchiveDriver::ArchiveError&) {
      cerr << "Error: Failed to open/process archive file" << endl;
      return false;
    }

    data->filesystems->insert(fs);

  } else {
    DIR* dir;
    struct dirent* file;
    struct stat info;

    char filename[PATH_MAX];
    char* filename_ptr;
    unsigned mounted_len = strlen(data->mounted);
    strcpy(filename, data->mounted);
    filename[mounted_len] = '/';
    filename_ptr = filename + mounted_len + 1;

    /* Projdu celý připojený adresář a pokud obsahuje archivy podporovaných typů
     * vytvořím jejich filesystémy */
    dir = opendir(data->mounted);
    while ((file = readdir(dir)) != NULL) {
      if (strcmp(file->d_name, ".") == 0 || strcmp(file->d_name, "..") == 0)
        continue;

      archive_type = NULL;

      // Získání celé cesty k archivu
      strcpy(filename_ptr, file->d_name);

      if (stat(filename, &info) != 0) continue;

      if (S_ISREG(info.st_mode) || S_ISLNK(info.st_mode)) {
        archive_type = GET_TYPE(filename);
        if (archive_type != NULL) {
          try {
            fs = new FileSystem(filename, false, archive_type);
          }
          catch (...) {
            continue;
          }

          data->filesystems->insert(fs);
        }
      }
    }

    closedir(dir);
  }

//   cout << "FILESYSTEM IS INITIALIZED" << endl;

  return true;
}