示例#1
0
bool
DevIntegrationPlugin::handleHook( BaseHook & hookData )
{
    qDebug() << PluginName << "handling hook #" << hookData.hookId();
    if ( hookData.is < Initialize > () ) {
        // we may need to initialize some qt formats here in the future...
        return true;
    }
    else if ( hookData.is < Carta::Lib::Hooks::GetInitialFileList > () ) {
        if ( ! m_enabled ) {
            return false;
        }
        Carta::Lib::Hooks::GetInitialFileList & hook =
            static_cast < Carta::Lib::Hooks::GetInitialFileList & > ( hookData );
        QString file = hook.paramsPtr->urlParams["file"];
        qDebug() << PluginName << "file" << file;
        if ( file.isEmpty() ) {
            hook.result.clear();
        }
        else {
            hook.result = QStringList{
                file
            };
        }

        // return success if we made a list of at least one filename
        return ! hook.result.isEmpty();
    }

    qWarning() << PluginName << "Sorrry, dont' know how to handle this hook";
    return false;
} // handleHook
示例#2
0
bool RegionCASA::handleHook(BaseHook & hookData){
    qDebug() << "RegionCASA plugin is handling hook #" << hookData.hookId();
    bool hookHandled = false;
    if( hookData.is<Carta::Lib::Hooks::Initialize>()) {
        hookHandled = true;
    }
    else if( hookData.is<Carta::Lib::Hooks::LoadRegion>()) {
        Carta::Lib::Hooks::LoadRegion & hook
                = static_cast<Carta::Lib::Hooks::LoadRegion &>( hookData);
        QString fileName = hook.paramsPtr->fileName;
        if ( fileName.length() > 0 ){
            //Before going to a lot of trouble, make sure we can open the file and that it has
            //the potential to be a CASA region.
            bool casaRegion = _isCASARegion( fileName );
            if ( casaRegion ){
                std::shared_ptr<Carta::Lib::Image::ImageInterface> imagePtr = hook.paramsPtr->image;
                hook.result = _loadRegion( fileName, imagePtr );
            }
            else {
                //Not a casa region so return an empty vector.
                hook.result = std::vector<std::shared_ptr<Carta::Lib::RegionInfo> >();
            }
            hookHandled = true;
        }
    }
    return hookHandled;
}
示例#3
0
bool PyCppPlug::handleHook(BaseHook & hookData)
{
    qDebug() << "PyCppPlug " << m_params.json.name << " is handling hook #" << hookData.hookId();

    if( hookData.hookId() == PreRender::staticId) {
        PreRender & hook = static_cast<PreRender &>( hookData);

        qDebug() << "Prerender hook received by PyCppPlug plugin";

        QPainter p( hook.paramsPtr->imgPtr);
        QString txt = "Py" + m_params.json.name;
        QRectF rect = hook.paramsPtr->imgPtr->rect();
        p.setFont( QFont( "Arial", 20));
        rect = p.boundingRect( rect, Qt::AlignLeft | Qt::AlignTop, txt);
        p.fillRect( rect, QColor( 0,0,0,128));
        p.setPen( QColor( "yellow"));
        p.drawText( hook.paramsPtr->imgPtr->rect(), Qt::AlignLeft | Qt::AlignTop, txt);

        QImage & img = * (hook.paramsPtr->imgPtr);
        pb_callPreRenderHook( m_pyModId, img.width(), img.height(),
                              img.bytesPerLine(), img.bits());

        return true;
    }

    if( hookData.is<Carta::Lib::Hooks::ColormapsScalarHook>()) {
        Carta::Lib::Hooks::ColormapsScalarHook & hook =
                static_cast<Carta::Lib::Hooks::ColormapsScalarHook &>( hookData);
        // get the list of raw python objects representing the colormaps
        std::vector<PyObject*> rawList = pb_colormapScalarGetColormaps( m_pyModId);
        qDebug() << "found" << rawList.size() << "colormaps";
        // wrap them up
        for( PyObject * pyCmap : rawList) {
            qDebug() << "pycmap refcnt" << Py_REFCNT(pyCmap);
            auto wrappedCmap = std::make_shared<colormap_impl::ColormapHelper>( m_pyModId, pyCmap);
            hook.result.push_back( wrappedCmap);
        }
        return true;
    }
    qWarning() << "PyCppPlug:: Sorrry, don't know how to handle this hook" << hookData.hookId();
    return false;
}
示例#4
0
bool
QImagePlugin::handleHook( BaseHook & hookData )
{
    qDebug() << "QImagePlugin is handling hook #" << hookData.hookId();
    if ( hookData.is < Initialize > () ) {
        // we may need to initialize some qt formats here in the future...
        return true;
    }
    else if ( hookData.is < LoadAstroImage > () ) {
        LoadAstroImage & hook = static_cast < LoadAstroImage & > ( hookData );
        auto fname = hook.paramsPtr->fileName;

        hook.result = QImageII::load( fname );

        // return true if result is not null
        return hook.result != nullptr;
    }

    qWarning() << "QImagePlugin: Sorrry, dont' know how to handle this hook";
    return false;
} // handleHook
示例#5
0
bool CasaImageLoader::handleHook(BaseHook & hookData)
{
    qDebug() << "CasaImageLoader plugin is handling hook #" << hookData.hookId();
    if( hookData.is<Carta::Lib::Hooks::Initialize>()) {
        // Register FITS and Miriad image types
        casa::FITSImage::registerOpenFunction();
        casa::MIRIADImage::registerOpenFunction();
        return true;
    }

    else if( hookData.is<Carta::Lib::Hooks::LoadAstroImage>()) {
        Carta::Lib::Hooks::LoadAstroImage & hook
                = static_cast<Carta::Lib::Hooks::LoadAstroImage &>( hookData);
        auto fname = hook.paramsPtr->fileName;
        hook.result = loadImage( fname);
        // return true if result is not null
        return hook.result != nullptr;
    }

    qWarning() << "Sorrry, dont' know how to handle this hook";
    return false;
}
示例#6
0
bool GenericPlugin::handleHook(BaseHook &hookData)
{
    //qDebug() << "GenericPlugin is handling hook #" << hookData.hookId();
    if( hookData.is<Initialize>()) {
//        Initialize & initHook = static_cast<Initialize &>( hookData);

        qDebug() << "Woohoo, generic plugin received initialize request.";

//        qDebug() << "You should see debug from Initialize below";
//        initHook.debug();

        return true;
    }

    if( hookData.hookId() == PreRender::staticId ) {
//        PreRender & hook = static_cast<PreRender &>( hookData);

        //qDebug() << "Prerender hook received by generic plugin";
        //qDebug() << "  " << hook.paramsPtr->viewName;
        //qDebug() << "  " << hook.paramsPtr->imgPtr->size();

        /*QPainter p( hook.paramsPtr->imgPtr);
        QString txt = "(C) Generic Plugin";
        QRectF rect = hook.paramsPtr->imgPtr->rect();
        p.setFont( QFont( "Arial", 20));
        rect = p.boundingRect( rect, Qt::AlignRight | Qt::AlignBottom, txt);
        p.fillRect( rect, QColor( 0,0,0,128));
        p.setPen( QColor( "white"));
        p.drawText( hook.paramsPtr->imgPtr->rect(), Qt::AlignRight | Qt::AlignBottom, txt);
*/
        return true;
    }


    qDebug() << "Sorrry, dont' know how to handle this hook";
    return false;
}
示例#7
0
bool
HpcImageRenderServicePlugin::handleHook( BaseHook & hookData )
{
    qDebug() << "HpcImageRenderServicePlugin is handling hook #" << hookData.hookId();
    if ( hookData.is < Carta::Lib::Hooks::Initialize > () ) {
        // insert initialization stuff here that depends on core running
        return true;
    }
    else if ( hookData.is < Carta::Lib::Hooks::GetImageRenderService > () ) {
        Carta::Lib::Hooks::GetImageRenderService & hook =
            static_cast < Carta::Lib::Hooks::GetImageRenderService & > ( hookData );
        try {
            hook.result = std::make_shared < MyImageRenderService > ();
        }
        catch ( ... ) {
            return false;
        }

        return true;
    }

    qWarning() << "HpcImageRenderServicePlugin: Sorrry, dont' know how to handle this hook";
    return false;
} // handleHook