bool CUninstallWindow::Start(app_entry_s *pApp)
{
    if (!fl_choice(CreateText(GetTranslation("This will remove %s from your computer\nContinue?"),
         pApp->name.c_str()), GetTranslation("No"), GetTranslation("Yes"), NULL))
        return false;
    
    bool checksums = false;
    if (!m_pOwner->CheckSums(pApp->name.c_str()))
    {
        int ret = fl_choice(GetTranslation("Some files have been modified after installation.\n"
                "This can happen if you installed another package which uses one or\n"
                "more files with the same name or you installed another version."),
                GetTranslation("Cancel"), GetTranslation("Continue anyway"),
                GetTranslation("Only remove unchanged"));
        if (ret == 0)
            return false;
        
        checksums = (ret == 2);
    }
    
    // Clear previous contents
    m_pBuffer->select(0, m_pBuffer->length());
    m_pBuffer->remove_selection();
    
    m_pProgress->value(0);
    
    m_pWindow->show();
    
    m_pOwner->Uninstall(pApp, checksums);
    
    m_pProgress->value(100);
    m_pOKButton->activate();
    return true;
}
Esempio n. 2
0
/*
 * React to user input.
 * This consists of the events:
 * - Rename Slot (right click)
 * - Read From Slot
 * - Write To Slot
 * - Swap Slot First Selection
 * - Swap Slot Second Selction
 *
 *   TODO restore autoclose functionality
 */
