Skip to content

Commit

Permalink
Creating interface for PMain to Neuron Assembler
Browse files Browse the repository at this point in the history
  • Loading branch information
MKRangers committed Jan 6, 2020
1 parent 3ec1dd6 commit 3cc7823
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 10 deletions.
1 change: 1 addition & 0 deletions v3d_main/basic_c_fun/v3d_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ QT_END_NAMESPACE
#include "v3d_global_preference.h"
#include "v3d_message.h"
#include "INeuronAssembler.h"
#include "IPMain4NeuronAssembler.h"
#include <set>

struct V3DPluginArgItem
Expand Down
29 changes: 23 additions & 6 deletions v3d_main/terafly/src/control/CViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,8 @@ CViewer::CViewer(V3DPluginCallback2 *_V3D_env, int _resIndex, tf::uint8 *_imgDat
toRetrieveData = false;
volumeCutSbAdjusted = false;
xMinAdjusted = false, xMaxAdjusted = false, yMinAdjusted = false, yMaxAdjusted = false, zMinAdjusted = false, zMaxAdjusted = false;

if (PMain::getInstance()->NeuronAssemblerPortal != nullptr) PMain::getInstance()->NeuronAssemblerPortal->getNAVersionNum();

try
{
Expand Down Expand Up @@ -730,6 +732,10 @@ bool CViewer::eventFilter(QObject *object, QEvent *event)
if (object == view3DWidget && event->type() == QEvent::MouseButtonDblClick)
{

#ifdef _NEURON_ASSEMBLER_
if (PMain::getInstance()->NeuronAssemblerPortal != nullptr) PMain::getInstance()->NeuronAssemblerPortal->switchMarkerMonitor_fromPMain(false);
#endif

// if(current == this)
// qDebug()<<"current == this!";
// else if(current == prev)
Expand Down Expand Up @@ -839,6 +845,9 @@ bool CViewer::eventFilter(QObject *object, QEvent *event)
}
// --------- END of [If there is an SWC presenting, search the nearest node to zoom in when double clicking] ---------

#ifdef _NEURON_ASSEMBLER_
if (PMain::getInstance()->NeuronAssemblerPortal != nullptr) PMain::getInstance()->NeuronAssemblerPortal->switchMarkerMonitor_fromPMain(true);
#endif

return true;
}
Expand Down Expand Up @@ -2103,6 +2112,10 @@ void CViewer::restoreViewerFrom(CViewer* source) throw (RuntimeException)
//
PMain* pMain = PMain::getInstance();

#ifdef _NEURON_ASSEMBLER_
if (pMain->NeuronAssemblerPortal != nullptr) pMain->NeuronAssemblerPortal->switchMarkerMonitor_fromPMain(false);
#endif

insituZoomOut_dx = round(pMain->Hdim_sbox->value()/2.0f);
insituZoomOut_dy = round(pMain->Vdim_sbox->value()/2.0f);
insituZoomOut_dz = round(pMain->Ddim_sbox->value()/2.0f);
Expand Down Expand Up @@ -2376,6 +2389,10 @@ void CViewer::restoreViewerFrom(CViewer* source) throw (RuntimeException)
//qDebug()<<"done translate ... start accepting new event ...";
isTranslate = false;
}

#ifdef _NEURON_ASSEMBLER_
if (pMain->NeuronAssemblerPortal != nullptr) pMain->NeuronAssemblerPortal->switchMarkerMonitor_fromPMain(true);
#endif
}
PLog::instance()->appendOperation(new RestoreViewerOperation(strprintf("Restored viewer %d from viewer %d", ID, source->ID), tf::ALL_COMPS, timer.elapsed()));
}
Expand Down Expand Up @@ -3233,6 +3250,12 @@ bool CViewer::teraflyImgInstance()
else return false;
}

void CViewer::sendCastNAUI2PMain(IPMain4NeuronAssembler* NAportal)
{
PMain& pMain = *(PMain::getInstance());
pMain.NeuronAssemblerPortal = NAportal;
}

