New Module Compilation Problems

Forum for software developers to discuss BCI2000 software development
Locked
jpardo
Posts: 8
Joined: 23 Sep 2011, 13:35

New Module Compilation Problems

Post by jpardo » 18 Nov 2011, 15:39

Hi,

I'm trying to create a new application module for BCI2000. I used the NewBCI2000Module.exe utility and created a solution file for Microsoft Visual Studio 2010. Right after I create it it compiles with no problems. However, when I add blank .cpp and .h files to my project, it fails to compile. The compiler out puts an error "c:\users\juan\documents\bci2000\src\shared\modules\CoreModule.h(99): fatal error C1189: #error : Unknown MODTYPE value"

The only thing I've done besides add the blank files is modify the CMakeLists.txt so cmake can create a solution later on.

Does anyone have any idea on what could be going on?

Here is the only code I have, which was mostly generated by NewBCI2000Module.exe

Code: Select all

#include "PCHIncludes.h"
#pragma hdrstop

#ifdef __BORLANDC__

#include <vcl.h>
#include "CoreModuleVCL.h"

#else // __BORLANDC__

// Not using borland, we'll use QT instead
#include "CoreModuleQT.h"
#include <QApplication>

#endif // __BORLANDC__

#define APP_TITLE "ClinicalDAQ"

#ifdef _WIN32

int WINAPI
WinMain( HINSTANCE, HINSTANCE, LPSTR, int )
{
#ifdef __BORLANDC__

  try
  {
	Application->Initialize();
	Application->Title = APP_TITLE;
	CoreModuleVCL().Run( _argc, _argv );
  }
  catch (Exception &exception)
  {
	Application->ShowException(&exception);
  }
  return 0;

#else // __BORLANDC__
  QApplication::setApplicationName( APP_TITLE );
  bool success = CoreModuleQT().Run( __argc, __argv );
  return success ? 0 : -1;

#endif // __BORLANDC__
}

#else // _WIN32

int main( int argc, char *argv[] )
{
  QApplication::setApplicationName( APP_TITLE );
  bool success = CoreModuleQT().Run( argc, argv );
  return success ? 0 : -1;
}

#endif // _WIN32
Here is my Cmake file, which I copied and modified from the Operator module, to make sure I wasn't doing anything wrong.

Code: Select all


# Set the executable name
SET( EXECUTABLE_NAME ClinicalDAQ )

# DEBUG
MESSAGE( "-- Adding Project: ${EXECUTABLE_NAME}" )

# Set the project specific sources
SET( SRC_PROJECT
  main.cpp            # You probably will not need to edit this file
  MainWindow.cpp
  GraphicsScene.cpp
  Marker.cpp
  # MyNewCustomFilter.cpp    # but you should add new filters to specify the module's behaviour
)

SET( HDR_PROJECT
  MainWindow.h
  GraphicsScene.h
  Marker.h
  # MyNewCustomFilter.cpp    # but you should add new filters to specify the module's behaviour
)

# Use the BCI2000_INCLUDE macro if you need to link with frameworks from /src/extlib:
# BCI2000_INCLUDE( "3DAPI" )
BCI2000_INCLUDE( "MATH" )

# Wrap the Qt files
QT4_WRAP_UI( GENERATED_UI
  MainWindow.ui
)

QT4_WRAP_CPP( GENERATED_MOC 
  MainWindow.h
  GraphicsScene.h
  Marker.h
)
SET( GENERATED
  ${GENERATED_UI}
  ${GENERATED_MOC}
)

# Tell the macro to link against the math libraries in extlib
BCI2000_INCLUDE( "MATH" )


# Generate the required framework
INCLUDE( ${BCI2000_CMAKE_DIR}/frameworks/Core.cmake )

# Add missing framework files
SET( SRC_BCI2000_FRAMEWORK
  ${SRC_BCI2000_FRAMEWORK}
  ${BCI2000_SRC_DIR}/shared/bcistream/BCIError_guiapp.cpp
  ${BCI2000_SRC_DIR}/shared/utils/DisplayFilter.cpp
  ${BCI2000_SRC_DIR}/shared/utils/DecimationFilter.cpp
  ${BCI2000_SRC_DIR}/shared/utils/Settings.cpp 
  ${BCI2000_SRC_DIR}/shared/gui/SignalDisplay.cpp
  ${BCI2000_SRC_DIR}/shared/gui/AboutBox.cpp
  ${BCI2000_SRC_DIR}/shared/gui/ColorListChooser.cpp
)
SET( HDR_BCI2000_FRAMEWORK
  ${HDR_BCI2000_FRAMEWORK}
  ${BCI2000_SRC_DIR}/shared/utils/DisplayFilter.h
  ${BCI2000_SRC_DIR}/shared/utils/DecimationFilter.h
  ${BCI2000_SRC_DIR}/shared/utils/Settings.h 
  ${BCI2000_SRC_DIR}/shared/gui/SignalDisplay.h
  ${BCI2000_SRC_DIR}/shared/gui/AboutBox.h
  ${BCI2000_SRC_DIR}/shared/gui/ColorListChooser.h
)

