Example #1
0
/**
 * @brief Adds the given path and all files and subdirectories
 *        to the set of watched files/directories.
 *        Symlinks will be followed!
 *
 * @param path that will be watched recursively
 *
 */
void Inotify::watchDirectoryRecursively(fs::path path)
{
    std::vector<boost::filesystem::path> paths;

    if (fs::exists(path)) {
        if (fs::is_directory(path)) {
            boost::system::error_code ec;
            fs::recursive_directory_iterator it(path, fs::symlink_option::recurse, ec);
            fs::recursive_directory_iterator end;

            for (; it != end; it.increment(ec)) {
                fs::path currentPath = *it;

                if (!fs::is_directory(currentPath) && !fs::is_symlink(currentPath)) {
                    continue;
                }

                paths.push_back(currentPath);
            }
        }
        paths.push_back(path);
    } else {
        throw std::invalid_argument(
            "CanĀ“t watch Path! Path does not exist. Path: " + path.string());
    }

    for (auto& path : paths) {
        watchFile(path);
    }
}
Example #2
0
AViz::AViz() 
    : QMainWindow()
{
    // Make menus in menubar
    QMenu *file = menuBar()->addMenu("&File");
    QMenu *elements = menuBar()->addMenu( "&Elements");
    QMenu *view = menuBar()->addMenu( "&View");
    QMenu *settings = menuBar()->addMenu( "&Settings");
    QMenu *data = menuBar()->addMenu("&Data");
    menuBar()->addSeparator();
    QMenu *help = menuBar()->addMenu("&Help");

    // Make a cascade menu to read files
    QMenu *openfile = file->addMenu("&Open");
    openfile->addAction("Open XYZ File...", this, SLOT(openXYZ()));
    openfile->addAction("Open File List...", this, SLOT(openList()));
    openfile->addAction("Open ViewParam File...", this, SLOT(openViewParam()));



    file->addAction( "Save ViewParam File...", this, SLOT(saveViewParam()) );
    file->addSeparator();
    file->addAction( "File List...", this, SLOT(launchFileList()) );
    file->addAction( "Animation...", this, SLOT(launchAnimation()) );
    file->addSeparator();
    m_inOutWatchModelAction = file->addAction( "Watch XYZ File", this, SLOT(watchFile()) );
    file->addSeparator();
    file->addAction( "Snap PNG File...", this, SLOT(savePNGFile()) );
    file->addSeparator();
    file->addAction( "Set Default View Param", this, SLOT(setDefaultView()));
    file->addSeparator();
    file->addAction( "E&xit", qApp, SLOT(quit()), Qt::CTRL+Qt::Key_Q );

    // Make a general view menu
    QMenu *viewpoint = view->addMenu("Set &Viewpoint");
    view->addAction( "Clipping...", this, SLOT(launchClip()) );
    view->addAction( "Slicing...", this, SLOT(launchSlice()) );

    // Make a cascade menu to set standard view points
    viewpoint->addAction( "Explicit...", this, SLOT(launchExplicit()) );
    viewpoint->addSeparator();
    viewpoint->addAction( "Default View", this, SLOT(setDefaults()) );
    viewpoint->addSeparator();
    viewpoint->addAction( "View XY +", this, SLOT(viewXYPlus()) );
    viewpoint->addAction( "View XY -", this, SLOT(viewXYMinus()) );
    viewpoint->addSeparator();
    viewpoint->addAction( "View XZ +", this, SLOT(viewXZPlus()) );
    viewpoint->addAction( "View XZ -", this, SLOT(viewXZMinus()) );
    viewpoint->addSeparator();
    viewpoint->addAction( "View YZ +", this, SLOT(viewYZPlus()) );
    viewpoint->addAction( "View YZ -", this, SLOT(viewYZMinus()) );


    // Fill a general elements menu
    m_atomsMenu = elements->addMenu("Atoms...");

    // Make a submenu for atom specifications
    m_atomsMenu->addAction( "Atoms/Molecules...", this, SLOT(launchAtoms()) );
    m_atomsMenu->addAction( "Bonds...", this, SLOT(launchBonds()) );

    m_spinsAction = elements->addAction( "Spins...", this, SLOT(launchSpins()) );
    m_liquidCrystalsAction = elements->addAction( "Liquid Crystals...", this, SLOT(launchLiquidCrystals()) );
    m_polymersMenu = elements->addMenu( "Polymers...");
    m_poresAction = elements->addAction( "Pores ...", this, SLOT(launchPores()) );
    elements->addAction( "Lights...", this, SLOT(launchLights()) );
    elements->addAction( "Annotation...", this, SLOT(launchAnnotation()) );

    // fill submenu for polymer specifications
    m_polymersMenu->addAction( "Polymers...", this, SLOT(launchPolymers()) );
    m_polymersMenu->addAction( "Bonds...", this, SLOT(launchBonds()) );


    // fill a general settings menu
    m_showHideAxesAction = settings->addAction( "Hide Axes", this, SLOT(showHideAxesCB()) );
    m_showHideContourAction = settings->addAction( "Hide Contour", this, SLOT(showHideContourCB()) );
    m_onlyContourAction = settings->addAction( "Only Contour", this, SLOT(onlyContourCB()) );

    // fill a general data menu
    data->addAction( "&Translate...", this, SLOT(launchTranslation()) );
    data->addSeparator();
    data->addAction( "Swap XY", this, SLOT(swapXY()) );
    data->addAction( "Swap XZ", this, SLOT(swapXZ()) );
    data->addAction( "Swap YZ", this, SLOT(swapYZ()) );
    data->addSeparator();
    data->addAction( "Mirror X", this, SLOT(mirrorX()) );
    data->addAction( "Mirror Y", this, SLOT(mirrorY()) );
    data->addAction( "Mirror Z", this, SLOT(mirrorZ()) );
    data->addSeparator();
    data->addAction( "Stretch XYZ...", this, SLOT(launchStretch()) );

    // fill a general help menu
    help->addAction( "&About", this, SLOT(about()), Qt::CTRL+Qt::Key_H );
    help->addAction( "License", this, SLOT(license()) );
    help->addAction( "Distribution", this, SLOT(distribute()) );

    // Now construct the main form
    // (Note having aviz as paramter for MainForm ctor
    // is "This is an ugly hack, intended to propagate the
    // address of the calling class")
    m_mainForm = new MainForm(this/*parent*/, this /*aviz*/);
    setCentralWidget(m_mainForm);

    // Construct a timer
    m_watchTimer = new QTimer(this);

    // Set initial settings
    setAtomMenus();
}