bool CViewer::checkFragTraceStatus()
{
Renderer_gl1* thisRenderer = static_cast<Renderer_gl1*>(CViewer::getCurrent()->getGLWidget()->getRenderer());
Expand All @@ -3245,12 +3268,6 @@ void CViewer::changeFragTraceStatus(bool newStatus)
pMain.fragTracePluginInstance = newStatus;
}

int CViewer::getTeraflyResLevel()
{
CViewer* currViewer = CViewer::getCurrent();
return currViewer->getResIndex();
}

bool CViewer::getXlockStatus()
{
PMain& pMain = *(PMain::getInstance());
Expand Down
6 changes: 4 additions & 2 deletions v3d_main/terafly/src/control/CViewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,13 @@ class terafly::CViewer : public QWidget
* ==================================================================================================== */
virtual bool teraflyImgInstance();

virtual void sendCastNAUI2PMain(IPMain4NeuronAssembler* NAportal);
virtual bool checkFragTraceStatus();
virtual void changeFragTraceStatus(bool newStatus);

virtual string getCviewerWinTitle() { return this->title; }
virtual int getTeraflyResLevel();
virtual string getCviewerWinTitle() { return CViewer::getCurrent()->title; }
virtual int getTeraflyTotalResLevel() { return CImport::instance()->getResolutions(); }
virtual int getTeraflyResLevel() { return CViewer::getCurrent()->getResIndex(); }
virtual bool getXlockStatus();
virtual bool getYlockStatus();
virtual bool getZlockStatus();
Expand Down
59 changes: 59 additions & 0 deletions v3d_main/terafly/src/presentation/PMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ PMain::PMain(V3DPluginCallback2 *callback, QWidget *parent) : QWidget(parent)
parentWidget = parent;
annotationsPathLRU = "";
marginLeft = 65;
NeuronAssemblerPortal = nullptr;

//creating fonts
QFont tinyFont = QApplication::font();
Expand Down Expand Up @@ -2466,10 +2467,16 @@ void PMain::resolutionIndexChanged(int i)
{
/**/tf::debug(tf::LEV1, strprintf("resolution = %d", i).c_str(), __itm__current__function__);

//if (this->NeuronAssemblerPortal != nullptr) this->NeuronAssemblerPortal->switchMarkerMonitor_fromPMain(false);

try
{
if(resolution_cbox->isEnabled() && CViewer::getCurrent() && i > CViewer::getCurrent()->getResIndex())
{

#ifdef _NEURON_ASSEMBLER_
if (this->NeuronAssemblerPortal != nullptr) this->NeuronAssemblerPortal->switchMarkerMonitor_fromPMain(false);
#endif
// int voiV0 = CVolume::scaleVCoord(V0_sbox->value()-1, CImport::instance()->getResolutions()-1, i);
// int voiV1 = CVolume::scaleVCoord(V1_sbox->value()-1, CImport::instance()->getResolutions()-1, i);
// int voiH0 = CVolume::scaleHCoord(H0_sbox->value()-1, CImport::instance()->getResolutions()-1, i);
Expand Down Expand Up @@ -2499,6 +2506,10 @@ void PMain::resolutionIndexChanged(int i)
}
// else
// resolution_cbox->setCurrentIndex(CViewer::getCurrent()->getResIndex());

#ifdef _NEURON_ASSEMBLER_
if (this->NeuronAssemblerPortal != nullptr) this->NeuronAssemblerPortal->switchMarkerMonitor_fromPMain(true);
#endif
}
}
catch(RuntimeException &ex)
Expand Down Expand Up @@ -2532,73 +2543,121 @@ void PMain::traslXposClicked()
{
/**/tf::debug(tf::LEV2, 0, __itm__current__function__);

#ifdef _NEURON_ASSEMBLER_
if (this->NeuronAssemblerPortal != nullptr) this->NeuronAssemblerPortal->switchMarkerMonitor_fromPMain(false);
#endif

CViewer* expl = CViewer::getCurrent();
if(expl && expl->_isActive && !expl->toBeClosed)
{
expl->newViewer((expl->volH1-expl->volH0)/2 + (expl->volH1-expl->volH0)*(100-CSettings::instance()->getTraslX())/100.0f,
(expl->volV1-expl->volV0)/2,
(expl->volD1-expl->volD0)/2, expl->volResIndex, expl->volT0, expl->volT1);
}

#ifdef _NEURON_ASSEMBLER_
if (this->NeuronAssemblerPortal != nullptr) this->NeuronAssemblerPortal->switchMarkerMonitor_fromPMain(true);
#endif
}
void PMain::traslXnegClicked()
{
/**/tf::debug(tf::LEV2, 0, __itm__current__function__);

#ifdef _NEURON_ASSEMBLER_
if (this->NeuronAssemblerPortal != nullptr) this->NeuronAssemblerPortal->switchMarkerMonitor_fromPMain(false);
#endif

CViewer* expl = CViewer::getCurrent();
if(expl && expl->_isActive && !expl->toBeClosed)
{
expl->newViewer((expl->volH1-expl->volH0)/2 - (expl->volH1-expl->volH0)*(100-CSettings::instance()->getTraslX())/100.0f,
(expl->volV1-expl->volV0)/2,
(expl->volD1-expl->volD0)/2, expl->volResIndex, expl->volT0, expl->volT1);
}

#ifdef _NEURON_ASSEMBLER_
if (this->NeuronAssemblerPortal != nullptr) this->NeuronAssemblerPortal->switchMarkerMonitor_fromPMain(true);
#endif
}
void PMain::traslYposClicked()
{
/**/tf::debug(tf::LEV2, 0, __itm__current__function__);

#ifdef _NEURON_ASSEMBLER_
if (this->NeuronAssemblerPortal != nullptr) this->NeuronAssemblerPortal->switchMarkerMonitor_fromPMain(false);
#endif

CViewer* expl = CViewer::getCurrent();
if(expl && expl->_isActive && !expl->toBeClosed)
{
expl->newViewer((expl->volH1-expl->volH0)/2,
(expl->volV1-expl->volV0)/2 + (expl->volV1-expl->volV0)*(100-CSettings::instance()->getTraslY())/100.0f,
(expl->volD1-expl->volD0)/2, expl->volResIndex, expl->volT0, expl->volT1);
}

#ifdef _NEURON_ASSEMBLER_
if (this->NeuronAssemblerPortal != nullptr) this->NeuronAssemblerPortal->switchMarkerMonitor_fromPMain(true);
#endif
}
void PMain::traslYnegClicked()
{
/**/tf::debug(tf::LEV2, 0, __itm__current__function__);

#ifdef _NEURON_ASSEMBLER_
if (this->NeuronAssemblerPortal != nullptr) this->NeuronAssemblerPortal->switchMarkerMonitor_fromPMain(false);
#endif

CViewer* expl = CViewer::getCurrent();
if(expl && expl->_isActive && !expl->toBeClosed)
{
expl->newViewer((expl->volH1-expl->volH0)/2,
(expl->volV1-expl->volV0)/2 - (expl->volV1-expl->volV0)*(100-CSettings::instance()->getTraslY())/100.0f,
(expl->volD1-expl->volD0)/2, expl->volResIndex, expl->volT0, expl->volT1);
}

#ifdef _NEURON_ASSEMBLER_
if (this->NeuronAssemblerPortal != nullptr) this->NeuronAssemblerPortal->switchMarkerMonitor_fromPMain(true);
#endif
}
void PMain::traslZposClicked()
{
/**/tf::debug(tf::LEV2, 0, __itm__current__function__);

#ifdef _NEURON_ASSEMBLER_
if (this->NeuronAssemblerPortal != nullptr) this->NeuronAssemblerPortal->switchMarkerMonitor_fromPMain(false);
#endif

CViewer* expl = CViewer::getCurrent();
if(expl && expl->_isActive && !expl->toBeClosed)
{
expl->newViewer((expl->volH1-expl->volH0)/2,
(expl->volV1-expl->volV0)/2,
(expl->volD1-expl->volD0)/2 + (expl->volD1-expl->volD0)*(100-CSettings::instance()->getTraslZ())/100.0f, expl->volResIndex, expl->volT0, expl->volT1);
}

#ifdef _NEURON_ASSEMBLER_
if (this->NeuronAssemblerPortal != nullptr) this->NeuronAssemblerPortal->switchMarkerMonitor_fromPMain(true);
#endif
}
void PMain::traslZnegClicked()
{
/**/tf::debug(tf::LEV2, 0, __itm__current__function__);

#ifdef _NEURON_ASSEMBLER_
if (this->NeuronAssemblerPortal != nullptr) this->NeuronAssemblerPortal->switchMarkerMonitor_fromPMain(false);
#endif

CViewer* expl = CViewer::getCurrent();
if(expl && expl->_isActive && !expl->toBeClosed)
{
expl->newViewer((expl->volH1-expl->volH0)/2,
(expl->volV1-expl->volV0)/2,
(expl->volD1-expl->volD0)/2 - (expl->volD1-expl->volD0)*(100-CSettings::instance()->getTraslZ())/100.0f, expl->volResIndex, expl->volT0, expl->volT1);
}

#ifdef _NEURON_ASSEMBLER_
if (this->NeuronAssemblerPortal != nullptr) this->NeuronAssemblerPortal->switchMarkerMonitor_fromPMain(true);
#endif
}
void PMain::traslTposClicked()
{
Expand Down
1 change: 1 addition & 0 deletions v3d_main/terafly/src/presentation/PMain.h
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ class terafly::PMain : public QWidget
bool fragTracePluginInstance;
QPluginLoader* FragTracerQPluginPtr;
V3d_PluginLoader* FragTracerPluginLoaderPtr;
IPMain4NeuronAssembler* NeuronAssemblerPortal;
bool xLockStatus, yLockStatus, zLockStatus;
/*************************************************************/

Expand Down
8 changes: 6 additions & 2 deletions v3d_main/v3d/INeuronAssembler.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,21 @@

#include <QtCore>

#include "IPMain4NeuronAssembler.h"

class INeuronAssembler
{
public:
virtual ~INeuronAssembler() {}

virtual bool teraflyImgInstance() = 0;

virtual void sendCastNAUI2PMain(IPMain4NeuronAssembler* NAportal) = 0;
virtual bool checkFragTraceStatus() = 0;
virtual void changeFragTraceStatus(bool newStatus) = 0;

virtual string getCviewerWinTitle() = 0;
virtual int getTeraflyTotalResLevel() = 0;
virtual int getTeraflyResLevel() = 0;
virtual bool getXlockStatus() = 0;
virtual bool getYlockStatus() = 0;
Expand All @@ -28,7 +32,7 @@ class INeuronAssembler
virtual void getParamsFromFragTraceUI(const string& keyName, const float& value) = 0;
};

Q_DECLARE_INTERFACE(INeuronAssembler, "MK.teraflyInterfaceTest1/1.0");
Q_DECLARE_INTERFACE(INeuronAssembler, "MK.NeuronAssemblerInterface_for_CViewerClass/1.0");


#endif
17 changes: 17 additions & 0 deletions v3d_main/v3d/IPMain4NeuronAssembler.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#ifndef IPMAIN4NEURONASSEMBLER_H
#define IPMAIN4NEURONASSEMBLER_H

#include <QtCore>

class IPMain4NeuronAssembler
{
public:
virtual void getNAVersionNum() = 0;

virtual void switchMarkerMonitor_fromPMain(bool on_off) = 0;

};

Q_DECLARE_INTERFACE(IPMain4NeuronAssembler, "MK.PMainInterface_for_NeuronAssemblerUI/1.0");

#endif
1 change: 1 addition & 0 deletions v3d_main/v3d/v3d_essential.pro
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ HEADERS += ../basic_c_fun/mg_utilities.h \
../io/v3d_nrrd.h \
../terafly/src/presentation/theader.h \
INeuronAssembler.h \
IPMain4NeuronAssembler.h \
# ./painting/shared/arthurstyle.h \
# ./painting/shared/arthurwidgets.h

Expand Down

0 comments on commit 3cc7823

Please sign in to comment.