SOURCE_GROUP( Source\\BCI2000_Framework\\shared\\bcistream FILES
  ${BCI2000_SRC_DIR}/shared/bcistream/BCIError_guiapp.cpp 
)
SOURCE_GROUP( Source\\BCI2000_Framework\\shared\\utils FILES
  ${BCI2000_SRC_DIR}/shared/utils/DisplayFilter.cpp
  ${BCI2000_SRC_DIR}/shared/utils/DecimationFilter.cpp
  ${BCI2000_SRC_DIR}/shared/utils/Settings.cpp 
)
SOURCE_GROUP( Source\\BCI2000_Framework\\shared\\gui FILES
  ${BCI2000_SRC_DIR}/shared/gui/SignalDisplay.cpp
  ${BCI2000_SRC_DIR}/shared/gui/AboutBox.cpp
  ${BCI2000_SRC_DIR}/shared/gui/ColorListChooser.cpp
)
SOURCE_GROUP( Headers\\BCI2000_Framework\\shared\\utils FILES
  ${BCI2000_SRC_DIR}/shared/utils/DisplayFilter.h
  ${BCI2000_SRC_DIR}/shared/utils/DecimationFilter.h
  ${BCI2000_SRC_DIR}/shared/utils/Settings.h 
)
SOURCE_GROUP( Headers\\BCI2000_Framework\\shared\\gui FILES
  ${BCI2000_SRC_DIR}/shared/gui/SignalDisplay.h
  ${BCI2000_SRC_DIR}/shared/gui/AboutBox.h
  ${BCI2000_SRC_DIR}/shared/gui/ColorListChooser.h
)


# Set the Project Source Groups
SOURCE_GROUP( Source\\Project FILES ${SRC_PROJECT} )
SOURCE_GROUP( Headers\\Project FILES ${HDR_PROJECT} )

# Set Generated Source Groups
SOURCE_GROUP( Generated FILES ${GENERATED} )

# Setup Extlib Dependencies
BCI2000_SETUP_EXTLIB_DEPENDENCIES( SRC_BCI2000_FRAMEWORK HDR_BCI2000_FRAMEWORK LIBS FAILED )

# Setup GUI Imports
BCI2000_SETUP_GUI_IMPORTS( SRC_BCI2000_FRAMEWORK HDR_BCI2000_FRAMEWORK )

IF( NOT FAILED )
  BCI2000_ADD_TO_INVENTORY( Operator ${EXECUTABLE_NAME} )
  
  # Add the executable to the project
  ADD_EXECUTABLE( 
    ${EXECUTABLE_NAME} 
    WIN32
    ${SRC_BCI2000_FRAMEWORK} ${HDR_BCI2000_FRAMEWORK} 
    ${SRC_PROJECT} ${HDR_PROJECT} 
    ${GENERATED} 
  )
  # Add Pre-processor defines
  SET_PROPERTY( TARGET ${EXECUTABLE_NAME} APPEND PROPERTY COMPILE_FLAGS "-DUSE_QT" )
  TARGET_LINK_LIBRARIES( ${EXECUTABLE_NAME} )
  # Link against the Qt Libraries and other dependencies
  TARGET_LINK_LIBRARIES( ${EXECUTABLE_NAME} ${QT_LIBRARIES} ${LIBS} )
ENDIF( NOT FAILED )

jhill
Posts: 31
Joined: 17 Nov 2009, 15:15

Re: New Module Compilation Problems

Post by jhill » 21 Nov 2011, 12:22

Are you following the instructions on our developers' Quickstart Guide ? I would recommend you start from scratch and go through the steps listed there, only modifying the procedure once you've got it to work.