void BankView::react(int event, int nslot)
{
    BankSlot &slot = *slots[nslot];
    const bool isempty = slot.empty();
    const int  mode    = bvc->mode();

    //Rename slot
    if (event==2 && !isempty && mode!=4) {
        if(const char *name=fl_input("Slot (instrument) name:", slot.name())) {
            osc->write("/bank-rename", "is", nslot, name);
            osc->write("/refresh_bank", "i", nslot);
        }
    }

    //Reads from slot
    if ((event==1)&&(mode==1)&&(!slot.empty())){
        printf("Loading a part #%d with file '%s'\n", nslot, slot.filename());
        osc->write("/load-part", "is", *npart, slot.filename());
        osc->writeValue("/part"+to_s(*npart)+"/name", slot.name());
        if(cbwig_)
            cbwig_->do_callback();
    }

    //save(write) to slot
    if(event==1 && mode==2){
        if(!isempty && !fl_choice("Overwrite the slot no. %d ?","No","Yes",NULL,nslot+1))
            return;

        osc->write("/save-bank-part", "ii", *npart, nslot);
        osc->write("/refresh_bank", "i", nslot);
        //pthread_mutex_lock(&master->part[*npart]->load_mutex);
        //bank->savetoslot(slot,master->part[*npart]);
        //pthread_mutex_unlock(&master->part[*npart]->load_mutex);

        bvc->mode(1);
    }


    //Clears the slot
    if(event==1 && mode==3 && !isempty) {
        if (fl_choice("Clear the slot no. %d ?","No","Yes",NULL, nslot+1)) {
            osc->write("/clear-bank-slot", "i", nslot);
            osc->write("/refresh_bank", "i", nslot);
        }
    }

    //Swap
    if(mode==4) {
        if(event==1 && nselected>=0){
            osc->write("/swap-bank-slots", "ii", nselected, nslot);
            osc->write("/refresh_bank", "i", nslot);
            osc->write("/refresh_bank", "i", nselected);
            //bank->swapslot(nselected,slot);
            nselected=-1;
        } else if(nselected<0 || event==2) {
            nselected=nslot;
        };
    };
}
// ----------------------------------------------------------------------------
// quitApp() - called when we are exiting the program
// ----------------------------------------------------------------------------
void MainWindow::quitApp()
{
    int ask = fl_choice("Do you really want to quit?", "Yes", "No", "Cancel");
    if (ask == 0) {
       std::exit(0);
    }
}
Esempio n. 4
0
int Msg::GetAnswer(const char *question, int defaultval, const char *zero,
                   const char *one, const char *two)
{
  // if a callback is given let's assume we don't want to be bothered
  // with interactive stuff
  if(CTX::instance()->noPopup || _callback) return defaultval;

#if defined(HAVE_FLTK)
  if(FlGui::available())
    return fl_choice(question, zero, one, two, "");
#endif

  if(two)
    printf("%s\n\n0=[%s] 1=[%s] 2=[%s] (default=%d): ", question,
           zero, one, two, defaultval);
  else
    printf("%s\n\n0=[%s] 1=[%s] (default=%d): ", question,
           zero, one, defaultval);
  char str[256];
  char *ret = fgets(str, sizeof(str), stdin);
  if(!ret || !strlen(str) || !strcmp(str, "\n"))
    return defaultval;
  else
    return atoi(ret);
}
Esempio n. 5
0
void cb_exit(Fl_Widget*, void* pall){
	allspec *all;
	all = (allspec *)pall;
	int ret;

	if(all->not_saved){
		ret = fl_choice("Memorized data are not saved.\nExit really?", "Exit", "Return", NULL);
		if(ret != 0)
			return;
	}
	exit(0);
}
Esempio n. 6
0
void open_callback(Fl_Widget* w)
{
    int allowed = 1;
    if (*CurrentFileSpec_str && Unsaved) {
        allowed = fl_choice("    Opening a new file now will discard unsaved work     ", 
                            "  Cancel open  ", "  Discard and open a new file  ", NULL);
    }
    
    if (allowed) {
        load_content(NULL);
    }
}
Esempio n. 7
0
void quit_callback(Fl_Widget* w)
{
    int allowed = 1;
//    printf("Current filespec is %s, unsaved is %d\n", CurrentFileSpec_str, Unsaved);
    if (*CurrentFileSpec_str && Unsaved) {
        allowed = fl_choice("Quitting now will discard unsaved work", 
                            "  Cancel quit  ", "  Discard and quit  ", NULL);
    }
    
    if (allowed) {
        Running = 0;
    }
}
Esempio n. 8
0
File: Mixer.C Progetto: imv/non
void
Mixer::command_quit ( void )
{
    if ( Loggable::dirty() )
    {
        int i = fl_choice( "There have been changes since the last save. Quitting now will discard them", "Discard", "Cancel", NULL );

        if ( i != 0 )
            return;
    }

    quit();
}
void CInstaller::CancelCB(Fl_Widget *w, void *p)
{
    CInstaller *installer = static_cast<CInstaller *>(p);
    
    const char *msg;
    if (installer->Installing())
        msg = GetTranslation("Install commands are still running\n"
                "If you abort now this may lead to a broken installation\n"
                "Are you sure?");
    else
        msg = GetTranslation("This will abort the installation\nAre you sure?");
    
    if (fl_choice(msg, GetTranslation("No"), GetTranslation("Yes"), NULL))
        throw Exceptions::CExUser();
}
Esempio n. 10
0
void clear_callback(Fl_Widget* w)
{
    int allowed = 1;
    if (Unsaved) {
        allowed = fl_choice("Clearing will discard unsaved work", 
                            "  Cancel clear  ", "  Discard unsaved work  ", NULL);
    }
    
    if (allowed) {
        clear_content();
        Unsaved = 0;
        *CurrentFileSpec_str = '\0';
        SaveBtn_p->deactivate();
        update_results_display();
    } 
}
Esempio n. 11
0
//callback for delete
void OnRemoveCommunity(Fl_Widget* pWidget,void * pParam)
{
    Fl_Tabs* pTab = (Fl_Tabs*)(pParam);
    
    if(pTab->children()>1)
    {       
        if(fl_choice("Really delete Scope of \"%s\" ?", "No", "Yes", NULL, pTab->value()->label()))
        {
            Fl_Group* pG = (Fl_Group*)pTab->value();
            pG->clear();
            pTab->remove(pG);
            pTab->value(pTab->child(0));
            delete pG;
        }
    }
}
Esempio n. 12
0
void
preset_click (Fl_Button * o, void *)
{

  int ok;

  char temp2[128];
  long long kk = (long long) o->user_data ();
  int num = (int) kk;
  int tecla = Fl::event_key ();

  if (Fl::event_button () == 3)
    {

      Fl_Widget *w = gui.ob->child (num);


      if (strlen (Banco[num].Name) > 0)
	{
	  Fl_Widget *m = fl_message_icon ();
	  m->parent ()->copy_label ("goomf");
	  sprintf (temp2, "Overwrite? \"%s\"", w->label ());
	  ok = fl_choice (temp2, "No", "Yes", NULL);
	  if (!ok)
	    return;
	}

      strcpy (Name, gui.Pname->value ());
      preset_to_bank (num);
      w->copy_label (gui.Pname->value ());
      Haz_laristra ();
      Send_laristra ();
    }



  if ((Fl::event_button () == 1) || tecla == 32)
    {
      gui.PresetSelect->value (num);
      Put_Combi (num);
      gui.ready = 2;
    }

}
Esempio n. 13
0
int fn_ask(const char *format, ...)
{
	va_list ap;
	char out[BUFFER_SIZE]; //maximum dans un message...

	//start
	va_start(ap,format);
#ifdef VISUALC
	vsprintf(out,format,ap);
#else
	vsnprintf(out,BUFFER_SIZE,format,ap);
#endif
	va_end(ap);

#ifdef WIN32
	return (MessageBox(GET_HWND,out,"",MB_YESNO|MB_ICONQUESTION)==IDYES)?1:0;
#endif
#ifdef LINUX
        return fl_choice(out,"Oui","Non",0)?0:1;
#endif
}
Esempio n. 14
0
bool CFLTKEditor::CheckSave()
{
	if (!IsFileChanged()) 
		return true;

	string sText;

	sText = "The file '";
	sText += GetName();
	sText += "' has been modified.\n";
	sText += "Would you like to save it now?";

	int iR = fl_choice(sText.c_str(), "Cancel", "Save", "Discard");

	if (iR == 1) 
	{
		Save(); // Save the file...
		return !IsFileChanged();
	}

	return (iR == 2) ? true : false;
}
Esempio n. 15
0
void CFLTKEditor::Quit()
{
	bool bSaveAll = false;
	int i, iCount = m_mEditorData.Count();

	for (i = 0; i < iCount; i++)
	{
		SetCurEditor(i);

		if (!bSaveAll && IsFileChanged()) 
		{
			string sText;

			sText = "The file '";
			sText += GetName();
			sText += "' has been modified.\n";
			sText += "Would you like to save it now?";

			int iR = fl_choice(sText.c_str(), "Discard", "Save", "Save all");

			if (iR == 1) 
			{
				Save(); // Save the file...
			}
			else if (iR == 2)
			{
				Save();
				bSaveAll = true;
			}
		}
		else if (bSaveAll)
		{
			Save();
		}
	}

	exit(0);
}
Esempio n. 16
0
int yyy_choice(const char *msg, const char *b0, const char *b1, const char *b2){
    return fl_choice(msg, b0, b1, b2);
}
Esempio n. 17
0
int ModelViewController::handle(int event)
{
	Vector2f    Clickpoint;												// NEW: Current Mouse Point
	static float Click_y;
	static float old_zoom;

	Clickpoint.x =  (GLfloat)Fl::event_x();;
	Clickpoint.y =  (GLfloat)Fl::event_y();;

	switch(event) {
		case FL_PUSH:	//mouse down event position in Fl::event_x() and Fl::event_y()
			{
				switch(Fl::event_button())	{
				case FL_LEFT_MOUSE:
					MousePt.T[0] = (GLfloat)Clickpoint.x;
					MousePt.T[1] = (GLfloat)Clickpoint.y;
					ArcBall->click(&MousePt);								// Update Start Vector And Prepare For Dragging
					break;
				case FL_MIDDLE_MOUSE:
					downPoint = Clickpoint;
					/*
					Matrix3fSetIdentity(&LastRot);								// Reset Rotation
					Matrix3fSetIdentity(&ThisRot);								// Reset Rotation
					Matrix4fSetRotationFromMatrix3f(&Transform, &ThisRot);		// Reset Rotation
					*/
					break;
				case FL_RIGHT_MOUSE:
					Click_y = Clickpoint.y;
					old_zoom = zoom;
					break;
				}
				LastRot = ThisRot;										// Set Last Static Rotation To Last Dynamic One
				redraw();
				return 1;
			}
		case FL_DRAG:	//mouse moved while down event ...
			switch(Fl::event_button())
				{
				case FL_LEFT_MOUSE:
					Quat4fT     ThisQuat;

					MousePt.T[0] = Clickpoint.x;
					MousePt.T[1] = Clickpoint.y;

					ArcBall->drag(&MousePt, &ThisQuat);						// Update End Vector And Get Rotation As Quaternion
					Matrix3fSetRotationFromQuat4f(&ThisRot, &ThisQuat);		// Convert Quaternion Into Matrix3fT
					Matrix3fMulMatrix3f(&ThisRot, &LastRot);				// Accumulate Last Rotation Into This One
					Matrix4fSetRotationFromMatrix3f(&Transform, &ThisRot);	// Set Our Final Transform's Rotation From This One
					redraw();
					break;
				case FL_MIDDLE_MOUSE:
					{
					Vector2f    dragp = Clickpoint;
					Vector2f delta = downPoint-dragp;
					Matrix4f matrix;
					memcpy(&matrix.m00, &Transform.M[0], sizeof(Matrix4f));
					Vector3f X(delta.x,0,0);
					X = matrix * X;
					Vector3f Y(0,-delta.y,0);
					Y = matrix * Y;
					ProcessControl.Center += X*delta.length()*0.01f;
					ProcessControl.Center += Y*delta.length()*0.01f;
					redraw();
					downPoint=Clickpoint;
					}

					break;
				case FL_RIGHT_MOUSE:
					float y = 	Click_y - Clickpoint.y;
					zoom = old_zoom + y*0.1;
					redraw();
					break;
				}
			return 1;
		case FL_RELEASE: //mouse up event ...
			MousePt.T[0] = (GLfloat)Fl::event_x();
			MousePt.T[1] = (GLfloat)Fl::event_y();
			redraw();
			return 1;
		case FL_MOUSEWHEEL: { //mouse scroll event
			int mwscrolled = Fl::event_dy();
			zoom += mwscrolled*1;
			redraw();
			return 1;
			}
		case FL_FOCUS :
		case FL_UNFOCUS : // Return 1 if you want keyboard events, 0 otherwise
			return 0;
		case FL_KEYBOARD: //keypress, key is in Fl::event_key(), ascii in Fl::event_text() .. Return 1 if you understand/use the keyboard event, 0 otherwise...
			return 1;
		case FL_SHORTCUT: // shortcut, key is in Fl::event_key(), ascii in Fl::event_text() ... Return 1 if you understand/use the shortcut event, 0 otherwise...
			return 1;
		case FL_CLOSE:
			if (fl_choice("Save settings ?", "Exit", "Save then exit", NULL))
			{
//				int a=0;
//				ProcessControl.SaveXML();
			}
			break;
		default:
			break;
	}
	// pass other events to the base class...
	return Fl_Gl_Window::handle(event);
}
Esempio n. 18
0
int ResourceWindow::handle( int event )
{
	int ret = Fl_Group::handle(event);
	std::string dndText;
	switch ( event ) {
		case FL_DND_RELEASE:
			//LOG("DND Release");
			ret = 1;
			break;
		case FL_DND_ENTER:          // return(1) for these events to 'accept' dnd
			//LOG("DND Enter");
			//Fl::belowmouse(this); // send the leave events first
			//Fl::focus(this);
			//handle(FL_FOCUS);		
			ret = 1;
			break;
		case FL_DND_DRAG:			
			ret = 1;
			break;
		case FL_DND_LEAVE:
			//LOG("DND Leave");
			ret = 1;
			break;	  
		case FL_PASTE:              // handle actual drop (paste) operation		   
			{
				//label(Fl::event_text());
				//fprintf(stderr, "PASTE: %s\n", Fl::event_text());
				//LOG("PASTE: %s\n", Fl::event_text());
				dndText = Fl::event_text();
				bool hasAsset = processedDragAndDrop(dndText);
				ret = 1;				
			}
			break;	
		case FL_PUSH:  
		{// do 'copy/dnd' when someone clicks on box
			if (Fl::event_button() == 2)
			{
				LOG("press middle button");
				LOG("lastClickedItemPath = %s",lastClickedItemPath.c_str());
				Fl_Tree_Item* lastItem = resourceTree->find_item(lastClickedItemPath.c_str());	
				if (lastItem)
				{
					const char* itemType = (const char*)lastItem->user_data();
					bool sendDND = false;
					std::string dndMsg = "";
					if (strcmp(itemType, "skeleton") == 0)
					{
						std::string skName = lastItem->label();
						dndMsg = "SKELETON:";
						dndMsg += skName;
						sendDND = true;
					}
					else if (strcmp(itemType, "pawn") == 0)
					{
						dndMsg = "PAWN:dummy";
						sendDND = true;
					}
					
					//Fl::copy("message",7,0);
					if (sendDND)
					{
						Fl::copy(dndMsg.c_str(),dndMsg.length(),0);
						Fl::dnd();
					}					
					ret = 1;
				}			
			}			
			break;
		}
		case FL_KEYDOWN:  
		{
		  switch (Fl::event_key())
		  {
			case FL_Delete:
				{
					// check pawns and characters for selection
					Fl_Tree_Item* tree = getTreeFromName("pawn");
					int numChildren = tree->children();
					for (int c = 0; c < numChildren; c++)
					{
						Fl_Tree_Item* child = tree->child(c);
						if (child->is_selected())
						{
							const char* name = child->label();
							int confirm = fl_choice(vhcl::Format("Are you sure you want to delete '%s'?",name).c_str(), "No", "Yes", NULL);
							if (confirm == 0)
								return 0;
							SmartBody::SBScene::getScene()->removePawn(name);
							updateGUI();
							return 1;
						}
					}

					tree = getTreeFromName("character");
					numChildren = tree->children();
					for (int c = 0; c < numChildren; c++)
					{
						Fl_Tree_Item* child = tree->child(c);
						if (child->is_selected())
						{
							const char* name = child->label();
							int confirm = fl_choice(vhcl::Format("Are you sure you want to delete '%s'?",name).c_str(), "No", "Yes", NULL);
							if (confirm == 0)
								return 0;
							SmartBody::SBScene::getScene()->removeCharacter(name);
							updateGUI();
							return 1;
						}
					}
				
				}
				break;
			default:
				break;
		  }
		}
	}
	return ret;
}
Esempio n. 19
0
void
Track::menu_cb ( const Fl_Menu_ *m )
{
    char picked[256];

    m->item_pathname( picked, sizeof( picked ) );

    DMESSAGE( "Picked: %s", picked );

    Logger log( this );

    if ( ! strcmp( picked, "Type/Mono" ) )
    {
        command_configure_channels( 1 );
    }
    else if ( ! strcmp( picked, "Type/Stereo" ) )
    {
        command_configure_channels( 2 );
    }
    else if ( ! strcmp( picked, "Type/Quad" ) )
    {
        command_configure_channels( 4 );
    }
    else if ( ! strcmp( picked, "Type/..." ) )
    {
        const char *s = fl_input( "How many channels?", "3" );
        if ( s )
        {

            int c = atoi( s );

            if ( c <= 0 || c > 10 )
                fl_alert( "Invalid number of channels." );
            else
            {
                command_configure_channels(c);
            }
        }
    }
    else if ( ! strcmp( picked, "/Add Control" ) )
    {
        /* add audio track */
        char *name = get_unique_control_name( "Control" );

        timeline->wrlock();
        new Control_Sequence( this, name );
        timeline->unlock();
    }
    else if ( ! strcmp( picked, "/Overlay controls" ) )
    {
        overlay_controls( ! m->mvalue()->value() );
    }
    else if ( ! strcmp( picked, "/Add Annotation" ) )
    {
        add( new Annotation_Sequence( this ) );
    }
    else if ( ! strcmp( picked, "/Color" ) )
    {
        unsigned char r, g, b;

        Fl::get_color( color(), r, g, b );

        if ( fl_color_chooser( "Track Color", r, g, b ) )
        {
            color( fl_rgb_color( r, g, b ) );
        }

        redraw();
    }
    else if ( ! strcmp( picked, "Flags/Record" ) )
    {
        armed( m->mvalue()->flags & FL_MENU_VALUE );
    }
    else if ( ! strcmp( picked, "Flags/Mute" ) )
    {
        mute( m->mvalue()->flags & FL_MENU_VALUE );
    }
    else if ( ! strcmp( picked, "Flags/Solo" ) )
    {
        solo( m->mvalue()->flags & FL_MENU_VALUE );
    }
    else if ( ! strcmp( picked, "Size/Small" ) )
    {
        size( 0 );
    }
    else if ( ! strcmp( picked, "Size/Medium" ) )
    {
        size( 1 );
    }
    else if ( ! strcmp( picked, "Size/Large" ) )
    {
        size( 2 );
    }
    else if ( ! strcmp( picked, "Size/Huge" ) )
    {
        size( 3 );
    }
    else if ( ! strcmp( picked, "/Remove" ) )
    {
        int r = fl_choice( "Are you certain you want to remove track \"%s\"?", "Cancel", NULL, "Remove", name() );

        if ( r == 2 )
        {
            timeline->command_remove_track( this );
             Fl::delete_widget( this );
        }
    }
    else if ( ! strcmp( picked, "/Rename" ) )
    {
        ((Fl_Sometimes_Input*)name_field)->take_focus();
    }
    else if ( ! strcmp( picked, "/Move Up" ) )
    {
        timeline->command_move_track_up( this );
    }
    else if ( ! strcmp( picked, "/Move Down" ) )
    {
        timeline->command_move_track_down( this );
    }
    else if ( !strcmp( picked, "Takes/Show all takes" ) )
    {
        show_all_takes( ! m->mvalue()->value() );
    }
    else if ( !strcmp( picked, "Takes/New" ) )
    {
        timeline->wrlock();
        sequence( (Audio_Sequence*)sequence()->clone_empty() );
        timeline->unlock();
    }
    else if ( !strcmp( picked, "Takes/Remove" ) )
    {
            if ( takes->children() )
            {
                Loggable::block_start();

                timeline->wrlock();

                Audio_Sequence *s = sequence();

                sequence( (Audio_Sequence*)takes->child( 0 ) );

                delete s;

                timeline->unlock();

                Loggable::block_end();
            }
    }
    else if ( !strcmp( picked, "Takes/Remove others" ))
    {
        if ( takes->children() )
            {
                Loggable::block_start();

                takes->clear();

                Loggable::block_end();
            }
    }
    else if ( !strncmp( picked, "Takes/", sizeof( "Takes/" ) - 1 ) )
    {
        Audio_Sequence* s = (Audio_Sequence*)m->mvalue()->user_data();

        timeline->wrlock();
        sequence( s );
        timeline->unlock();
    }
}
Esempio n. 20
0
/*
============================================================================
Saves the log data to a file using the current window width
============================================================================
*/
void VTTpddServerLog::SaveFile(MString filename)
{
	FILE*			fd;
	int				count, c, i, dataIdx;
	VTTpddLogEntry*	pEntry;
	MString			fmt, hexFmt;

	// Validate we have data
	if (m_log.GetSize() == 0)
		return;

	// Test if the file exists
	if ((fd = fopen((const char *) filename, "r")) != NULL)
	{
		// Close the file
		fclose(fd);
		int ans = fl_choice("Overwrite existing file %s?", "Ok", "Cancel", NULL, 
				fl_filename_name((const char *) filename));	
		if (ans == 1)
			return;
	}

	// Try to open the file
	if ((fd = fopen((const char *) filename, "w")) == NULL)
	{
		MString err;

		err.Format("Unable to create file %s\n", (const char *) filename);
		fl_message("%s", (const char *) err);
		return;
	}

	// Test if any leftover RX or TX data not logged to an entry yet
	if (m_rxCount > 0)
		AddNewEntry(TPDD_LOG_RX, m_rxCount, m_rxBuffer);
	if (m_txCount > 0)
		AddNewEntry(TPDD_LOG_TX, m_txCount, m_txBuffer);
	m_txCount = 0;
	m_rxCount = 0;
	
	// Now loop for all entries
	count = m_log.GetSize();
	for (c = 0; c < count; c++)
	{
		// Get the next entry
		pEntry = (VTTpddLogEntry *) m_log[c];
		fmt.Format("%4d: %s: ", pEntry->m_ref, pEntry->m_rxTx ? "TX" : "RX");
		i = 0;
		dataIdx = 0;
		while (dataIdx < pEntry->m_count)
		{
			if (dataIdx != 0)
				fmt = "          ";
			// "Print" the HEX data to the line
			for (i = 0; i < m_bytesPerLine && dataIdx + i < pEntry->m_count; i++)
			{
				hexFmt.Format("%02X ", (unsigned char) pEntry->m_pData[dataIdx + i]);
				fmt += hexFmt;
			}

			// Pad with spaces if less then m_bytesPerLine
			for ( ; i < m_bytesPerLine; i++)
				fmt += (char *) "   ";

			// "Print" the ASCII data to the line
			fmt += (char *) "  ";
			for (i = 0; i < m_bytesPerLine && dataIdx + i < pEntry->m_count; i++)
			{
				// Test if it's actual ASCII data or not
				if (pEntry->m_pData[dataIdx + i] >= ' ' && pEntry->m_pData[dataIdx + i] <= '~')
					hexFmt.Format("%c", (unsigned char) pEntry->m_pData[dataIdx + i]);
				else
					hexFmt = '.';
				fmt += hexFmt;
			}

			// Save to the file
			fprintf(fd, "%s\n", (const char *) fmt);
			dataIdx += i;
		}
	}

	// Close the file
	fclose(fd);
}
Esempio n. 21
0
void VSPAEROScreen::GuiDeviceCallBack( GuiDevice* device )
{
    assert( m_ScreenMgr );

    Vehicle *veh = VehicleMgr.GetVehicle();

    if( veh )
    {
        //TODO add callback to determine if the setup file text has been edited

        if ( device == &m_SetupButton )
        {
            if( veh->GetVSPAEROCmd().empty() || !FileExist( VSPAEROMgr.m_DegenFileFull ) || VSPAEROMgr.IsSolverRunning() )
            { /* Do nothing. Should not be reachable, button should be deactivated.*/ }
            else
            {
                if ( FileExist( VSPAEROMgr.m_SetupFile ) )
                {
                    switch( fl_choice( "Overwrite any existing setup file?", "Cancel", "Abort", "Overwrite" ) )
                    {
                    case( 0 ):
                    case ( 1 ):
                        break;
                    case( 2 ):
                        // Clear the solver console
                        m_SolverBuffer->text( "" );

                        m_SolverProcess.StartThread( solver_setup_thread_fun, ( void* ) &m_SolverPair );
                        break;
                    }
                }
                else
                {
                    // Clear the solver console
                    m_SolverBuffer->text( "" );

                    m_SolverProcess.StartThread( solver_setup_thread_fun, ( void* ) &m_SolverPair );
                }
            }
        }
        else if ( device == &m_SolverButton )
        {
            if( veh->GetVSPAEROCmd().empty() || !FileExist( VSPAEROMgr.m_DegenFileFull ) || VSPAEROMgr.IsSolverRunning() )
            { /* Do nothing. Should not be reachable, button should be deactivated.*/ }
            else
            {
                // Clear out previous results
                VSPAEROMgr.ClearAllPreviousResults();

                // Clear the solver console
                m_SolverBuffer->text( "" );

                //Show the plot screen
                m_ScreenMgr->m_ShowPlotScreenOnce = true;   //deferred show of plot screen

                VSPAEROPlotScreen * vspapscreen = ( VSPAEROPlotScreen * )m_ScreenMgr->GetScreen( ScreenMgr::VSP_VSPAERO_PLOT_SCREEN );
                if( vspapscreen )
                {
                    vspapscreen->SetDefaultView();
                    vspapscreen->Update();
                }

                m_SolverProcess.StartThread( solver_thread_fun, ( void* ) &m_SolverPair );

            }
        }
        else if ( device == &m_ViewerButton )
        {
            if( veh->GetVIEWERCmd().empty() || !FileExist( VSPAEROMgr.m_DegenFileFull ) || m_ViewerProcess.IsRunning() )
            { /* Do nothing. Should not be reachable, button should be deactivated.*/ }
            else
            {
                vector<string> args;
                args.push_back( VSPAEROMgr.m_ModelNameBase );

                m_ViewerProcess.ForkCmd( veh->GetExePath(), veh->GetVIEWERCmd(), args );

                m_ViewerBuffer->text( "" );
                m_ViewerMonitor.StartThread( monitorfun, ( void* ) &m_ViewerPair );

            }
        }
        else if( device == &m_KillSolverSetupButton )
        {
            VSPAEROMgr.KillSolver();
        }
        else if( device == &m_KillSolverButton )
        {
            VSPAEROMgr.KillSolver();
        }
        else if( device == &m_PlotButton )
        {
            m_ScreenMgr->m_ShowPlotScreenOnce = true;   //deferred show of plot screen
        }
        else if( device == &m_SaveSetup )
        {
            SaveSetup();
        }
        else if( device == &m_ReadSetup )
        {
            ReadSetup();
        }
        else if( device == &m_RefWingChoice )
        {
            int id = m_RefWingChoice.GetVal();
            VSPAEROMgr.m_RefGeomID = m_WingGeomVec[id];
        }
        else if( device == &m_GeomSetChoice )
        {
            VSPAEROMgr.m_GeomSet = m_GeomSetChoice.GetVal();
        }
        else if( device == &m_ComputeGeometryButton )
        {
            VSPAEROMgr.ComputeGeometry();
        }
        else if( device == &m_DegenFileButton )
        {
            veh->setExportFileName( vsp::DEGEN_GEOM_CSV_TYPE, m_ScreenMgr->GetSelectFileScreen()->FileChooser( "Select degen geom CSV output file.", "*.csv" ) );
        }
        else if( device == &m_CompGeomFileButton )
        {
            veh->setExportFileName( vsp::VSPAERO_PANEL_TRI_TYPE, m_ScreenMgr->GetSelectFileScreen()->FileChooser( "Select comp geom TRI output file.", "*.tri" ) );
        }
        else if( device == &m_CGSetChoice )
        {
            VSPAEROMgr.m_CGGeomSet = m_CGSetChoice.GetVal();
        }
        else if( device == &m_MassPropButton )
        {
            string id = veh->MassPropsAndFlatten( m_CGSetChoice.GetVal(), VSPAEROMgr.m_NumMassSlice(), false, false );
            veh->DeleteGeom( id );

            VSPAEROMgr.m_Xcg = veh->m_CG.x();
            VSPAEROMgr.m_Ycg = veh->m_CG.y();
            VSPAEROMgr.m_Zcg = veh->m_CG.z();
        }
        else if( device == &m_ExportResultsToCsvButton )
        {
            string fileName = m_ScreenMgr->GetSelectFileScreen()->FileChooser( "Select CSV File", "*.csv" );
            if ( fileName.size() > 0 )
            {
                int status = VSPAEROMgr.ExportResultsToCSV( fileName );
                if ( status != vsp::VSP_OK )
                {
                    char strBuf[1000];
                    sprintf( strBuf, "File export failed\nFile: %s", fileName.c_str() );
                    fl_alert( strBuf );
                }
            }
        }
    }
    m_ScreenMgr->SetUpdateFlag( true );
}