* Author: sbh
*/
-#ifndef Config_ValidatorMessage_H_
-#define Config_ValidatorMessage_H_
+#ifndef CONFIG_VALIDATORMESSAGE_H_
+#define CONFIG_VALIDATORMESSAGE_H_
#include <Events_Message.h>
#include <Config_def.h>
std::list<std::string> myVaidatorParameters;
public:
- CONFIG_EXPORT Config_ValidatorMessage(const Events_ID theId, const void* theParent = 0);CONFIG_EXPORT virtual ~Config_ValidatorMessage();
+ CONFIG_EXPORT Config_ValidatorMessage(const Events_ID theId, const void* theParent = 0);
+ CONFIG_EXPORT virtual ~Config_ValidatorMessage();
//CONFIG_EXPORT static const char* UID() const;
- CONFIG_EXPORT const std::string& validatorId() const;CONFIG_EXPORT const std::string& featureId() const;CONFIG_EXPORT const std::string& attributeId() const;CONFIG_EXPORT const std::list<
- std::string>& parameters() const;CONFIG_EXPORT bool isValid() const;
+ CONFIG_EXPORT const std::string& validatorId() const;
+ CONFIG_EXPORT const std::string& featureId() const;
+ CONFIG_EXPORT const std::string& attributeId() const;
+ CONFIG_EXPORT const std::list<std::string>& parameters() const;
+ CONFIG_EXPORT bool isValid() const;
- CONFIG_EXPORT void setValidatorId(const std::string& theId);CONFIG_EXPORT void setFeatureId(
- const std::string& theId);CONFIG_EXPORT void setAttributeId(const std::string& theId);CONFIG_EXPORT void setValidatorParameters(
- const std::list<std::string>& parameters);
+ CONFIG_EXPORT void setValidatorId(const std::string& theId);
+ CONFIG_EXPORT void setFeatureId(const std::string& theId);
+ CONFIG_EXPORT void setAttributeId(const std::string& theId);
+ CONFIG_EXPORT void setValidatorParameters(const std::list<std::string>& parameters);
};
#endif /* Config_ValidatorMessage_H_ */
XGUI_Selection.h
XGUI_Preferences.h
XGUI_IPrefMgr.h
+ XGUI_QtEvents.h
)
SET(PROJECT_AUTOMOC
XGUI_ModuleConnector.cpp
XGUI_Selection.cpp
XGUI_Preferences.cpp
+ XGUI_QtEvents.cpp
)
SET(PROJECT_RESOURCES
--- /dev/null
+/*
+ * XGUI_QEvents.cpp
+ *
+ * Created on: Sep 12, 2014
+ * Author: sbh
+ */
+
+#include "XGUI_QtEvents.h"
+
+QEvent::Type PostponeMessageQtEvent::PostponeMessageQtEventType = QEvent::Type(QEvent::registerEventType());
+
+
+//TODO(mpv): #4
+//boost::shared_ptr<Events_Message> PostponeMessageQtEvent::postponedMessage()
+boost::shared_ptr<ModelAPI_Document> PostponeMessageQtEvent::resultDoc()
+{
+ return myTestDoc;
+}
+
--- /dev/null
+/*
+ * XGUI_QEvents.h
+ *
+ * Created on: Sep 12, 2014
+ * Author: sbh
+ */
+
+#ifndef XGUI_QTEVENTS_H_
+#define XGUI_QTEVENTS_H_
+
+#include <XGUI.h>
+
+#include <ModelAPI_ResultPart.h>
+#include <Events_Message.h>
+
+#include <QEvent>
+#include <QString>
+
+class XGUI_EXPORT PostponeMessageQtEvent : public QEvent
+{
+ public:
+ static QEvent::Type PostponeMessageQtEventType;
+
+ //TODO(mpv): ModelAPI_Document is taken here for example
+ //the commented code should be ok when you implement boost::shared_ptr on Events_Message
+ //the same for #1-4
+ PostponeMessageQtEvent(boost::shared_ptr<ModelAPI_Document> theDoc)
+ //PostponeMessageQtEvent(boost::shared_ptr<Events_Message> theMessage)
+ : QEvent(PostponeMessageQtEventType),
+ //TODO(mpv): #1
+ //myMessage(theMessage)
+ myTestDoc(theDoc)
+ {
+ }
+ static QEvent::Type type()
+ {
+ return PostponeMessageQtEventType;
+ }
+
+ //TODO(mpv): #2
+ //boost::shared_ptr<Events_Message> postponedMessage();
+ boost::shared_ptr<ModelAPI_Document> resultDoc();
+
+ private:
+ //TODO(mpv): #3
+ //boost::shared_ptr<Events_Message> myMessage;
+ boost::shared_ptr<ModelAPI_Document> myTestDoc;
+};
+
+#endif /* XGUI_QEVENTS_H_ */
#include "XGUI_ContextMenuMgr.h"
#include "XGUI_ModuleConnector.h"
#include "XGUI_Preferences.h"
+#include <XGUI_QtEvents.h>
#include <ModelAPI_Events.h>
#include <ModelAPI_Session.h>
#include <QPushButton>
#include <QDockWidget>
#include <QLayout>
-#include <QTimer>
+#include <QThread>
+#include <QObject>
#ifdef _DEBUG
#include <QDebug>
+#include <iostream>
#endif
#ifdef WIN32
//******************************************************
void XGUI_Workshop::processEvent(const Events_Message* theMessage)
{
+ if (QApplication::instance()->thread() != QThread::currentThread()) {
+ #ifdef _DEBUG
+ std::cout << "XGUI_Workshop::processEvent: " << "Working in another thread." << std::endl;
+ #endif
+ SessionPtr aMgr = ModelAPI_Session::get();
+ PostponeMessageQtEvent* aPostponeEvent = new PostponeMessageQtEvent(aMgr->activeDocument());
+ QApplication::postEvent(this, aPostponeEvent);
+ return;
+ }
+
//A message to start feature creation received.
if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_LOADED)) {
const Config_FeatureMessage* aFeatureMsg =
else if (theMessage->eventID() == Events_LongOp::eventID()) {
if (Events_LongOp::isPerformed())
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
- //QTimer::singleShot(10, this, SLOT(onStartWaiting()));
else
QApplication::restoreOverrideCursor();
}
myPropertyPanel->cleanContent();
}
+bool XGUI_Workshop::event(QEvent * theEvent)
+{
+ PostponeMessageQtEvent* aPostponedEv = dynamic_cast<PostponeMessageQtEvent*>(theEvent);
+ if (aPostponedEv) {
+#ifdef _DEBUG
+ std::cout << "XGUI_Workshop::event " << "Got PostponeMessageQtEvent" << std::endl;
+ bool isMyThread = (QApplication::instance()->thread() == QThread::currentThread());
+ std::cout << "XGUI_Workshop::event " << "I am in the Qt's thread: "
+ << isMyThread << std::endl;
+#endif
+ boost::shared_ptr<ModelAPI_Document> aDoc = aPostponedEv->resultDoc();
+ if (aDoc) {
+#ifdef _DEBUG
+ std::cout << "XGUI_Workshop::event " << "Passed boost ptr is ok, doc id: " << aDoc->id()
+ << std::endl;
+#endif
+ }
+ //TODO(mpv): After modifications in the XGUI_QtEvents.* this code should be like...
+ //boost::shared_ptr<Events_Message> aEventPtr = aPostponedEv->postponedMessage();
+ //processEvent(aEventPtr);
+ return true;
+ }
+ return false;
+}
+
/*
*
*/
void activateLastPart();
protected:
+ bool event(QEvent * theEvent);
//Event-loop processing methods:
void addFeature(const Config_FeatureMessage*);
void connectWithOperation(ModuleBase_Operation* theOperation);