I'm confused as to why you're adapting a CMakeLists.txt file from the one belonging to the Operator. The Operator module is an entirely different species of animal from a core module (signal source, signal-processing, or application). NewBCI2000Module only helps you build core modules, and that seems to be what you want to do (you say you're building an "application" module, and I assume you're using that word the same way we do... although the name you've chosen, "ClinicalDAQ" makes me slightly suspect you might want a signal source module)

NewBCI2000Module already creates a CMakeLists.txt file for you, which should work for whichever type of core module you've chosen (read NewBCI2000Module's text output to verify where the cmake file is). And you say that that compiled for you initially? If so, that's good: so now, to add new files, you should only need to make minimal changes to CMakeLists.txt—replacing it with a modified Operator/CMakeLists.txt definitely does not count as minimal, as a before/after comparison should make apparent. The minimal changes (creating and adding your own .cpp and .h pair) can even be automated, using a second tool called NewBCI2000Filter. Again, the Quickstart Guide has all the instructions.

Hope this helps, --jez

jpardo
Posts: 8
Joined: 23 Sep 2011, 13:35

Re: New Module Compilation Problems

Post by jpardo » 22 Nov 2011, 16:37

Thanks for replying!

I started again from scratch carefully following the quickstart guide and got my code up and running again, however, I'm still not quite where I want to be. I ran into the following issues:

1) Every time I run CMake, the new build solution erases the files I've added to my project (it only keeps the .c and .h files that I've added with the NewModule and NewFilter utilities).
2) There are linker errors (LNK2001 unresolved external) that can only be resolved when I change the line "BCI2000_ADD_APPLICATION_MODULE()" in my CMakeList.txt file to "BCI2000_ADD_TOOLS_GUIAPP( )", compiling and then changing it back to "BCI2000_ADD_APPLICATION_MODULE()".
3)QImage from Qt gives me a runtime error saying it cannot find QImage (I've run my code in QT creator and against the latest build of the Qt library so I know it works). Every other Qt element works fine.
4) I was forced to re-write the autogenerated code in the main loop to something similar to what is used in main.cpp in the BCI2000Launcher module. I'm not using CoreModuleQT so I'm not quite sure if this has something to do with how QImage is called.

What I'm trying to do:
I'm trying to write an stand-alone application similar to BCI2000Viewer that can read BCI2000 files and perform some analysis on the signals off-line, in addition to some other fucntions that don't depend on the BCI2000 framework. In the future I plan to integrate it with SIGFRIED, however, as of now my main goal is to be able to read .dat files and perform analysis which will be visually available to the user in the GUI that I created in Qt designer. So far I've created a stand-alone GUI in QT creator and I'm trying to move my project to Microsoft Visual Studio 2010, so I can use the BCI2000 framework.

Thanks again for all your help!

Juan P.


Here is the code to my main function:

Code: Select all

#include <QtGui/QApplication>
#include "ExceptionCatcher.h"
#include "MainWindow.h"

#ifdef _WIN32
# include <Windows.h>

int main( int, char*[] );

int WINAPI
WinMain( HINSTANCE, HINSTANCE, LPSTR, int )
{
  return main( __argc, __argv );
}
#endif // _WIN32

int main(int argc, char *argv[])
{
  QApplication a(argc, argv);
  a.setOrganizationName( "WUSTL" );
  a.setApplicationName( "ClinicalDAQ" );
  MainWindow w;
  w.show();

  std::string message = "Aborting ";
  message += a.applicationName().toLocal8Bit().constData();
  FunctionCall< int() >
    call( &QApplication::exec );
  bool finished = ExceptionCatcher()
    .SetMessage( message )
    .Run( call );
  return finished ? call.Result() : -1;
}

Here's the code to my MainWindow:

Code: Select all

#include "PCHIncludes.h"
#pragma hdrstop

#include "MainWindow.h"
#include "BCIError.h"
#include "ui_MainWindow.h"
#include "Marker.h"
#include "GraphicsScene.h"
#include <QtGui>

using namespace std;

const int IdRole = Qt::UserRole;
int Gsize;
int Gshp_inx;

QColor col;
int rbID;



