コード例 #1
0
ファイル: primitives.c プロジェクト: dmt4/atomeye
bool set_glob_advance (int iw)
{
    char danswer[TERMSIZE];
    xterm_get_focus(iw); clear_stdin_buffer();
    sprintf (danswer, "%d", n[iw].glob_advance);
    sscanf(readline_gets("\nFilelist step advance",danswer),
           "%d", &(n[iw].glob_advance));
    xterm_release_focus(iw);
    n[iw].glob_advance = ABS(n[iw].glob_advance);
    return (FALSE);
} /* set_glob_advance() */
コード例 #2
0
ファイル: info.c プロジェクト: sinamoeini/AtomEye
bool find_atom (int iw)
{
    static int last_atom = 0;
    int i;
    char question[MAX_FILENAME_SIZE],danswer[MAX_FILENAME_SIZE],*answer;
    xterm_get_focus(iw); clear_stdin_buffer();
    sprintf (question, "\nFind atom [0-%d]", np-1);
    sprintf (danswer, "%d", last_atom);
    answer = readline_gets(question,danswer);
    sscanf (answer, "%d", &i);
    xterm_release_focus(iw);
    if ((i < 0) || (i >= np)) printf("find_atom: illegal index\n");
    else
    {
        n[iw].anchor = i;
        print_atom(iw,i);
        last_atom = i;
    }
    return (FALSE);
} /* end find_atom() */
コード例 #3
0
ファイル: xtal_shift.c プロジェクト: sinamoeini/AtomEye
bool xtal_origin_goto (int iw)
{
    double old_s[3], s[3];
    char danswer[MAX_FILENAME_SIZE],*answer;
    if (!n[iw].xtal_mode)
    {
        printf ("Crystal translation is only available under Xtal mode.\n");
        return(FALSE);
    }
    V3mM3 (AX_3D[iw].x, HI, old_s);
    xterm_get_focus(iw); clear_stdin_buffer();
    sprintf (danswer, "%g %g %g", old_s[0],old_s[1],old_s[2]);
    answer = readline_gets("\nCrystal origin s0,s1,s2",danswer);
    sscanf (answer, "%lf %lf %lf", s, s+1, s+2);
    xterm_release_focus(iw);
    V3TRIM (s,s);
    if (V3EQ(old_s,s)) return(FALSE);
    V3mM3 (s, H, n[iw].xtal_origin);
    atom_xtal_origin (n[iw].xtal_origin);
    if (n[iw].bond_mode) bond_xtal_origin_update (iw);
    else n[iw].bond_xtal_origin_need_update = TRUE;
    return (TRUE);
} /* end xtal_origin_goto() */
コード例 #4
0
ファイル: info.c プロジェクト: sinamoeini/AtomEye
/* Save atoms selected in a monoclinic filter to a file */
void save_atoms_in_monoclinic_filter (int iw)
{
    M3 HH;
    double d0, zmargin, xytolerance, origin[3];
    char danswer[MAX_FILENAME_SIZE], *answer, fname[MAX_FILENAME_SIZE];
    char *taglist = NULL;
    int selected[2];
    
    V3SUB( B->BALL[n[iw].atom_stack[0]].x,
           B->BALL[n[iw].atom_stack[1]].x, HH[0] );
    V3SUB( B->BALL[n[iw].atom_stack[2]].x,
           B->BALL[n[iw].atom_stack[1]].x, HH[1] );
    V3CROSS (HH[0], HH[1], HH[2]);
    if (V3ISSMALL(HH[2]))
    {
        printf("The selected parallelogram is ill-conditioned\n"
               "for constructing a monoclinic filter.\n");
        return;
    }
    V3NORMALIZE (HH[2], d0);
    printf ("\"up\" is [%g %g %g]\n"
            "check it agrees with your mirror normal...\n", V3E(HH[2]));
        
    d0 = 2.5;
    zmargin = 0.01; 
    xytolerance = 0.01;
    xterm_get_focus(iw); clear_stdin_buffer();
    REALLOC (save_atoms_in_monoclinic_filter, taglist, np, char);
    while (1)
    {
        sprintf (danswer, "%g %g %g", d0, zmargin, xytolerance);
        answer = readline_gets
            ("Interplanar spacing [A]  z-margin [A]  xy-tolerance", danswer);
        sscanf(answer, "%lf %lf %lf", &d0, &zmargin, &xytolerance);
        V3ADDMUL (B->BALL[n[iw].atom_stack[1]].x, d0/2,HH[2], origin);
        if (tag_atoms_in_monoclinic_filter
            (origin,HH, d0+2*zmargin,xytolerance, selected,taglist)>0) break;
        strcpy (danswer, answer);
    }
    printf("down=%d and up=%d atoms selected in filter.\n",
           selected[0], selected[1]);
    while (1)
    {
        sprintf (danswer, "%s.idx", fbasename);
        answer = readline_gets("Save the selected atoms to", danswer);
        sscanf(answer, "%s", fname);
        if ( tested_to_be_writable(fname) )
        {
            save_dipole_indices (selected, taglist, fname);
            printf ("selected atom indices [0-%d] saved to %s.\n", np-1,fname);
            Free (taglist);
            break;
        }
        else
        {
            printf ("\n** %s: **\n", fname);
            printf ("** This file is unwritable! **\n");
        }
        strcpy(danswer, answer);
    }
    xterm_release_focus(iw);

    return;
} /* end save_atoms_in_monoclinic_filter() */
コード例 #5
0
ファイル: primitives.c プロジェクト: dmt4/atomeye
/* Load color/radii file for atoms */
bool load_atom_color_from_file (int iw)
{
    char fname[MAX_FILENAME_SIZE], buf[COLOR_LINESIZE];
    FILE *fp;
    int m, j, k, items;
    double c[4];

    xterm_get_focus(iw); clear_stdin_buffer();
    sprintf (buf, "%s.clr", fbasename);
    strcpy(fname,readline_gets("\nLoad color properties from",buf));
    xterm_release_focus(iw);
    if (Freadable(fname))
    {
        fp = ROpen(fname);
        for (m=0; ; m++)
            if (fgets(buf,COLOR_LINESIZE,fp))
            {
                if (m >= np)
                {
                    printf ("\n** %s has more rows than atoms **\n", fname);
                    return (FALSE);
                }
                items = sscanf (buf, "%lf %lf %lf %lf", c, c+1, c+2, c+3);
                if (items == 1)
                {
                    c[3] = c[0];
                    c[0] = B->BALL[m].r;
                    c[1] = B->BALL[m].g;
                    c[2] = B->BALL[m].b;
                }
                else if (items == 3)
                    c[3] = B->BALL[m].radius / n[iw].atom_r_ratio;
                if (c[0]>1) c[0]/=255;
                if (c[1]>1) c[1]/=255;
                if (c[2]>1) c[2]/=255;
                AX_3D_AssignRGB(B->BALL[m], c[0], c[1], c[2]);
                B->BALL[m].radius = c[3] * n[iw].atom_r_ratio;
            }
            else if (m < np) 
            {
                if (m == 0)
                {
                    printf ("\n** %s has no data **\n", fname);
                    return (FALSE);
                }
                else if ( ISFACTOR (m, np) )
                { /* make a bold guess */
                    for (j=m; j<np; j++)
                    {
                        k = j % m;
                        AX_3D_AssignRGB (B->BALL[j], B->BALL[k].r,
                                         B->BALL[k].g, B->BALL[k].b);
                        B->BALL[j].radius = B->BALL[k].radius;
                    }
                }
                else printf ("\n** premature ending of %s **\n", fname);
                bond_atom_color_update (iw);
                return (TRUE);
            }
            else break;
    }
    else
    {
        printf ("\n** %s: **\n", fname);
        printf ("** This file is unreadable! **\n");
        return (FALSE);
    }
    bond_atom_color_update (iw);
    return (TRUE);
} /* end load_atom_color_from_file() */
コード例 #6
0
ファイル: primitives.c プロジェクト: dmt4/atomeye
/* Use script to produce jpeg frames */
void script_animate (int iw)
{
    char buf[SCRIPT_LINE_SIZE],output[SCRIPT_LINE_SIZE],*ptr;
    int i,hascontent,quality,frames;
    FILE *fp;
    glob_t globbuf;
    
    strcpy(buf, "scr_anim");
    if (!(fp=ropen(buf)))
    {
        printf ("\nAnimation script \"%s\" does not exist,\n", buf);
        xterm_get_focus(iw); clear_stdin_buffer();
        if (!strcasecmp("y", readline_gets
                        ("Do you want a default one created (y/n)?","y")))
        {
            numerically_sorted_glob (config_fname, &globbuf);
            fp=wopen(buf);
            fprintf (fp, "%d\n", AX_JPG_DEF_QUALITY);
            for (i=0; i<globbuf.gl_pathc; i++)
                fprintf (fp, "%s Jpg/%05d.jpg\n", globbuf.gl_pathv[i], i);
            globfree (&globbuf);
            fclose(fp);
            fp = ropen(buf);
        }
        else
        {
            xterm_release_focus(iw);
            return;
        }
    }
    if (!(ptr=fgets(buf,SCRIPT_LINE_SIZE,fp)))
    {
        printf ("\nThere is nothing in animation script \"%s\".\n", buf);
        fclose (fp);
        return;
    }
    for (hascontent=i=0; (buf[i]!=EOS) &&
             (ISDIGIT(buf[i]) || ISBLANK(buf[i]) || (buf[i]=='\n')); i++)
        if (ISALNUM(buf[i])) hascontent=1;
    if (!hascontent)
    {
        printf ("\nThere is no content in animation script \"%s\".\n", buf);
        fclose (fp);
        return;
    }
    if (buf[i] == EOS)
    {
        sscanf (buf, "%d", &quality);
        if ((quality<0) || (quality>100))
        {
            printf ("\nquality = %d is out of valid range ([0,100]).\n",
                    quality);
            return;
        }
        else printf ("\nquality = %d\n", quality);
        ptr = fgets(buf,SCRIPT_LINE_SIZE,fp);
    }
    else quality = AX_JPG_DEF_QUALITY;
    frames = 0;
    /* If bonds are not on now, there is no need to refresh */
    temporary_disable_bond = !n[iw].bond_mode;
    /* cylinder data structure during the rendering.        */
    while (ptr)
    {
        buf[SCRIPT_LINE_CHAR] = EOS;
        sscanf (buf, "%s %s", config_fname, output);
        reload_config (iw, FALSE);
        paint_scene(iw);
        AX_dump(iw); AX_show(iw);
        if (str_caseend_with(output,".png"))
            AX_save_pixmap_as_png
                (iw,AX_JPG_QUALITY_TO_PNG_LEVEL(quality),output);
        else if (str_caseend_with(output,".eps"))
            AX_save_pixmap_as_eps(iw,quality,output);
        else AX_save_pixmap_as_jpg(iw,quality,output);
        frames++;
        ptr = fgets(buf,SCRIPT_LINE_SIZE,fp);
    }
    fclose(fp);
    printf ("%d frames saved.\n\n", frames);
    if (temporary_disable_bond)
    {
        Config_to_3D_Bonds (n[iw].bond_radius);
        if (n[iw].bond_mode)
        {
            bond_xtal_origin_update (iw);
            bond_atom_color_update(iw);
        }
        else
        {
            n[iw].bond_xtal_origin_need_update = TRUE;
            n[iw].bond_atom_color_need_update = TRUE;
        }
        temporary_disable_bond = 0;
    }
    return;
} /* end script_animate() */
コード例 #7
0
ファイル: primitives.c プロジェクト: dmt4/atomeye
/* Reload the configuration but keeping the rendering state */
void reload_config (int iw, bool term_input_filename)
{
    register int i;
    int j, k, old_np;
    char fname[MAX_FILENAME_SIZE], oldfname[MAX_FILENAME_SIZE]; 
    V3 hook_s, tmp, dx;
    char *old_symbol=NULL;
    bool incompatible_config;
    
    strcpy(oldfname, config_fname);
    if (n[iw].anchor >= 0)
    { /* the new configuration may not even have the atom */
        V3EQV (B->BALL[n[iw].anchor].x, n[iw].hook);
        n[iw].anchor = -1;
    }
    /* hook_s[] is what is kept invariant */
    V3mM3 (n[iw].hook, HI, hook_s);
    if (term_input_filename)
    {
        xterm_get_focus(iw); clear_stdin_buffer();
        strcpy(fname,readline_gets("\nLoad configuration",config_fname));
        strcpy(config_fname,fname);
        xterm_release_focus(iw);
    }
    if (!Fexists(config_fname))
    {
        printf ("\n** %s: **\n", config_fname);
        printf ("** There is no such file! **\n");
        strcpy(config_fname, oldfname);
        return;
    }
    if (!Freadable(config_fname))
    {
        printf ("\n** %s: **\n", config_fname);
        printf ("** This file is unreadable! **\n");
        strcpy(config_fname, oldfname);
        return;
    }
    cr();

    old_np = np;
    CLONE(symbol, SYMBOL_SIZE*np, char, old_symbol);
    i = CONFIG_LOAD (config_fname, Config_Aapp_to_Alib);

    for (k=0; k<CONFIG_num_auxiliary; k++)
        if (*blank_advance(CONFIG_auxiliary_name[k])==EOS)
            sprintf(CONFIG_auxiliary_name[k], "auxiliary%d", k);
    rebind_CT (Config_Aapp_to_Alib, "", ct, &tp); cr();
    Neighborlist_Recreate_Form (Config_Aapp_to_Alib, ct, N);
    if (i == CONFIG_CFG_LOADED)
        N->s_overflow_err_handler =
            NEIGHBORLIST_S_OVERFLOW_ERR_HANDLER_FOLD_INTO_PBC;
    else
        N->s_overflow_err_handler =
            NEIGHBORLIST_S_OVERFLOW_ERR_HANDLER_BOUNDING_BOX;
    N->small_cell_err_handler = NEIGHBORLIST_SMALL_CELL_ERR_HANDLER_MULTIPLY;
    for (i=0; i<ct->t; i++)
        for (j=i; j<ct->t; j++)
            for (k=0; k<rcut_patch_top; k++)
                if ( ( ( (rcut_patch[k].Zi == ct->Z[i]) &&
                         (rcut_patch[k].Zj == ct->Z[j]) ) ||
                       ( (rcut_patch[k].Zi == ct->Z[j]) &&
                         (rcut_patch[k].Zj == ct->Z[i]) ) ) )
                    NEIGHBOR_TABLE(N->rcut,ct,i,j) =
                        NEIGHBOR_TABLE(N->rcut,ct,j,i) = rcut_patch[k].rcut;
    Neighborlist_Recreate (Config_Aapp_to_Alib, stdout, ct, &tp, N);
    V3mM3 (hook_s, H, tmp);
    V3SUB (tmp, n[iw].hook, dx);
    V3EQV (tmp, n[iw].hook);
    V3AdD (dx, AX_3D[iw].x);
    M3InV (H, HI, volume);
    lengthscale = cbrt(volume);
    V3ASSIGN (0.5,0.5,0.5,tmp);
    V3mM3 (tmp, H, cm);
    geo_clear_has_evaluated_flags();
    evaluate_geo_measures(); Free(s1); Free(mass);

    if  ( ComputeLeastSquareStrain )
    {
        if (ConfigChecksum(Config_Aapp_to_Alib) != ref->checksum)
            printf ("This configuration is not isoatomic with the imprinted "
                    "reference\n%s. Least-square strain NOT calculated.\n",
                    ref_fbasename);
        else LeastSquareStrain_Append();
    }

    incompatible_config = (np != old_np) ||
        memcmp(symbol, old_symbol, SYMBOL_SIZE*MIN(np,old_np));
    Free(old_symbol);
    
    if (incompatible_config)
        Config_to_3D_Balls (n[iw].atom_r_ratio);
    else for (i=0; i<np; i++) V3mM3 ( &(s[DIMENSION*i]), H, B->BALL[i].x );

    atom_xtal_origin (n[iw].xtal_origin);
    if (!n[iw].auxiliary_thresholds_rigid)
    {
        for (i=0; i<CONFIG_num_auxiliary; i++)
            reset_auxiliary_threshold(iw,i);
        for (i=0; i<MAX_GEO_MEASURES; i++)
            if (geolist[i].has_evaluated)
                reset_auxiliary_threshold(iw,CONFIG_MAX_AUXILIARY+i);
    }
    if (!temporary_disable_bond) Config_to_3D_Bonds (n[iw].bond_radius);
    select_fbasename (config_fname);
    if ((n[iw].xtal_mode) && (n[iw].color_mode == COLOR_MODE_COORD))
        assign_coordination_color(iw);
    else if (n[iw].color_mode == COLOR_MODE_AUXILIARY)
        color_encode_auxiliary(iw);
    else if (n[iw].color_mode == COLOR_MODE_SCRATCH)
        scratch_color (iw);
    else
    {
        strcpy (AX_title[iw],fbasename);
        AXSetName (iw);
        XStoreName(AX_display[iw],xterm_win,AX_title[iw]);
        XSetIconName(AX_display[iw],xterm_win,AX_title[iw]);
        if (!temporary_disable_bond)
        {
            bond_xtal_origin_update (iw);
            bond_atom_color_update (iw);
        }
    }
    return;
} /* end reload_config() */