#include "Plot2d_SetupPlot2dDlg.h"
#include "Plot2d_ViewFrame.h"
#include "VTKViewer_ViewFrame.h"
+#include "VTKViewer_InteractorStyleSALOME.h"
#include "VisuGUI_FileDlg.h"
// QT Includes
QFont font;
};
-static VisuGUI MYVISUGUI;
+static VisuGUI MYVISUGUI("");
VisuGUI *visuGUI = &MYVISUGUI;
VISU::VISU_Gen_i* VisuGUI::GetVisuGen(){
return dynamic_cast<VTKViewer_ViewFrame*>(aViewFrame);
}
+static void UpdateViewFrame() {
+ QList<QAD_StudyFrame> aFrameList = VisuGUI::GetActiveStudy()->getStudyFrames();
+
+ for (QAD_StudyFrame* aStudyFrame = aFrameList.first(); aStudyFrame; aStudyFrame = aFrameList.next()) {
+ if (aStudyFrame->getTypeView() == VIEW_VTK) {
+ QAD_ViewFrame* aViewFrame = aStudyFrame->getRightFrame()->getViewFrame();
+ VTKViewer_ViewFrame* aVtkViewFrame = dynamic_cast<VTKViewer_ViewFrame*>(aViewFrame);
+ if (!aVtkViewFrame) continue;
+ VTKViewer_RenderWindowInteractor* anInteractor = aVtkViewFrame->getRWInteractor();
+ if (anInteractor) {
+ anInteractor->SetSelectionProp();
+ anInteractor->SetSelectionTolerance();
+ VTKViewer_InteractorStyleSALOME* aStyle = anInteractor->GetInteractorStyleSALOME();
+ if (aStyle) {
+ aStyle->setPreselectionProp();
+ }
+ }
+ }
+ }
+}
+
SALOMEDS::Study_var VisuGUI::GetStudyDocument(){
return GetActiveStudy()->getStudyDocument();
}
}
-VisuGUI::VisuGUI(){
+VisuGUI::VisuGUI( const QString& theName, QObject* theParent ):
+ SALOMEGUI( theName, theParent )
+{
mySelectionDlg = 0;
}
/* ======================================================================================== */
/* Import Table from file */
/* ======================================================================================== */
-
case 199:
{
if(checkLock(aStudy)) break;
visuGUI->SelectionInfo();
break;
- /* ========================================================================================================================= */
- /* Selection - Shape */
- /* ========================================================================================================================= */
-
- //case 413 :
-
/* ========================================================================================================================= */
/* Visualization - Wireframe */
/* ========================================================================================================================= */
tr ("VISU_BUT_OK") );
break;
}
+ } catch (const std::bad_alloc& e ) {
+ INFOS("bad_alloc exception is caught "<<e.what());
+ QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
+ tr("ERR_NO_MEMORY") + " " + tr(e.what()),
+ tr("VISU_BUT_OK") );
+ return false;
+ }
+ catch (std::exception& e){
+ INFOS(e.what());
+ QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
+ tr(e.what()),
+ tr("VISU_BUT_OK") );
}catch (const SALOME::SALOME_Exception& S_ex) {
+ INFOS("const SALOME::SALOME_Exception& S_ex");
QtCatchCorbaException(S_ex);
return false;
}
catch(...) {
+ INFOS(tr("ERR_UNKNOWN_EXCEPTION").latin1());
QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
tr("ERR_UNKNOWN_EXCEPTION"),
tr("VISU_BUT_OK") );
return true;
}
-
void VisuGUI::SelectionInfo() {
- if (mySelectionDlg) {
- mySelectionDlg->close(true);
- mySelectionDlg = 0;
- }
mySelectionDlg = new VisuGUI_SelectionDlg();
mySelectionDlg->show();
}
// Slot-functions for presentations creation
//=====================================================================================
-
#define CREATEPRESENTATION(FunctionName) \
void FunctionName() { \
if (checkLock(GetStudyDocument())) return; \
-
//=====================================================================================
-// function : setSettings()
+// function : SetSettings()
// purpose :
//=====================================================================================
-bool VisuGUI::setSettings(QAD_Desktop* parent)
+bool VisuGUI::SetSettings(QAD_Desktop* parent)
{
int anId = 53;
QMenuData* pp;
if(aValue.isEmpty()? 0 : aValue.toInt())
pp->setItemChecked(anId, true);
+ anId = 50;
+ parent->menuBar()->changeItem(anId,parent->getComponentUserName("VISU"));
+
+ ::UpdateViewFrame();
+
return true;
}
thePrs->UpdateActor(anActor);
}
}catch(std::runtime_error& ex){
- QApplication::restoreOverrideCursor();
INFOS(ex.what());
+ QApplication::restoreOverrideCursor();
QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
- tr ("ERR_CANT_BUILD_PRESENTATION"),
+ tr ("ERR_CANT_BUILD_PRESENTATION") + " " + tr(ex.what()),
tr ("VISU_BUT_OK") );
for(int i = 0, nbFrames = GetActiveStudy()->getStudyFramesCount(); i < nbFrames; i++)
if(QAD_StudyFrame* aFrame = GetActiveStudy()->getStudyFrame(i)){
{
VISU::CutPlanes_i* aPrsObject = dynamic_cast<VISU::CutPlanes_i*>(aPrs3d);
if (aPrsObject) {
- VisuGUI_CutPlanesDlg* aDlg = new VisuGUI_CutPlanesDlg(false, false);
+ VisuGUI_CutPlanesDlg* aDlg = new VisuGUI_CutPlanesDlg(false, false);
aDlg->initFromPrsObject(aPrsObject);
aDlg->show();
myActiveDialogBox = aDlg;
}catch(std::runtime_error& exc){
INFOS(exc.what());
QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
- tr ("ERR_CANT_CREATE_ACTOR"),
+ tr ("ERR_CANT_CREATE_ACTOR") + " " + tr(exc.what()),
tr ("VISU_BUT_OK") );
}
}
void VisuGUI::SaveViewParams()
{
if (checkLock(GetStudyDocument())) return;
- SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
- if ( Sel->IObjectCount() > 1 || GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK )
+ SALOME_Selection* aSel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
+ QAD_StudyFrame* aStudyFrame = GetActiveStudy()->getActiveStudyFrame();
+ if ( aSel->IObjectCount() > 1 || aStudyFrame->getTypeView() != VIEW_VTK )
return;
- VISU::ViewManager_var aVM = GetVisuGen()->GetViewManager();
- if(!CORBA::is_nil(aVM.in())){
- VISU::View_var aView = aVM->GetCurrentView();
- if(!CORBA::is_nil(aView.in())){
- VISU::View3D_var aView3D = VISU::View3D::_narrow(aView);
- if(CORBA::is_nil(aView3D.in())) return;
- if ( Sel->IObjectCount() == 0 ) {
- // Save view parameters by new name
- aView3D->SaveViewParams( 0 );
- GetActiveStudy()->updateObjBrowser( true );
- }else{
- bool isExist;
- VISU::Storable::TRestoringMap aMap;
- Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = GetSelectedObj(&anIO,GetActiveStudy(),&aMap);
- VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
- if(isExist && aType == VISU::TVIEW3D){
- aView3D->SaveViewParams( anIO->getName() );
- GetActiveStudy()->updateObjBrowser( true );
- }
- }
- }
+ if ( aSel->IObjectCount() == 0 ) {
+ VISU::View3D_i::SaveViewParams(aStudyFrame,VISU::View3D_i::GenerateViewParamsName().latin1());
+ }else{
+ const Handle(SALOME_InteractiveObject)& anIO = aSel->firstIObject();
+ VISU::View3D_i::SaveViewParams(aStudyFrame,anIO->getName());
}
+ GetActiveStudy()->updateObjBrowser( true );
}
void VisuGUI::RestoreViewParams()
{
- SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
- if ( Sel->IObjectCount() > 1 || GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK )
+ SALOME_Selection* aSel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
+ QAD_StudyFrame* aStudyFrame = GetActiveStudy()->getActiveStudyFrame();
+ if ( aSel->IObjectCount() > 1 || aStudyFrame->getTypeView() != VIEW_VTK )
return;
- VISU::ViewManager_var aVM = GetVisuGen()->GetViewManager();
- if(!CORBA::is_nil(aVM.in())){
- VISU::View_var aView = aVM->GetCurrentView();
- if(!CORBA::is_nil(aView.in())){
- VISU::View3D_var aView3D = VISU::View3D::_narrow(aView);
- if(CORBA::is_nil(aView3D.in())) return;
- bool isExist;
- VISU::Storable::TRestoringMap aMap;
- Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = GetSelectedObj(&anIO,GetActiveStudy(),&aMap);
- VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
- if(isExist && aType == VISU::TVIEW3D)
- aView3D->RestoreViewParams( anIO->getName() );
- }
- }
+ const Handle(SALOME_InteractiveObject)& anIO = aSel->firstIObject();
+ VISU::View3D_i::RestoreViewParams(aStudyFrame,anIO->getName());
}
+
//=====================================================================================
// function : DeleteViewParams()
// purpose :
}
QApplication::setOverrideCursor( Qt::waitCursor );
- for (int j=0 ; j<aCycles; j++) {
- for (int i=0 ; i<=aSteps; i++) {
- float aPercents = float(i)/aSteps;
- aPrsObject->SetMapScale(aPercents);
- aPrsObject->UpdateActor(aActor);
- vf->getRW()->getRenderWindow()->Render();
- usleep(aTemp);
+ try{
+ for (int j=0 ; j<aCycles; j++) {
+ for (int i=0 ; i<=aSteps; i++) {
+ float aPercents = float(i)/aSteps;
+ aPrsObject->SetMapScale(aPercents);
+ aPrsObject->UpdateActor(aActor);
+ vf->getRW()->getRenderWindow()->Render();
+ usleep(aTemp);
+ }
}
+ }catch(std::exception& exc){
+ INFOS("Follow exception was accured :\n"<<exc.what());
+ }catch(...){
+ INFOS("Unknown exception was accured!");
}
QApplication::restoreOverrideCursor();
}
thePopup->clear();
SALOME_Selection* aSelection = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
if ( aSelection->IObjectCount() == 0 ) {
- if ( theParent == "Viewer" && isVTKViewer)
- // Available only for VTK viewer
+ if ( theParent == "Viewer" && isVTKViewer && !aIsLocked)
thePopup->insertItem( "Save view parameters", visuGUI, SLOT( SaveViewParams() ) );
return false;
}
if ( !aIsLocked )thePopup->insertItem("Create Presentation", visuGUI, SLOT(CreateMesh()));
break;
case VISU::TVIEW3D:
+ if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK )
+ thePopup->insertItem( "Restore view parameters", visuGUI, SLOT( RestoreViewParams() ) );
if ( !aIsLocked ) {
if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
// Available only for VTK viewer
thePopup->insertItem( "Save view parameters", visuGUI, SLOT( SaveViewParams() ) );
- thePopup->insertItem( "Restore view parameters", visuGUI, SLOT( RestoreViewParams() ) );
}
thePopup->insertItem( "Rename...", visuGUI, SLOT( Rename() ) );
thePopup->insertItem("Delete", visuGUI, SLOT(DeleteViewParams()));
vf->AddActor(SelectedActor);
}catch(std::runtime_error& exc){
INFOS(exc.what());
+ throw exc;
}
}else
if(MYDEBUG) MESSAGE("CORBA::is_nil(anObject) = true");
END_OF("VisuGUI::BuildPresentation");
}
-extern "C"
-{
-
- bool OnGUIEvent(int theCommandID, QAD_Desktop* parent)
- {
- //if(MYDEBUG) MESSAGE("VisuGUI::OnGUIEvent "<< theCommandID);
- return VisuGUI::OnGUIEvent(theCommandID, parent);
- }
-
- bool OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
- {
- if(MYDEBUG) MESSAGE("VisuGUI::OnKeyPress ");
- return VisuGUI::OnKeyPress (pe, parent, studyFrame);
- }
-
- bool OnMousePress (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
- {
- //if(MYDEBUG) MESSAGE("VisuGUI::OnMousePress ");
- return VisuGUI::OnMousePress (pe, parent, studyFrame);
- }
- bool OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
- {
- //if(MYDEBUG) MESSAGE("VisuGUI::OnMouseMove ");
- return VisuGUI::OnMouseMove (pe, parent, studyFrame);
- }
-
- bool SetSettings ( QAD_Desktop* parent )
- {
- return VisuGUI::setSettings( parent );
- }
-
- bool customPopup ( QAD_Desktop* parent, QPopupMenu* popup, const QString & theContext,
- const QString & theParent, const QString & theObject )
- {
- return VisuGUI::CustomPopup( parent, popup, theContext, theParent, theObject );
- }
-
- void definePopup ( QString & theContext, QString & theParent, QString & theObject )
- {
- VisuGUI::DefinePopup( theContext, theParent, theObject );
- }
+//===========================================================================
+// SupportedViewType
+//===========================================================================
+void VisuGUI::SupportedViewType(int* buffer, int bufferSize)
+{
+ if (!buffer || !bufferSize) return;
+ buffer[0] = (int)VIEW_VTK;
+ if (--bufferSize) buffer[1] = (int)VIEW_PLOT2D;
+}
- bool activeStudyChanged ( QAD_Desktop* parent )
- {
- //VisuGUI::activeStudyChanged( parent );
- }
- void buildPresentation ( const Handle(SALOME_InteractiveObject)& theIO )
- {
- VisuGUI::BuildPresentation(theIO);
+extern "C"
+{
+ Standard_EXPORT SALOMEGUI* GetComponentGUI() {
+ if ( !visuGUI )
+ visuGUI = new VisuGUI( "" );
+ return visuGUI;
}
-
- void supportedViewType(int* buffer, int bufferSize)
- {
- if (!buffer || !bufferSize) return;
- buffer[0] = (int)VIEW_VTK;
- if (--bufferSize) buffer[1] = (int)VIEW_PLOT2D;
- }
-
}
+
//////////////////////////////////////////////////////////////////////////////////
//////////////// CHANGE ACTOR COLOR ////////////////////////
//////////////////////////////////////////////////////////////////////////////////
int intopac;
CursorDlg->Comment1->setText( tr( "Set value between") );
CursorDlg->Comment2->setText( tr( "0 (transparent) and 100 (opaque)" ) );
- oldopac=Actor->GetProperty()->GetOpacity();
- intopac=int(oldopac*100.);
+ oldopac=Actor->GetOpacity();
+ intopac=int(oldopac*100.+0.5);
CursorDlg->SpinBox1->setMinValue(0);
CursorDlg->SpinBox1->setMaxValue(100);
CursorDlg->SpinBox1->setValue(intopac);
{
intopac = CursorDlg->SpinBox1->value() ;
newopac = intopac/100.;
- Actor->GetProperty()->SetOpacity(newopac);
+ Actor->SetOpacity(newopac);
}
delete CursorDlg;
}
return false; \
} \
} \
- CreateActor(pPresent); \
+ try { \
+ CreateActor(pPresent); \
+ }catch (...) {\
+ return false;} \
return true; \
} \
return false; \
bool VisuGUI::CreateCutPlanes(SALOMEDS::SObject_var theField) {
+ try {
VISU::Storable::TRestoringMap aMap = getMapOfValue(theField);
bool isExist;
QString aType = VISU::Storable::FindValue(aMap,"myType",&isExist);
return true;
}
}
+}catch (...){return false;}
return false;
}
bool VisuGUI::CreateCutLines(SALOMEDS::SObject_var theField) {
+try {
VISU::Storable::TRestoringMap aMap = getMapOfValue(theField);
bool isExist;
QString aType = VISU::Storable::FindValue(aMap,"myType",&isExist);
// return true;
}
}
+}catch (...){return false; }
return false;
}
try {
GetVisuGen() -> ExportTableToFile(aSObj, aFile.latin1());
QAD_Application::getDesktop()->putInfo(aFile+" exported.");
+ } catch(std::exception& ex) {
+ INFOS(ex.what());
+ QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
+ tr ("ERR_ERROR_DURING_EXPORT") + " " + tr(ex.what()),
+ tr ("VISU_BUT_OK") );
} catch(...) {
+ INFOS(tr ("ERR_ERROR_DURING_EXPORT"));
QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
tr ("ERR_ERROR_DURING_EXPORT"),
tr ("VISU_BUT_OK") );
try{
//APO - aResult->GetInput()->ToFile(aFile.latin1());
QAD_Application::getDesktop()->putInfo(aFile+" exported.");
- }catch(...){
+ }catch(std::exception& ex) {
+ INFOS(ex.what());
+ QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
+ tr ("ERR_ERROR_DURING_EXPORT") + " " +tr(ex.what()),
+ tr ("VISU_BUT_OK") );
+ }
+ catch(...){
+ INFOS(tr ("ERR_ERROR_DURING_EXPORT").latin1());
QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
tr ("ERR_ERROR_DURING_EXPORT"),
tr ("VISU_BUT_OK") );
try{
anVISUActor = thePrs->CreateActor();
vf->AddActor(anVISUActor);
- }catch(std::runtime_error& exc){
+ } catch ( std::runtime_error& exc ){
INFOS(exc.what());
QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
- tr ("ERR_CANT_VISUALIZE_OBJECT"),
- tr ("VISU_BUT_OK") );
+ tr("ERR_CANT_VISUALIZE_OBJECT") + " " + tr(exc.what()),
+ tr ("VISU_BUT_OK") );
anVISUActor = NULL;
}
return anVISUActor;
timer.Start();
#endif
try{
+ MESSAGE("Available memory : "<<VISU_PipeLine::GetAvailableMemory());
VISU_Actor* aActor = thePrs->CreateActor();
vf->AddActor(aActor);
- }catch(std::runtime_error& exc){
- INFOS(exc.what());
+ }catch(std::runtime_error& exc) {
+ INFOS("std::runtime_error "<<exc.what());
+ INFOS("Available memory : "<<VISU_PipeLine::GetAvailableMemory());
QApplication::restoreOverrideCursor();
QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
- tr ("WRN_CANT_VISUALIZE_PRS"),
- tr ("VISU_BUT_OK") );
+ tr ("WRN_CANT_VISUALIZE_PRS") + " " + tr(exc.what()),
+ tr ("VISU_BUT_OK") );
+ throw exc;
+ } catch (...) {
+ cout<<" Unknown exception"<<endl;
+ QApplication::restoreOverrideCursor();
+ INFOS("Unknown exception is caught in VisuGUI::CreateActor");
+ INFOS("Available memory : "<<VISU_PipeLine::GetAvailableMemory());
+ QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
+ tr ("WRN_CANT_VISUALIZE_PRS") + " " + tr("ERR_UNKNOWN_EXCEPTION"),
+ tr ("VISU_BUT_OK") );
+ throw ;
}
#ifdef CHECKTIME
timer.Stop();