MainWindow::MainWindow(QWidget *parent):
    QMainWindow(parent),ui(new Ui::MainWindow)
{
    ui->setupUi(this);


    Escene=new GraphicsScene();  //Sets up Scene to use in QGraphicsView
    Escene->setSceneRect(QRect(0, 0, 661, 381));

    VEscene=new QGraphicsScene();  //Sets up Scene to use in QGraphicsView
    VEscene->setSceneRect(QRect(0, 0, 461, 301));

    Sscene=new GraphicsScene();  //Sets up Scene to use in QGraphicsView
    Sscene->setSceneRect(QRect(0, 0, 661, 381));

    SCPscene=new GraphicsScene();  //Sets up Scene to use in QGraphicsView
    SCPscene->setSceneRect(QRect(0, 0, 661, 381));

    Eview = ui->ECSView;            //Creates pointer to ECSView ui element
    VEview =ui->VSECSView;            //Creates pointer to ECSView ui element
    Sview=ui->SigfriedView;         //Creates pointer to SigfriedView ui element
    SCPview=ui->SCPView;         //Creates pointer to SigfriedView ui element


    Eview->setScene(Escene);
    Eview->setDragMode(QGraphicsView::RubberBandDrag);  //Allows you to select multiple items click-dragging the cursor
    Eview->setRenderHints(QPainter::Antialiasing);      //Enable antialiasing

    VEview->setScene(VEscene);
    VEview->setRenderHints(QPainter::Antialiasing);      //Enable antialiasing

    Sview->setScene(Sscene);
    Sview->setDragMode(QGraphicsView::RubberBandDrag);  //Allows you to select multiple items click-dragging the cursor
    Sview->setRenderHints(QPainter::Antialiasing);      //Enable antialiasing

    Sview->setScene(Sscene);
    Sview->setDragMode(QGraphicsView::RubberBandDrag);  //Allows you to select multiple items click-dragging the cursor
    Sview->setRenderHints(QPainter::Antialiasing);      //Enable antialiasing

    FileNameRec1="";  //FileNameRec records the last valid image file path
    FileNameRec2="";  //setting as blank at the start
    FileNameRec3="";

    //Read Default values
    Gsize=ui->SizeSpinBox->value();
    Gshp_inx=ui->ShapeMenu->currentIndex();
    rbID=radioButtonSelected();

    switch(rbID)
    {
    case 1:col=Qt::yellow;
        break;
    case 2:col=Qt::darkGreen;
        break;
    case 3:col=Qt::darkBlue;
        break;
    case 4:col=QColor(255,140,0,255);
        break;
    case 5:col=Qt::magenta;
        break;
    case 6:col=Qt::black;
        break;
    case 7:col=Qt::white;
        break;
    }


    QObject::connect(Escene, SIGNAL(markerPos(qreal,qreal)), this, SLOT(on_addMarker(qreal,qreal)));
    QObject::connect(Escene, SIGNAL(selectionChanged()), this, SLOT(on_selection()));
    qApp->installEventFilter(this);
}


MainWindow::~MainWindow()
{
    delete Escene;
    delete Eview;
    delete Sscene;
    delete Sview;
    delete ui;

}

bool MainWindow::eventFilter(QObject *obj, QEvent *event)  //using eventfilter to implement the Mousemove signal
{

        if (event->type() == QEvent::MouseMove)
        {
            if (Eview->underMouse()==true) //restricting the operational area to Eview
            {
              QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
              Sceneposition=Eview->mapToScene(mouseEvent->pos());
              ui->xdisplay2->setText(Cursorx.setNum(Sceneposition.x())); //displayed in x box
              ui->ydisplay2->setText(Cursory.setNum(Sceneposition.y())); //displayed in y box
    //the coordinates are with respect to the object the cursor is on.
            }
            else  //display "N/A" when out of range
            {
                ui->xdisplay2->setText("N/A");
                ui->ydisplay2->setText("N/A");
            }
        }


    return false;
}



void MainWindow::on_ImageSelectButton1_clicked()
{
    QString fileName1 = QFileDialog::getOpenFileName(this,tr("Open File"), QDir::currentPath()); //Open File Dialog


    if (!fileName1.isEmpty())                    //Check to see if a file is selected. If a file is selected pass image create QImage object
    {
            QImage image1(fileName1);             //Load Image

            if (image1.isNull())                 //If not an image file display error
            {
                QMessageBox::information(this, tr("Sigfried Viewer"), tr("Cannot load %1.").arg(fileName1));

                return;
            }


            FileNameRec1=fileName1; //storing the valid namepath for future reference

            ui->ImageDirText1->setText(FileNameRec1);

            QPixmap img1 = QPixmap::fromImage(image1);
            Sscene->setBackgroundBrush(img1.scaled(661,381,Qt::IgnoreAspectRatio,Qt::SmoothTransformation));
            Sview->setScene(Sscene);


            Sview->setGeometry(QRect(310, 10, 661, 381));
            Sview->show();

     }

}


