コード例 #1
0
ファイル: X11Context.cpp プロジェクト: colajam93/pomdog
X11Context::X11Context()
    : Display(nullptr)
{
    ::XInitThreads();

    Display = ::XOpenDisplay(nullptr);
    if (Display == nullptr) {
        POMDOG_THROW_EXCEPTION(std::runtime_error, "Error: XOpenDisplay");
    }

    //int screen = DefaultScreen(display);
    //::Window rootWindow = RootWindow(display, screen);

    InitializeAtoms(Display, Atoms);
}
コード例 #2
0
ファイル: Main.c プロジェクト: juddy/edcde
/*++++++++++++++++++++++++++++++++++++++*/
int 
main(
        int argc,
        char **argv )
{
    int             n;
    Arg             args[MAX_ARGS];
    XEvent          event;
    XPropertyEvent *pEvent=(XPropertyEvent *)&event;
    long            mwmFunc;
    Boolean         useMaskRtn, useIconFileCacheRtn;    
    char           *dirs = NULL;
    char           *string;
	Visual         *visual;

#ifdef USERHELP
malloc_check(1);
malloc_trace(0);
#endif

    XtSetLanguageProc(NULL, NULL, NULL);
    _DtEnvControl(DT_ENV_SET); 
    

    /* Initialize the toolkit and open the display */
    style.shell = 
        XtInitialize(argv[0], XMCLASS, option_list, 1, (int *)&argc, argv);

#ifdef __osf__
    _XmColorObjCreate(style.shell, NULL, NULL);
#endif

    /* Allow all WS manipulation functions except resize and maximize */
    mwmFunc = MWM_FUNC_ALL ^ (MWM_FUNC_RESIZE | MWM_FUNC_MAXIMIZE); 

    n = 0;
    XtSetArg(args[n], XmNmwmFunctions, mwmFunc); n++;
    XtSetArg(args[n], XmNuseAsyncGeometry, True); n++;
    XtSetValues(style.shell, args, n);

    /* initialize global style data */

    style.display    = XtDisplay(style.shell);
    style.screen     = DefaultScreenOfDisplay(style.display);
    style.screenNum  = DefaultScreen(style.display);
    style.colormap   = DefaultColormap(style.display, style.screenNum);
    style.root       = DefaultRootWindow(style.display);
    style.execName   = argv[0];
    style.errDialog  = NULL;
    style.tmpXmStr   = NULL;
    style.home = (char *) XtMalloc(strlen((char *) getenv("HOME")) + 1);
    strcpy(style.home, (char *) getenv("HOME"));
    style.colorDialog = NULL;
    style.backdropDialog = NULL;
    style.fontDialog = NULL;
    style.kbdDialog = NULL;
    style.mouseDialog = NULL;
    style.audioDialog = NULL;
    style.screenDialog = NULL;
    style.startupDialog = NULL;
    style.dtwmDialog = NULL;
    style.i18nDialog = NULL;
	visual = XDefaultVisual(style.display,style.screenNum);
	style.visualClass = visual->class;
    
    if (progName = DtStrrchr(argv[0], '/')) progName++;
    else progName = argv[0];

    /* Get the lock established to ensure only one dtstyle process
     * is running per screen .. first malloc enough space*/

    if (_DtGetLock (style.display, STYLE_LOCK) == 0)
    {
        _DtSimpleError (progName, DtError, NULL, "%s",
	     ((char *)GETMESSAGE(2, 5, "Style Manager is already running, second attempt aborted.")));
        exit(1);
    }

    InitDtstyleProtocol();
    SetWindowProperties();

    /* Register error handlers */
    XSetErrorHandler(ErrorHandler);
    XSetIOErrorHandler(IOErrorHandler);
    XtAppSetErrorHandler(XtWidgetToApplicationContext(style.shell),
                         ToolkitErrorHandler);
    XtAddEventHandler(style.shell, StructureNotifyMask, 0,
                         (XtEventHandler)MwmReparentNotify, NULL);

    /* set up resolution dependent layout variables */
    switch (_DtGetDisplayResolution(style.display, style.screenNum))
    {
        case LOW_RES_DISPLAY:
            style.horizontalSpacing = 
            style.verticalSpacing = 3;
            break;
            
        case MED_RES_DISPLAY:
            style.horizontalSpacing = 
            style.verticalSpacing = 5;
            break;
            
        case HIGH_RES_DISPLAY:
            style.horizontalSpacing = 
            style.verticalSpacing = 8;
            break;
    }
    
    GetApplicationResources();
    
    XmeGetIconControlInfo(style.screen, &useMaskRtn,
			  &style.useMultiColorIcons, &useIconFileCacheRtn);
    
    
    /* add the directory $HOME/.dt/backdrops */
    
    string = (char *)XtMalloc(strlen(style.home) + strlen("/.dt/backdrops:") + 1);
    sprintf(string, "%s/.dt/backdrops:", style.home);

    dirs = (char *)XtCalloc(1, strlen("/etc/dt/backdrops:/usr/dt/backdrops") + 
			    (style.xrdb.backdropDir == NULL ? 2 :
			    strlen(style.xrdb.backdropDir)) + 
			    strlen(string) + 2);
  

    strcpy(dirs, string);
    if (style.xrdb.backdropDir) 
      {
	strcat(dirs, style.xrdb.backdropDir);
	strcat(dirs, ":"); 
      }
    strcat(dirs, "/etc/dt/backdrops:/usr/dt/backdrops");

    _DtWsmSetBackdropSearchPath(style.screen, dirs, style.useMultiColorIcons);

    if (string != NULL)
      XtFree((char *)string);
    
    if (dirs != NULL)
      XtFree((char *)dirs); 
    
    

    style.count = 0;
    /* if this is started from save session we need to set up the BMS
       first, otherwise do it after making the window. (for user perception
       for how long it takes for the dtstyle to come up) */
    if(style.xrdb.session != NULL) {
      DtInitialize (style.display, style.shell, progName, progName);
      /*Restore a session or build and display the main Window.*/
      if(!restoreSession(style.shell,style.xrdb.session))
	init_mainWindow(style.shell);
    }
    else {
      init_mainWindow(style.shell);
      DtInitialize (style.display, style.shell, progName, progName);
      InitializeAtoms();
      CheckMonitor(style.shell);
      GetDefaultPal(style.shell);
    }
    
    signal(SIGINT,(void (*)())activateCB_exitBtn); 
    signal(SIGTERM,(void (*)())activateCB_exitBtn); 

    /* to avoid defunct screen saver processes */    
    signal(SIGCHLD, (void (*)())WaitChildDeath);

    /* backdrop dialog  needs to know when the workspace changes to recolor 
       the bitmap displayed in the dialog */
    ListenForWorkspaceChange();

    /* if using COLOR builtin, style.workProcs is True */

    if ((XmeUseColorObj() != FALSE) && style.workProcs)

        XtAppAddWorkProc(XtWidgetToApplicationContext(style.shell), 
                        NewCreateD, style.shell);

    XtAppMainLoop(XtWidgetToApplicationContext(style.shell));

    return 0;
}
コード例 #3
0
ファイル: mix_md.c プロジェクト: kuahitz/accel_md
// # Description
//   X方向の小さいモデルで転位を作ってX方向を拡張するためのプログラム
// # Arguments
// 1. ARGV[1]
//   cmdsファイル
// # Contents of cmds
// 1. コンディションファイル
// 2. 作成するモデル数
// 3. 拡張したいモデルの名前 拡張したいモデルの角度 拡張後のX方向大きさ SPBC_DZ
// 4. 拡張したいモデルの名前 拡張したいモデルの角度 拡張後のX方向大きさ SPBC_DZ
// 5.                                 :
// 6.                                 :
// 7.                                 :
int  main (int argc, char *argv[])
{
    LATTICE_t  lattice;
    MD_t md, cliped_md;
    CONDITION_t condition;
    lattice.x = NULL;
    md.atom = NULL;
    int  i, j, n, nx, ny, nz;
    char  output_file_name[256], cnd_file_name[256], cmd_name[256], mdl_name[256], cmds_update_output[256], cnd_file_input[256];
    double  b, b_x, b_z, new_x, scale_top_x, scale_bottom_x, rad, spbc_dz;
    FILE  *fp, *mdl_fp, *cmds_update_fp;
    char *home = getenv("HOME");

    char  file_name[256];
    if(argc > 1) {
        sprintf (file_name, "%s", argv[1]);
    } else {
        fprintf (stdout, "ファイル名: ");
        fflush (stdout);
        fscanf (stdin, "%s", file_name);
    }

    sprintf (cmd_name, "%s/lab_src/cmds/%s.cmds", home, file_name);
    fp = fopen (cmd_name, "r");
    if (fp == NULL) {
        fprintf (stdout, "%s ファイルが開けません\n", file_name);
        return 1;
    }
    sprintf (mdl_name, "%s/lab_src/mdls/%s.mdls", home, file_name);
    mdl_fp = fopen (mdl_name, "w");
    sprintf (cmds_update_output, "%s/lab_src/cmds/%s_update.cmds", home, file_name);
    cmds_update_fp = fopen (cmds_update_output, "w");

    fscanf (fp, "%s", cnd_file_name);
    fscanf (fp, "%d", &n);
    // fscanf (fp, "%lf %lf %lf", &lx, &ly, &lz);
    ARG_t arg[n];
    sprintf (cnd_file_input, "%s/lab_src/%s", home, cnd_file_name);

    fprintf(cmds_update_fp, "%s\n", cnd_file_name);
    fprintf(cmds_update_fp, "%d\n", n);

    for (i = 0; i < n; i++) {
        fscanf (fp, "%lf%lf%lf%lf%lf%lf",
                &arg[i].a0,
                &arg[i].deg,
                &arg[i].clip_x,
                &arg[i].lx,
                &arg[i].ly,
                &arg[i].lz);
    }

    for (i = 0; i < n; i++) {
        InitializeAtoms (&md);
        InitializeAtoms (&cliped_md);
        InitializeLattice (&lattice);

        sprintf (output_file_name, "%s/lab_src/lats/bcc110_deg%.4lf.lat", home, arg[i].deg);
        rad = (arg[i].deg - 90.0) * M_PI / 180.0;
        if (ReadLattice (&lattice, output_file_name)) {
            GenerateLatticeType0 (&lattice, arg[i].a0);
            GenerateAtoms (&md, &lattice, 200, 1, 200);
            for (j = 0; j < md.nAtoms; j++) {
                md.atom[j].x -= md.lx / 2.0;
                md.atom[j].y -= md.ly / 2.0;
                md.atom[j].z -= md.lz / 2.0;
            }
            ClipAtoms (&md, &cliped_md, arg[i].clip_x, arg[i].a0 / 4.0, rad, arg[i].a0);
            WriteLattice (&cliped_md, output_file_name);
            ReadLattice (&lattice, output_file_name);
        }

        nx = ceil (arg[i].lx / lattice.lx);
        ny = ceil (arg[i].ly / (2.0 * lattice.ly)) * 2; // 偶数
        nz = ceil (arg[i].lz / lattice.lz);
        GenerateAtoms (&md, &lattice, nx, ny, nz);

        // CheckAtomsInDiscRange (&md, md.lx / 2.0, md.ly / 2.0 + arg[i].a0 / 4.0, 0.0, 0.0, 0.0, 1.0, 11.2, md.lz * 10.0);
        // SetAtomType (&md, 1);
        // UncheckAllAtoms (&md);

        b = arg[i].a0 * sqrt (3) / 2.0;
        b_x = b * cos (rad);
        b_z = b * sin (rad);
        new_x = md.lx + b_x / 2.0;
        // new_x = md.lx; // 下に合わせる
        // new_x = md.lx + b_x; // 上に合わせる
        scale_top_x = new_x / (md.lx + b_x);
        scale_bottom_x = new_x / md.lx;
        spbc_dz = b_z / 2.0;

        // cutting from right bottom
        // CheckAtomsInCubeRange (&md, md.lx - b_x, md.lx, 0.0, md.ly / 2.0 - arg[i].a0 / 4.0, 0.0, md.lz);
        // cutting from left top
        CheckAtomsInCubeRange (&md, -INF, 2.0 * b_x, md.ly / 2.0 - arg[i].a0 / 4.0, INF, -INF, INF);
        DuplicateAtoms (&md, md.lx, 0.0, 0.0);
        // SetAtomType (&md, 1);
        UncheckAllAtoms (&md);

        CheckAtomsInYRange (&md, -INF, md.ly / 2.0 - arg[i].a0 / 4.0);
        Scale (&md, scale_bottom_x, 1.0, 1.0, scale_bottom_x, 1.0, 1.0);
        Deform (&md, md.lx, spbc_dz);
        UncheckAllAtoms (&md);

        CheckAtomsInYRange (&md, md.ly / 2.0 - arg[i].a0 / 4.0, INF);
        Scale (&md, scale_top_x, 1.0, 1.0, 1.0, 1.0, 1.0);
        Deform (&md, md.lx, -spbc_dz);
        UncheckAllAtoms (&md);

        // Displacement (&md, md.lx / 2.0, md.ly / 2.0 + arg[i].a0 / 4.0, b_x, b_z);

        CheckAtomsInYRange (&md, -INF, 10.6);
        CheckAtomsInYRange (&md, md.ly - 10.6, INF);
        SetFixAtomBC (&md, 2);
        UncheckAllAtoms (&md);

        CheckAtomsInXRange (&md, -INF, 2.0 * b_x);
        CheckAtomsInXRange (&md, md.lx - 2.0 * b_x, INF);
        ValidateDuplication (&md, spbc_dz, arg[i].a0 / 4.0);
        UncheckAllAtoms (&md);

        // sprintf (output_file_name, "deg_%lf.xxyz", arg[i].deg);
        // WriteAtomsToXXYZ (&md, output_file_name);

        ReadCondition (&condition, cnd_file_input);
        condition.bc.displacement_ux = cos(rad);
        condition.bc.displacement_uz = sin(rad);
        condition.bc.displacement_h = 10.6;
        condition.bc.stress_ex = cos(rad);
        condition.bc.stress_ez = sin(rad);
        condition.bc.spbc_dz = spbc_dz;

        sprintf (output_file_name, "%s_deg%.4lf_nx%d_ny%d_nz%d_mix", file_name, arg[i].deg, nx, ny, nz);
        fprintf(cmds_update_fp, "%s %lf %lf\n", output_file_name, arg[i].deg, spbc_dz);
        strcat (output_file_name, ".mdl");
        WriteAtomsToMDL (&md, output_file_name, condition);
        fprintf(mdl_fp, "%s\n", output_file_name);
    }

    fclose (fp);
    fclose (mdl_fp);
    fclose (cmds_update_fp);
    return 0;
}