void MainWindow::on_ImageSelectButton2_clicked()
{

    QString fileName2 = QFileDialog::getOpenFileName(this,tr("Open File"), QDir::currentPath()); //Open File Dialog


    if (!fileName2.isEmpty())                    //Check to see if a file is selected. If a file is selected pass image create QImage object
    {
            QImage image2(fileName2);             //Load Image

            if (image2.isNull())                 //If not an image file display error
            {
                QMessageBox::information(this, tr("ECS Viewer"), tr("Cannot load %1.").arg(fileName2));

                return;
            }


            FileNameRec2=fileName2;

            ui->ImageDirText2->setText(FileNameRec2);

            QPixmap img2 = QPixmap::fromImage(image2);
            Escene->setBackgroundBrush(img2.scaled(661,381,Qt::IgnoreAspectRatio,Qt::SmoothTransformation));
            Eview->setScene(Escene);

            Eview->setGeometry(QRect(310, 10, 661, 381));
            Eview->show();

           //VEscene->setBackgroundBrush(img2.scaled(461,301,Qt::KeepAspectRatioByExpanding,Qt::SmoothTransformation));
           // VEview->setScene(VEscene);

           //VEview->setGeometry(QRect(0, 0, 465, 305));
           //VEview->show();

     }


}

void MainWindow::on_ImageSelectButton3_clicked()
{

    QString fileName3 = QFileDialog::getOpenFileName(this,tr("Open File"), QDir::currentPath()); //Open File Dialog


    if (!fileName3.isEmpty())                    //Check to see if a file is selected. If a file is selected pass image create QImage object
    {
            QImage image3(fileName3);             //Load Image

            if (image3.isNull())                 //If not an image file display error
            {
                QMessageBox::information(this, tr("SCP Viewer"), tr("Cannot load %1.").arg(fileName3));

                return;
            }


            FileNameRec3=fileName3;

            ui->ImageDirText3->setText(FileNameRec3);

            QPixmap img3 = QPixmap::fromImage(image3);
            SCPscene->setBackgroundBrush(img3.scaled(661,381,Qt::IgnoreAspectRatio,Qt::SmoothTransformation));
            SCPview->setScene(SCPscene);

            SCPview->setGeometry(QRect(310, 10, 661, 381));
            SCPview->show();

     }


}



void MainWindow::on_YellowMarker_clicked()
{

    Marker *marker;

    QList<QGraphicsItem *> items =Escene->items();
    QListIterator<QGraphicsItem *> i(items);

    while(i.hasNext())
    {
        marker=(Marker *)i.next();
        marker->setOutlineColor(Qt::yellow);

    }

    Eview->update();
    col=Qt::yellow;

}
void MainWindow::on_BlueMarker_clicked()
{

    Marker *marker;

    QList<QGraphicsItem *> items =Escene->items();
    QListIterator<QGraphicsItem *> i(items);

    while(i.hasNext())
    {
        marker=(Marker *)i.next();
        marker->setOutlineColor(Qt::darkBlue);

    }

    Eview->update();
    col=Qt::darkBlue;

}
void MainWindow::on_GreenMarker_clicked()
{

    Marker *marker;

    QList<QGraphicsItem *> items =Escene->items();
    QListIterator<QGraphicsItem *> i(items);

    while(i.hasNext())
    {
        marker=(Marker *)i.next();
        marker->setOutlineColor(Qt::darkGreen);

    }

    Eview->update();
    col=Qt::green;

}
void MainWindow::on_MagentaMarker_clicked()
{

    Marker *marker;

    QList<QGraphicsItem *> items =Escene->items();
    QListIterator<QGraphicsItem *> i(items);

    while(i.hasNext())
    {
        marker=(Marker *)i.next();
        marker->setOutlineColor(Qt::magenta);

    }

    Eview->update();
    col=Qt::magenta;

}
void MainWindow::on_OrangeMarker_clicked()
{

    Marker *marker;

    QList<QGraphicsItem *> items =Escene->items();
    QListIterator<QGraphicsItem *> i(items);

    while(i.hasNext())
    {
        marker=(Marker *)i.next();
        marker->setOutlineColor(QColor(255,140,0,255));

    }

    Eview->update();
    col=QColor(255,140,0,255);

}
void MainWindow::on_BlackMarker_clicked()
{

    Marker *marker;

    QList<QGraphicsItem *> items =Escene->items();
    QListIterator<QGraphicsItem *> i(items);

    while(i.hasNext())
    {
        marker=(Marker *)i.next();
        marker->setOutlineColor(Qt::black);

    }

    Eview->update();
    col=Qt::black;

}
void MainWindow::on_WhiteMarker_clicked()
{

    Marker *marker;

    QList<QGraphicsItem *> items =Escene->items();
    QListIterator<QGraphicsItem *> i(items);

    while(i.hasNext())
    {
        marker=(Marker *)i.next();
        marker->setOutlineColor(Qt::white);

    }

    Eview->update();
    col=Qt::white;

}



void MainWindow::on_ShapeMenu_activated(int index)
{
    Marker *marker;
    Marker::Shape shape = Marker::Shape(index-1);//ui->ShapeMenu->itemData(
                 //ui->ShapeMenu->currentIndex(), IdRole).toInt());

    QList<QGraphicsItem *> items =Escene->items();
    QListIterator<QGraphicsItem *> i(items);

    while(i.hasNext())
    {
        marker=(Marker *)i.next();
        marker->setShape(shape);
    }

    Eview->update();
    Gshp_inx=ui->ShapeMenu->currentIndex();
}

void MainWindow::on_SizeSpinBox_valueChanged(int index)
{
    Marker *marker;
    QList<QGraphicsItem *> items =Escene->items();
    QListIterator<QGraphicsItem *> i(items);

    while(i.hasNext())
    {
        marker=(Marker *)i.next();
        marker->setSize(ui->SizeSpinBox->value());
    }

    Eview->update();
    Gsize=ui->SizeSpinBox->value();
    Gshp_inx=ui->ShapeMenu->currentIndex();
}



short MainWindow::getSize()
{
    return Gsize;
}
QColor MainWindow::getColor()
{
    return col;
}


int MainWindow::getShape()
{
    return Gshp_inx;
}

int MainWindow::radioButtonSelected()
{
    if(ui->YellowMarker->isChecked())
        return 1;
    else if(ui->GreenMarker->isChecked())
        return 2;
    else if(ui->BlueMarker->isChecked())
        return 3;
    else if(ui->OrangeMarker->isChecked())
        return 4;
    else if(ui->MagentaMarker->isChecked())
        return 5;
    else if(ui->BlackMarker->isChecked())
        return 6;
    else if(ui->WhiteMarker->isChecked())
        return 7;
    else
        return 0;
}

void MainWindow::on_NoElectrodesSpinBox_valueChanged(int ElecValue)
{
        ElecValue=ui->NoElectrodesSpinBox->value();
        ui->ElectrodesTable->setRowCount(ElecValue);
}

void MainWindow::on_ImageDirText2_returnPressed()
{



    QString fileName2 = ui->ImageDirText2->text();

    if (!fileName2.isEmpty())                    //Check to see if a file is selected. If a file is selected pass image create QImage object
    {
            QImage image2(fileName2);             //Load Image

            if (image2.isNull())                 //If not an image file display error
            {
                QMessageBox::information(this, tr("ECS Viewer"), tr("Cannot load %1.").arg(fileName2));

                ui->ImageDirText2->setText(FileNameRec2); //restoring to last valid filename
                return;
            }

            FileNameRec2=fileName2; //storing for future reference

            //view = new QGraphicsView(ui->ECSView); //Creates pointer to ECSView ui element

            QPixmap img2 = QPixmap::fromImage(image2);
            Escene->setBackgroundBrush(img2.scaled(661,381));
            Eview->setScene(Escene);

            Eview->setGeometry(QRect(310, 10, 661, 381));
            Eview->show();

     }

}

void MainWindow::on_ImageDirText1_returnPressed()
{


    QString fileName1 = ui->ImageDirText1->text();

    if (!fileName1.isEmpty())                    //Check to see if a file is selected. If a file is selected pass image create QImage object
    {
            QImage image1(fileName1);             //Load Image

            if (image1.isNull())                 //If not an image file display error
            {
                QMessageBox::information(this, tr("ECS Viewer"), tr("Cannot load %1.").arg(fileName1));

                ui->ImageDirText1->setText(FileNameRec1);  //restoring to the last valid name
                return;
            }

            FileNameRec1=fileName1; //storing for future reference

            //view = new QGraphicsView(ui->ECSView); //Creates pointer to ECSView ui element

            QPixmap img1 = QPixmap::fromImage(image1);
            Sscene->setBackgroundBrush(img1.scaled(661,381));
            Sview->setScene(Sscene);

            Sview->setGeometry(QRect(310, 10, 661, 381));
            Sview->show();

     }
}

void MainWindow::on_ImageDirText3_returnPressed()
{



    QString fileName3 = ui->ImageDirText3->text();

    if (!fileName3.isEmpty())                    //Check to see if a file is selected. If a file is selected pass image create QImage object
    {
            QImage image3(fileName3);             //Load Image

            if (image3.isNull())                 //If not an image file display error
            {
                QMessageBox::information(this, tr("ECS Viewer"), tr("Cannot load %1.").arg(fileName3));

                ui->ImageDirText3->setText(FileNameRec3); //restoring to last valid filename
                return;
            }

            FileNameRec2=fileName3; //storing for future reference

            //view = new QGraphicsView(ui->ECSView); //Creates pointer to ECSView ui element

            QPixmap img3 = QPixmap::fromImage(image3);
            SCPscene->setBackgroundBrush(img3.scaled(661,381));
            SCPview->setScene(SCPscene);

            SCPview->setGeometry(QRect(310, 10, 661, 381));
            SCPview->show();

     }

}




void MainWindow::on_tabWidget_selected(const QString &arg1)
{
    Marker *marker;
    QList<QGraphicsItem *> items =Escene->items();
    QListIterator<QGraphicsItem *> i(items);

    while(i.hasNext())
    {
        marker=(Marker *)i.next();
        marker->setSelected(false);
    }

    Eview->update();

    QString fileName = "ECSview.png";
    QByteArray bytes;
    QBuffer buffer(&bytes);
    buffer.open(QIODevice::WriteOnly);
    QPixmap pixMap = QPixmap::grabWidget(Eview);

    VEscene->setBackgroundBrush(pixMap.scaled(461,301,Qt::IgnoreAspectRatio,Qt::SmoothTransformation));

}

void MainWindow::on_addMarker(qreal xpos1, qreal ypos1)
{
    QString xval;
    QString yval;

    ui->xdisplay1->setText(xval.setNum(xpos1));
    ui->ydisplay1->setText(yval.setNum(ypos1));
}

void MainWindow::on_selection()
{
    QString xval;
    QString yval;

    Marker *marker;
    QList<QGraphicsItem *> items =Escene->selectedItems();
    QListIterator<QGraphicsItem *> i(items);


    if (i.hasNext()==true && items.size()==1)
       {
          marker=(Marker *)i.next();

          ui->xdisplay1->setText(xval.setNum(marker->getXpos()));
          ui->ydisplay1->setText(yval.setNum(marker->getYpos()));
       }

       else
       {
          ui->xdisplay1->setText("");
          ui->ydisplay1->setText("");
       }
}


void MainWindow::on_SCPLoadDataButton_clicked()
{

}

MainWindow* MainWindow::self()
{
    return this;
}

jhill
Posts: 31
Joined: 17 Nov 2009, 15:15

Re: New Module Compilation Problems

Post by jhill » 22 Nov 2011, 19:09

Aha, some things become clearer. NewBCI2000Module is specifically for modules, where "module" means a component of the realtime pipeline that plays one of four highly specialized and delineated roles: Operator, SignalSource, SignalProcessing and, yes, "Application" (but that term means something very specific in this context).

For setting up a standalone app (in BCI2000-speak, a "tool"), NewBCI2000Module is probably not the best thing to use. For that, I would probably put together the CMakeLists.txt file from scratch using BCI2000Viewer as a template. BCI2000_ADD_TOOLS_GUIAPP() does sound, by its name, like it might be the right function to call in that file, rather than BCI2000_ADD_APPLICATION_MODULE(). But since I'm unfamiliar with the former, I'll have to bounce your question back to Jürgen.

mellinger
Posts: 1065
Joined: 12 Feb 2003, 11:06

Re: New Module Compilation Problems

Post by mellinger » 23 Nov 2011, 07:09

Hi,

your code looks fine. As suggested by Jez, it is probably best to use a modified CMakeLists.txt from a "tool". There, BCI2000Viewer comes closest, so you might start out by using that as a template.
1) Every time I run CMake, the new build solution erases the files I've added to my project (it only keeps the .c and .h files that I've added with the NewModule and NewFilter utilities).
When you say that files get "erased" from the project by CMake, I'm not sure whether I understand your problem. It is the purpose of CMake to create IDE projects from CMakeLists.txt files, so when you add a file in the IDE rather than the CMakeLists.txt file, and then run CMake, it will create a new IDE project file from the CMakeLists.txt file, without the new file, because that file is not listed in the CMakeLists.txt file. So, when using CMake, add new files to the CMakeLists.txt file of your project, and re-run CMake to create an updated project file.

When you want to use the IDE to add or remove files then you cannot use CMake at all. It will not back-translate IDE project files into CMakeLists.txt files.
2) There are linker errors (LNK2001 unresolved external) that can only be resolved when I change the line "BCI2000_ADD_APPLICATION_MODULE()" in my CMakeList.txt file to "BCI2000_ADD_TOOLS_GUIAPP( )", compiling and then changing it back to "BCI2000_ADD_APPLICATION_MODULE()".
Use BCI2000Viewer as a template project. You are creating a GUI application, not a BCI2000 application module.
3)QImage from Qt gives me a runtime error saying it cannot find QImage (I've run my code in QT creator and against the latest build of the Qt library so I know it works). Every other Qt element works fine.
What do you mean by saying "QImage cannot find QImage"?
4) I was forced to re-write the autogenerated code in the main loop to something similar to what is used in main.cpp in the BCI2000Launcher module. I'm not using CoreModuleQT so I'm not quite sure if this has something to do with how QImage is called.
The code looks fine but I don't understand who or what "forced" you to rewrite it? The only difference between the Qt template code, and your copied-and-pasted code is that the modified code runs the application's event loop inside an ExceptionCatcher instance, which has the purpose to catch uncaught exceptions and to display a meaningful error message rather than the uninformative default Windows crash dialog. This should not affect any other aspect of your application's code. Also, there is no relation to CoreModuleQT, which is used by BCI2000 core modules, not by BCI2000 tools/GUIapps.

Best regards,
Juergen

jpardo
Posts: 8
Joined: 23 Sep 2011, 13:35

Re: New Module Compilation Problems

Post by jpardo » 23 Nov 2011, 15:18

Hi Juergen,

I completely agree with you and understand what CMake is doing now. I fixed my problem by NOT adding files using the IDE and just letting Cmake build the solution using the files I added to the src directory. It was a bit confusing for me because I would add files using the IDE and then I would update the CMakeLists.txt file accordingly, and then I would run CMake. For some reason this doesn't work and the appropriate way of doing things is by starting a CMakeLists.txt file from scratch, and then running CMake allowing it to identify the already existing files found in the src directory.

As soon as I fixed this, all linker errors were resolved and all the generated files were in the correct directories.

I'm still left with one problem though and that is Qt, specifically QImage. When I try to load an image into my program it fails to do so. The output console shows me during runtime:
'ClinicalDAQ.exe': Loaded 'ImageAtBase0x11860000', Loading disabled by Include/Exclude setting.
'ClinicalDAQ.exe': Unloaded 'ImageAtBase0x11860000'
but no errors during compile time. Does it have to do with the stripped down version of Qt included with BCI2000?

mellinger
Posts: 1065
Joined: 12 Feb 2003, 11:06

Re: New Module Compilation Problems

Post by mellinger » 24 Nov 2011, 06:28

Hi,
'ClinicalDAQ.exe': Loaded 'ImageAtBase0x11860000', Loading disabled by Include/Exclude setting.
'ClinicalDAQ.exe': Unloaded 'ImageAtBase0x11860000'
This has nothing to do with Qt. It is a message from the VisualStudio Debugger. (Generally, it helps to google for the exact wording of messages in order to understand what they mean.)

Regards,
Juergen

jpardo
Posts: 8
Joined: 23 Sep 2011, 13:35

Re: New Module Compilation Problems

Post by jpardo » 01 Dec 2011, 16:46

Hi Juergen,

Yes, you're right, the messages are from the debugger. I was a bit confused on what they meant. Anyway, I discovered that my problem with QImage is unique to Qt 4.6 the image support for jpeg using the Qt plug-in (http://developer.qt.nokia.com/forums/viewthread/320). Apparently the problem is solved when you use Qt 4.7.4 (which is what I was using before I transferred my project from Qt creator to MSVC and BCI2000). For now I'll use .png images to avoid this error.

Are there any plans to update Qt to version 4.7.4 in BCI2000?

Thanks again for your time and help!

Juan P.

mellinger
Posts: 1065
Joined: 12 Feb 2003, 11:06

Re: New Module Compilation Problems

Post by mellinger » 16 Dec 2011, 12:48

Hi,
my problem with QImage is unique to Qt 4.6
BCI2000 uses Qt 4.7.0. The problem with JPEG support comes from the fact that BCI2000 links statically to Qt, while JPEG support is realized as a plugin, and not available when linking statically. This would not change with an update to 4.7.4.

Regards,
Juergen

Locked

Who is online

Users browsing this forum: No registered users and 2 guests